Skip to content

Commit

Permalink
modules: shell: Add wait before UARTs are suspended
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jtguggedal authored and simensrostad committed Nov 8, 2024
1 parent 367aafb commit 3c10e98
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/modules/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 3c10e98

Please sign in to comment.