50 #if PLATFORM_HAS_UARTE 52 #include "nrfx_config.h" 53 #include "nrfx_uarte.h" 54 #include "hal/nrf_gpio.h" 56 static int (*input_handler)(
unsigned char c) = NULL;
57 #define NRF_UARTE0_TX NRF_GPIO_PIN_MAP(NRF_UARTE0_TX_PORT, NRF_UARTE0_TX_PIN) 58 #define NRF_UARTE0_RX NRF_GPIO_PIN_MAP(NRF_UARTE0_RX_PORT, NRF_UARTE0_RX_PIN) 60 static nrfx_uarte_t instance = NRFX_UARTE_INSTANCE(0);
61 static nrfx_uarte_config_t
config = NRFX_UARTE_DEFAULT_CONFIG(NRF_UARTE0_TX, NRF_UARTE0_RX);
62 static uint8_t uarte_buffer;
68 }
while(nrfx_uarte_tx_in_progress(&instance));
69 nrfx_uarte_tx(&instance, &data,
sizeof(data));
79 uarte_handler(nrfx_uarte_event_t
const *p_event,
void *p_context)
86 if(p_event->type == NRFX_UARTE_EVT_RX_DONE) {
88 p_data = p_event->data.rxtx.p_data;
89 bytes = p_event->data.rxtx.bytes;
90 for(i = 0; i < bytes; i++) {
91 input_handler(p_data[i]);
93 nrfx_uarte_rx(&instance, &uarte_buffer,
sizeof(uarte_buffer));
101 input_handler =
input;
104 nrfx_uarte_rx(&instance, &uarte_buffer,
sizeof(uarte_buffer));
111 nrfx_uarte_init(&instance, &
config, uarte_handler);
void uarte_init(void)
Initializa the UARTE driver.
void uarte_write(unsigned char data)
Writes to the UARTE driver.
void uarte_set_input(int(*input)(unsigned char c))
Sets the input handler called in the event handler.
static void input(void)
Process a received 6lowpan packet.