52#include "nrfx_config.h"
53#include "nrfx_uarte.h"
54#include "hal/nrf_gpio.h"
56static int (*input_handler)(
unsigned char c) = NULL;
58static nrfx_uarte_t instance = NRFX_UARTE_INSTANCE(0);
59static uint8_t uarte_buffer;
65 }
while(nrfx_uarte_tx_in_progress(&instance));
66 nrfx_uarte_tx(&instance, &data,
sizeof(data));
76uarte_handler(nrfx_uarte_event_t
const *p_event,
void *p_context)
83 if(p_event->type == NRFX_UARTE_EVT_RX_DONE) {
85 p_data = p_event->data.rxtx.p_data;
86 bytes = p_event->data.rxtx.bytes;
87 for(i = 0; i < bytes; i++) {
88 input_handler(p_data[i]);
90 nrfx_uarte_rx(&instance, &uarte_buffer,
sizeof(uarte_buffer));
98 input_handler =
input;
101 nrfx_uarte_rx(&instance, &uarte_buffer,
sizeof(uarte_buffer));
108#if defined(NRF_UARTE0_TX_PORT) && defined(NRF_UARTE0_TX_PIN) \
109 && defined(NRF_UARTE0_RX_PORT) && defined(NRF_UARTE0_RX_PIN)
110 const nrfx_uarte_config_t config = NRFX_UARTE_DEFAULT_CONFIG(
111 NRF_GPIO_PIN_MAP(NRF_UARTE0_TX_PORT, NRF_UARTE0_TX_PIN),
112 NRF_GPIO_PIN_MAP(NRF_UARTE0_RX_PORT, NRF_UARTE0_RX_PIN)
115 nrfx_uarte_init(&instance, &config, uarte_handler);
117 (void) uarte_handler;
void uarte_write(unsigned char data)
Writes to the UARTE driver.
void uarte_init(void)
Initializa 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.