#include "bsp_uart.h" #define UART_RX_PIN_NUMBER 8 #define UART_TX_PIN_NUMBER 6 #define UART_CTS_PIN_NUMBER 7 #define UART_RTS_PIN_NUMBER 5 #define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED #define UART_TX_BUF_SIZE 1024 /**< UART TX buffer size. */ #define UART_RX_BUF_SIZE 1024 /**< UART RX buffer size. */ extern void AABBCC_REC(unsigned char data); void uart_error_handle(app_uart_evt_t * p_event) { unsigned char data=0; unsigned int error_code=0; switch(p_event->evt_type) { case APP_UART_DATA_READY: error_code=app_uart_get(&data); if(error_code==NRF_SUCCESS)AABBCC_REC(data); else printf("uart_error_handle ->error=0x%x\n",error_code); break; case APP_UART_FIFO_ERROR: break; case APP_UART_COMMUNICATION_ERROR: break; case APP_UART_TX_EMPTY: break; case APP_UART_DATA: break; } } void bsp_uart_init(void) { uint32_t err_code; const app_uart_comm_params_t comm_params = { UART_RX_PIN_NUMBER, UART_TX_PIN_NUMBER, UART_RTS_PIN_NUMBER, UART_CTS_PIN_NUMBER, UART_HWFC, false, #if defined (UART_PRESENT) NRF_UART_BAUDRATE_115200 #else NRF_UARTE_BAUDRATE_115200 #endif }; 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("bsp_uart_init OK\r\n"); }