Skip to content

Commit

Permalink
soc: st: stm32: complete wkup pins cfg before poweroff
Browse files Browse the repository at this point in the history
Complete wake-up pins configuration before powering off
the system when the CONFIG_STM32_WKUP_PINS flag is enabled.

Signed-off-by: Abderrahmane Jarmouni <[email protected]>
  • Loading branch information
ajarmouni-st committed May 22, 2024
1 parent a44db46 commit 796a527
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions soc/st/stm32/stm32l4x/poweroff.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>

#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>
#include <stm32_ll_system.h>

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();
Expand Down
9 changes: 9 additions & 0 deletions soc/st/stm32/stm32u5x/poweroff.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>

#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>

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();

Expand Down
7 changes: 7 additions & 0 deletions soc/st/stm32/stm32wbx/poweroff.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>

#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>

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();
Expand Down
9 changes: 9 additions & 0 deletions soc/st/stm32/stm32wlx/poweroff.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
* Copyright (c) 2024 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>

#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>

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();

Expand Down

0 comments on commit 796a527

Please sign in to comment.