tests: uart_async_api: flush reception in read_abort

After finish transmitting some bytes might be in the
peripheral receive register, since the transmition
is still happening after reception disabled.
This patch ensures that the peripheral has no
bytes in its internal state.

Signed-off-by: Shlomi Vaknin <shlomi.39sd@gmail.com>
This commit is contained in:
Shlomi Vaknin 2020-12-21 04:27:05 +02:00 committed by Carles Cufí
commit 13a8d1c1c2

View file

@ -305,6 +305,14 @@ void test_read_abort(void)
"RX_DISABLED timeout");
zassert_false(failed_in_isr, "Unexpected order of uart events");
zassert_not_equal(memcmp(tx_buf, rx_buf, 100), 0, "Buffers equal");
/* Read out possible other RX bytes
* that may affect following test on RX
*/
uart_rx_enable(uart_dev, rx_buf, sizeof(rx_buf), 50);
while (k_sem_take(&rx_rdy, K_MSEC(1000)) != -EAGAIN)
;
uart_rx_disable(uart_dev);
}
ZTEST_BMEM volatile size_t sent;