From 08cbb03bddfa1a18ac8048e979fb2e9682beb1c2 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 3 Oct 2018 11:39:01 +0700 Subject: implement common_hal_busio_uart_clear_rx_buffer --- ports/nrf/common-hal/busio/UART.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.3