Skip to content

Commit e10ed05

Browse files
nordic-krchaescolar
authored andcommitted
drivers: serial: uart_async_to_irq: Move resetting to disabling function
Move resetting of the receiver state to disabling function so that once uart is disabled there is no data pending in the module. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 8f89013 commit e10ed05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/serial/uart_async_to_irq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ static void on_rx_dis(const struct device *dev, struct uart_async_to_irq_data *d
107107
if (data->flags & A2I_RX_ENABLE) {
108108
int err;
109109

110+
if (data->rx.async_rx.pending_bytes == 0) {
111+
uart_async_rx_reset(&data->rx.async_rx);
112+
}
113+
110114
err = try_rx_enable(dev, data);
111115
if (err == 0) {
112116
data->rx.pending_buf_req = 0;
@@ -331,7 +335,6 @@ int uart_async_to_irq_rx_enable(const struct device *dev)
331335
return err;
332336
}
333337

334-
uart_async_rx_reset(&data->rx.async_rx);
335338

336339
err = try_rx_enable(dev, data);
337340
if (err == 0) {
@@ -355,6 +358,8 @@ int uart_async_to_irq_rx_disable(const struct device *dev)
355358
k_sem_take(&data->rx.sem, K_FOREVER);
356359
}
357360

361+
uart_async_rx_reset(&data->rx.async_rx);
362+
358363
return 0;
359364
}
360365

0 commit comments

Comments
 (0)