Skip to content

Commit 08cbb03

Browse files
committed
implement common_hal_busio_uart_clear_rx_buffer
1 parent f543c84 commit 08cbb03

File tree

1 file changed

+5
-1
lines changed
  • ports/nrf/common-hal/busio

1 file changed

+5
-1
lines changed

ports/nrf/common-hal/busio/UART.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
250250
}
251251

252252
void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) {
253-
253+
// Discard received byte, and queue 1-byte transfer for rx_characters_available()
254+
if ( self->rx_count > 0 ) {
255+
self->rx_count = -1;
256+
_VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1));
257+
}
254258
}
255259

256260
bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {

0 commit comments

Comments
 (0)