diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index dd79612322d..097ba70c1b6 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1279,7 +1279,8 @@ static void uart_stm32_isr(const struct device *dev) uart_stm32_err_check(dev); #endif /* CONFIG_UART_ASYNC_API */ -#ifdef CONFIG_PM +#if defined(CONFIG_PM) && defined(IS_UART_WAKEUP_FROMSTOP_INSTANCE) \ + && defined(USART_CR3_WUFIE) if (LL_USART_IsEnabledIT_WKUP(config->usart) && LL_USART_IsActiveFlag_WKUP(config->usart)) { @@ -2017,13 +2018,14 @@ static int uart_stm32_init(const struct device *dev) * CONFIG_PM_DEVICE=n : Always active * CONFIG_PM_DEVICE=y : Controlled by pm_device_wakeup_enable() */ - +#ifdef USART_CR3_WUFIE LL_USART_Disable(config->usart); LL_USART_SetWKUPType(config->usart, LL_USART_WAKEUP_ON_RXNE); LL_USART_EnableIT_WKUP(config->usart); LL_USART_ClearFlag_WKUP(config->usart); - LL_USART_EnableInStopMode(config->usart); LL_USART_Enable(config->usart); +#endif + LL_USART_EnableInStopMode(config->usart); if (config->wakeup_line != STM32_EXTI_LINE_NONE) { /* Prepare the WAKEUP with the expected EXTI line */