From 3c10e9847833facf57f0b7c64f2f301d7e004bbf Mon Sep 17 00:00:00 2001 From: Jan Tore Guggedal Date: Fri, 8 Nov 2024 10:30:21 +0100 Subject: [PATCH] modules: shell: Add wait before UARTs are suspended Add a short wait before UARTs are suspended to leave time to empty the buffers. Otherwise an assert will kick in because the TX_STOPPED event has not been received before suspending the UARTs. Signed-off-by: Jan Tore Guggedal --- app/src/modules/shell/shell.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/modules/shell/shell.c b/app/src/modules/shell/shell.c index 8681ac80..63eb5493 100644 --- a/app/src/modules/shell/shell.c +++ b/app/src/modules/shell/shell.c @@ -67,6 +67,12 @@ static void uart_disable_handler(struct k_work *work) } #endif + /* Wait for UART buffers to be emptied before suspending. + * If a transfer is ongoing, the driver will cause an assertion to fail. + * 100 ms is an arbitrary value that should be enough for the buffers to empty. + */ + k_busy_wait(100 * USEC_PER_MSEC); + if (device_is_ready(uart1_dev)) { pm_device_action_run(uart1_dev, PM_DEVICE_ACTION_SUSPEND); }