Skip to content

Commit eb6e514

Browse files
robert-hhdpgeorge
authored andcommitted
nrf/modules/machine/uart: Prevent UART lock-up after a receive error.
Like frame error, overrun, etc. Fix is provided by @ricksorensen.
1 parent a529e0e commit eb6e514

File tree

1 file changed

+4
-0
lines changed
  • ports/nrf/modules/machine

1 file changed

+4
-0
lines changed

ports/nrf/modules/machine/uart.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ typedef struct _machine_hard_uart_buf_t {
7777
#define NRF_UART_HWFC_DISABLED NRF_UARTE_HWFC_DISABLED
7878
#define NRF_UART_PARITY_EXCLUDED NRF_UARTE_PARITY_EXCLUDED
7979
#define NRFX_UART_EVT_RX_DONE NRFX_UARTE_EVT_RX_DONE
80+
#define NRFX_UART_EVT_ERROR NRFX_UARTE_EVT_ERROR
8081

8182
#define NRF_UART_BAUDRATE_1200 NRF_UARTE_BAUDRATE_1200
8283
#define NRF_UART_BAUDRATE_2400 NRF_UARTE_BAUDRATE_2400
@@ -136,6 +137,9 @@ STATIC void uart_event_handler(nrfx_uart_event_t const *p_event, void *p_context
136137
{
137138
ringbuf_put((ringbuf_t *)&self->buf.rx_ringbuf, chr);
138139
}
140+
} else if (p_event->type == NRFX_UART_EVT_ERROR) {
141+
// Perform a read to unlock UART in case of an error
142+
nrfx_uart_rx(self->p_uart, &self->buf.rx_buf[0], 1);
139143
}
140144
}
141145

0 commit comments

Comments
 (0)