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 <jurenatomas@gmail.com>
This commit is contained in:
parent
41a996df94
commit
d700943d29
3 changed files with 31 additions and 0 deletions
|
@ -12,3 +12,4 @@ set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/li
|
|||
zephyr_sources_ifdef(CONFIG_PM
|
||||
power.c
|
||||
)
|
||||
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
|
|
@ -12,4 +12,5 @@ config SOC_SERIES_STM32F4X
|
|||
select CPU_HAS_ARM_MPU
|
||||
select HAS_SWO
|
||||
select HAS_PM
|
||||
select HAS_POWEROFF
|
||||
select SOC_EARLY_INIT_HOOK
|
||||
|
|
29
soc/st/stm32/stm32f4x/poweroff.c
Normal file
29
soc/st/stm32/stm32f4x/poweroff.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
* Copyright (c) 2025 Tomas Jurena
|
||||
*
|
||||
* 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
|
||||
LL_PWR_ClearFlag_WU();
|
||||
#endif /* CONFIG_STM32_WKUP_PINS */
|
||||
|
||||
LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
|
||||
LL_LPM_EnableDeepSleep();
|
||||
|
||||
k_cpu_idle();
|
||||
|
||||
CODE_UNREACHABLE;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue