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 
z_sys_poweroff(void)16 void z_sys_poweroff(void)
17 {
18 #ifdef CONFIG_STM32_WKUP_PINS
19 	stm32_pwr_wkup_pin_cfg_pupd();
20 
21 	LL_PWR_ClearFlag_WU();
22 #endif /* CONFIG_STM32_WKUP_PINS */
23 
24 	LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
25 	LL_LPM_EnableDeepSleep();
26 
27 	k_cpu_idle();
28 
29 	CODE_UNREACHABLE;
30 }
31