1 /*
2  * Copyright (c) 2023 Nordic Semiconductor ASA
3  * Copyright (c) 2024 STMicroelectronics
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <zephyr/kernel.h>
9 #include <zephyr/sys/poweroff.h>
10 #include <zephyr/toolchain.h>
11 #include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>
12 
13 #include <stm32_ll_cortex.h>
14 #include <stm32_ll_pwr.h>
15 #include <stm32_ll_system.h>
16 
z_sys_poweroff(void)17 void z_sys_poweroff(void)
18 {
19 #ifdef CONFIG_STM32_WKUP_PINS
20 	stm32_pwr_wkup_pin_cfg_pupd();
21 
22 	LL_PWR_ClearFlag_WU();
23 #endif /* CONFIG_STM32_WKUP_PINS */
24 
25 	LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
26 	LL_LPM_EnableDeepSleep();
27 	LL_DBGMCU_DisableDBGStandbyMode();
28 
29 	k_cpu_idle();
30 
31 	CODE_UNREACHABLE;
32 }
33