zephyr/soc/st/stm32/stm32f4x/poweroff.c
Tomáš Juřena d700943d29 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>
2025-04-11 06:33:56 +02:00

29 lines
612 B
C

/*
* 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;
}