Skip to content

Commit d700943

Browse files
jurenatkartben
authored andcommitted
soc: st: stm32: Add poweroff to F4 family
Allows F4 MCUs to enter standby mode which behave similar to the poweroff mode. Signed-off-by: Tomáš Juřena <[email protected]>
1 parent 41a996d commit d700943

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

soc/st/stm32/stm32f4x/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/li
1212
zephyr_sources_ifdef(CONFIG_PM
1313
power.c
1414
)
15+
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)

soc/st/stm32/stm32f4x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ config SOC_SERIES_STM32F4X
1212
select CPU_HAS_ARM_MPU
1313
select HAS_SWO
1414
select HAS_PM
15+
select HAS_POWEROFF
1516
select SOC_EARLY_INIT_HOOK

soc/st/stm32/stm32f4x/poweroff.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA
3+
* Copyright (c) 2024 STMicroelectronics
4+
* Copyright (c) 2025 Tomas Jurena
5+
*
6+
* SPDX-License-Identifier: Apache-2.0
7+
*/
8+
9+
#include <zephyr/kernel.h>
10+
#include <zephyr/sys/poweroff.h>
11+
#include <zephyr/toolchain.h>
12+
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>
13+
14+
#include <stm32_ll_cortex.h>
15+
#include <stm32_ll_pwr.h>
16+
17+
void z_sys_poweroff(void)
18+
{
19+
#ifdef CONFIG_STM32_WKUP_PINS
20+
LL_PWR_ClearFlag_WU();
21+
#endif /* CONFIG_STM32_WKUP_PINS */
22+
23+
LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
24+
LL_LPM_EnableDeepSleep();
25+
26+
k_cpu_idle();
27+
28+
CODE_UNREACHABLE;
29+
}

0 commit comments

Comments
 (0)