Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdbool.h>
- #include <stdint.h>
- #include <stdio.h>
- #include "app_uart.h"
- #include "app_error.h"
- #include "nrf_delay.h"
- #include "nrf.h"
- #include "bsp.h"
- #define MAX_TEST_DATA_BYTES (15U) /**< max number of test bytes to be used for tx and rx. */
- #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
- #define UART_RX_BUF_SIZE 1 /**< 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);
- }
- }
- /**
- * @brief Function for main application entry.
- */
- int main(void)
- {
- uint32_t err_code;
- const app_uart_comm_params_t
- comm_params =
- {
- 4,//RX_PIN_NUMBER,
- 6, //TX_PIN_NUMBER,
- RTS_PIN_NUMBER,
- CTS_PIN_NUMBER,
- APP_UART_FLOW_CONTROL_DISABLED, //APP_UART_FLOW_CONTROL_ENABLED,
- false,
- UART_BAUDRATE_BAUDRATE_Baud38400
- };
- APP_UART_FIFO_INIT(&comm_params,
- UART_RX_BUF_SIZE,
- UART_TX_BUF_SIZE,
- uart_error_handle,
- APP_IRQ_PRIORITY_LOW,
- err_code);
- APP_ERROR_CHECK(err_code);
- printf("\n\rStart: \n\r");
- while (true)
- {
- uint8_t cr;
- while(app_uart_get(&cr) != NRF_SUCCESS);
- while(app_uart_put(cr) != NRF_SUCCESS);
- if (cr == 'q' || cr == 'Q')
- {
- printf(" \n\rExit!\n\r");
- while (true)
- {
- // Do nothing.
- }
- }
- printf("Hit.\r\n");
- nrf_delay_ms(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement