[chip dv] Fix uart unexpected watermark interrupt When RX watermark fires, read the data, but if remaining items are less than 16, RX watermark won't fire. In that case, changed to keep reading until all items are received. Signed-off-by: Weicai Yang <weicai@google.com>
diff --git a/sw/device/tests/sim_dv/uart_tx_rx_test.c b/sw/device/tests/sim_dv/uart_tx_rx_test.c index a85aac2..5e0b3fb 100644 --- a/sw/device/tests/sim_dv/uart_tx_rx_test.c +++ b/sw/device/tests/sim_dv/uart_tx_rx_test.c
@@ -454,10 +454,14 @@ if (!uart_rx_done && uart_irq_rx_watermark_fired) { uart_irq_rx_watermark_fired = false; - // Receive the remaining uart_rx_data as and when the RX watermark fires. - CHECK(uart_transfer_ongoing_bytes(uart, kUartReceive, uart_rx_data, - UART_DATASET_SIZE, &uart_rx_bytes_read, - &uart_rx_done)); + // When RX watermark fires, read the data, but if remaining items are less + // than 16, RX watermark won't fire. In that case, keep reading until all + // item are received. + do { + CHECK(uart_transfer_ongoing_bytes(uart, kUartReceive, uart_rx_data, + UART_DATASET_SIZE, + &uart_rx_bytes_read, &uart_rx_done)); + } while (!uart_rx_done && (UART_DATASET_SIZE - uart_rx_bytes_read < 16)); if (uart_rx_done) { exp_uart_irq_rx_watermark = false;