/* Use flow control in loopback test. */
#define UART_HWFC APP_UART_FLOW_CONTROL_ENABLED
void uart_err_handle(app_uart_evt_type_t * p)
{
}
int main(void)
{
uint32_t err_code;
bsp_board_init(BSP_INIT_LEDS);
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
UART_HWFC,
false,
NRF_UART_BAUDRATE_115200
};
APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOWEST,
err_code);
APP_ERROR_CHECK(err_code);
printf("Hello PC from nordic Device!! \r\n");
while(true)
{
uint8_t cr;
while(app_uart_get(&cr) != NRF_SUCCESS);
if(cr == 't')
{
bsp_board_leds_on();
printf("Leds on");
}
if(cr == 'k')
{
bsp_board_leds_off();
printf("Leds off");
}
}
}
NRF52832 学习笔记 (1. UART Serial Communication)
最新推荐文章于 2024-09-12 19:46:23 发布