| /* |
| * Copyright (c) 2023 Nordic Semiconductor ASA |
| * Copyright (c) 2024 STMicroelectronics |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| #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 |
| stm32_pwr_wkup_pin_cfg_pupd(); |
| #endif /* CONFIG_STM32_WKUP_PINS */ |
| |
| LL_PWR_ClearFlag_WU(); |
| |
| LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY); |
| LL_PWR_SetRadioSBRetention(LL_PWR_RADIO_SB_NO_RETENTION); |
| LL_PWR_SetSRAM1SBRetention(LL_PWR_SRAM1_SB_NO_RETENTION); |
| LL_PWR_SetSRAM2SBRetention(LL_PWR_SRAM2_SB_NO_RETENTION); |
| LL_LPM_EnableDeepSleep(); |
| |
| __WFI(); |
| |
| CODE_UNREACHABLE; |
| } |