Skip to content

Commit e5ab70b

Browse files
erwangocarlescufi
authored andcommitted
drivers: uart: stm32: Complete wakeup feature
Serial wakeup feature was only working whe DBG in Stop mode setting was enabled. Add required changes to make it functional also when this configuration isn't set. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 0d42aca commit e5ab70b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/serial/uart_stm32.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,18 @@ static void uart_stm32_isr(const struct device *dev)
12781278
/* Clear errors */
12791279
uart_stm32_err_check(dev);
12801280
#endif /* CONFIG_UART_ASYNC_API */
1281+
1282+
#ifdef CONFIG_PM
1283+
if (LL_USART_IsEnabledIT_WKUP(config->usart) &&
1284+
LL_USART_IsActiveFlag_WKUP(config->usart)) {
1285+
1286+
LL_USART_ClearFlag_WKUP(config->usart);
1287+
#ifdef USART_ISR_REACK
1288+
while (LL_USART_IsActiveFlag_REACK(config->usart) == 0) {
1289+
}
1290+
#endif
1291+
}
1292+
#endif
12811293
}
12821294
#endif /* CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API || CONFIG_PM */
12831295

@@ -2005,7 +2017,14 @@ static int uart_stm32_init(const struct device *dev)
20052017
* CONFIG_PM_DEVICE=n : Always active
20062018
* CONFIG_PM_DEVICE=y : Controlled by pm_device_wakeup_enable()
20072019
*/
2020+
2021+
LL_USART_Disable(config->usart);
2022+
LL_USART_SetWKUPType(config->usart, LL_USART_WAKEUP_ON_RXNE);
2023+
LL_USART_EnableIT_WKUP(config->usart);
2024+
LL_USART_ClearFlag_WKUP(config->usart);
20082025
LL_USART_EnableInStopMode(config->usart);
2026+
LL_USART_Enable(config->usart);
2027+
20092028
if (config->wakeup_line != STM32_EXTI_LINE_NONE) {
20102029
/* Prepare the WAKEUP with the expected EXTI line */
20112030
LL_EXTI_EnableIT_0_31(BIT(config->wakeup_line));

0 commit comments

Comments
 (0)