summaryrefslogtreecommitdiff
path: root/ports/nrf/common-hal/busio
diff options
context:
space:
mode:
authorhathach <thach@tinyusb.org>2018-10-03 11:39:01 +0700
committerhathach <thach@tinyusb.org>2018-10-03 11:39:01 +0700
commit08cbb03bddfa1a18ac8048e979fb2e9682beb1c2 (patch)
treee66476c90dd9c506d01de8827f4a22ca1d9afb38 /ports/nrf/common-hal/busio
parentf543c8415d96aff96b252a0256795e1eb874f2ed (diff)
implement common_hal_busio_uart_clear_rx_buffer
Diffstat (limited to 'ports/nrf/common-hal/busio')
-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) {