summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/nrf/common-hal/busio/UART.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index 8d0db34be..b2dbb56a1 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -250,7 +250,11 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
}
void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) {
-
+ // Discard received byte, and queue 1-byte transfer for rx_characters_available()
+ if ( self->rx_count > 0 ) {
+ self->rx_count = -1;
+ _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1));
+ }
}
bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {