Skip to content

Commit 53e28e0

Browse files
AlessandroLuokartben
authored andcommitted
driver: uart: ambiq: need to wait for IO stable after resume
Add a short delay to wait for IO stable when resume from sleep to prevent printing gibberish. Signed-off-by: Hao Luo <[email protected]>
1 parent 1f95b06 commit 53e28e0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/serial/uart_ambiq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ LOG_MODULE_REGISTER(uart_ambiq, CONFIG_UART_LOG_LEVEL);
2525
#define UART_AMBIQ_RSR_ERROR_MASK \
2626
(UART0_RSR_FESTAT_Msk | UART0_RSR_PESTAT_Msk | UART0_RSR_BESTAT_Msk | UART0_RSR_OESTAT_Msk)
2727

28+
#define UART_IO_RESUME_DELAY_US 100
29+
2830
#ifdef CONFIG_UART_ASYNC_API
2931
struct uart_ambiq_async_tx {
3032
const uint8_t *buf;
@@ -563,9 +565,11 @@ static int uart_ambiq_pm_action(const struct device *dev, enum pm_device_action
563565
if (err < 0) {
564566
return err;
565567
}
568+
k_busy_wait(UART_IO_RESUME_DELAY_US);
566569
status = AM_HAL_SYSCTRL_WAKE;
567570
break;
568571
case PM_DEVICE_ACTION_SUSPEND:
572+
am_hal_uart_tx_flush(data->uart_handler);
569573
/* Move pins to sleep state */
570574
err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_SLEEP);
571575
if ((err < 0) && (err != -ENOENT)) {

0 commit comments

Comments
 (0)