From 796a5275421d8914614250262824a996053be1b1 Mon Sep 17 00:00:00 2001 From: Abderrahmane Jarmouni Date: Tue, 21 May 2024 02:47:57 +0200 Subject: [PATCH] soc: st: stm32: complete wkup pins cfg before poweroff Complete wake-up pins configuration before powering off the system when the CONFIG_STM32_WKUP_PINS flag is enabled. Signed-off-by: Abderrahmane Jarmouni --- soc/st/stm32/stm32l4x/poweroff.c | 9 +++++++++ soc/st/stm32/stm32u5x/poweroff.c | 9 +++++++++ soc/st/stm32/stm32wbx/poweroff.c | 7 +++++++ soc/st/stm32/stm32wlx/poweroff.c | 9 +++++++++ 4 files changed, 34 insertions(+) diff --git a/soc/st/stm32/stm32l4x/poweroff.c b/soc/st/stm32/stm32l4x/poweroff.c index b5260dc33cdfb65..0b5a9effdd8f225 100644 --- a/soc/st/stm32/stm32l4x/poweroff.c +++ b/soc/st/stm32/stm32l4x/poweroff.c @@ -1,11 +1,14 @@ /* * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 STMicroelectronics + * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include @@ -13,6 +16,12 @@ void z_sys_poweroff(void) { +#ifdef CONFIG_STM32_WKUP_PINS + stm32_pwr_wkup_pin_cfg_pupd(); + + LL_PWR_ClearFlag_WU(); +#endif /* CONFIG_STM32_WKUP_PINS */ + LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN); LL_LPM_EnableDeepSleep(); LL_DBGMCU_DisableDBGStandbyMode(); diff --git a/soc/st/stm32/stm32u5x/poweroff.c b/soc/st/stm32/stm32u5x/poweroff.c index 191230be5235d97..1b2e26c0395c8c2 100644 --- a/soc/st/stm32/stm32u5x/poweroff.c +++ b/soc/st/stm32/stm32u5x/poweroff.c @@ -1,17 +1,26 @@ /* * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 STMicroelectronics + * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include void z_sys_poweroff(void) { +#ifdef CONFIG_STM32_WKUP_PINS + stm32_pwr_wkup_pin_cfg_pupd(); + + LL_PWR_ClearFlag_WU(); +#endif /* CONFIG_STM32_WKUP_PINS */ + LL_PWR_SetPowerMode(LL_PWR_SHUTDOWN_MODE); LL_LPM_EnableDeepSleep(); diff --git a/soc/st/stm32/stm32wbx/poweroff.c b/soc/st/stm32/stm32wbx/poweroff.c index d95aa24fc0c0557..e4319762e826215 100644 --- a/soc/st/stm32/stm32wbx/poweroff.c +++ b/soc/st/stm32/stm32wbx/poweroff.c @@ -1,18 +1,25 @@ /* * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 STMicroelectronics + * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include void z_sys_poweroff(void) { +#ifdef CONFIG_STM32_WKUP_PINS + stm32_pwr_wkup_pin_cfg_pupd(); + LL_PWR_ClearFlag_WU(); +#endif /* CONFIG_STM32_WKUP_PINS */ LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN); LL_LPM_EnableDeepSleep(); diff --git a/soc/st/stm32/stm32wlx/poweroff.c b/soc/st/stm32/stm32wlx/poweroff.c index 05d516393ea963d..e4319762e826215 100644 --- a/soc/st/stm32/stm32wlx/poweroff.c +++ b/soc/st/stm32/stm32wlx/poweroff.c @@ -1,17 +1,26 @@ /* * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 STMicroelectronics + * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include +#include #include #include void z_sys_poweroff(void) { +#ifdef CONFIG_STM32_WKUP_PINS + stm32_pwr_wkup_pin_cfg_pupd(); + + LL_PWR_ClearFlag_WU(); +#endif /* CONFIG_STM32_WKUP_PINS */ + LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN); LL_LPM_EnableDeepSleep();