From c80589af5686c503ca9f6c58d883540a7b25b4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Thu, 3 Feb 2022 15:50:43 +0100 Subject: [PATCH] drivers: uart_nrfx_uarte: Fix RX auto disabling routine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow-up to commit 11bbdb030def3b4a4b97ee380b1091913e61d371. When RX is automatically disabled because all provided RX buffers have been filled up, the rx_enabled flag needs to be cleared, otherwise it will be impossible to enable RX again. Signed-off-by: Andrzej Głąbek --- drivers/serial/uart_nrfx_uarte.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 545ac1eca9d..be45ddbd272 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -1330,7 +1330,16 @@ static void rxto_isr(const struct device *dev) notify_rx_buf_release(dev, &data->async->rx_buf, true); notify_rx_buf_release(dev, &data->async->rx_next_buf, true); - if (!data->async->rx_enabled) { + /* If the rx_enabled flag is still set at this point, it means that + * RX is being disabled because all provided RX buffers have been + * filled up. Clear the flag then, so that RX can be enabled again. + * + * If the flag is already cleared, it means that RX was aborted by + * a call to uart_rx_disable() and data from FIFO should be discarded. + */ + if (data->async->rx_enabled) { + data->async->rx_enabled = false; + } else { (void)rx_flush(dev, NULL, 0); }