12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include "bsp_uart.h"
- #include "app_uart.h"
- #if defined (UART_PRESENT)
- #include "nrf_uart.h"
- #endif
- #if defined (UARTE_PRESENT)
- #include "nrf_uarte.h"
- #endif
- #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 256 /**< UART TX buffer size. */
- #define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */
- void uart_error_handle(app_uart_evt_t * p_event)
- {
- if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR){
- APP_ERROR_HANDLER(p_event->data.error_communication);
- }
- else if (p_event->evt_type == APP_UART_FIFO_ERROR){
- APP_ERROR_HANDLER(p_event->data.error_code);
- }
- }
- 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);
- #if DEBUG_EN
- printf("bsp_uart_init OK\r\n");
- #endif
- }
|