1 /* 2 * Copyright (c) 2023 Bjarki Arge Andreasen 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #include <zephyr/sys/poweroff.h> 7 #include <soc.h> 8 9 /* 10 * Poweroff will make the chip enter the backup low-power mode, which 11 * achieves the lowest possible power consumption. Wakeup from this mode 12 * requires enabling a wakeup source or input, or power cycling the device. 13 */ 14 soc_core_sleepdeep_enable(void)15static void soc_core_sleepdeep_enable(void) 16 { 17 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; 18 } 19 soc_core_sleepdeep_wait(void)20static void soc_core_sleepdeep_wait(void) 21 { 22 __WFE(); 23 __WFI(); 24 } 25 z_sys_poweroff(void)26void z_sys_poweroff(void) 27 { 28 soc_core_sleepdeep_enable(); 29 BPM->PMCON |= BPM_PMCON_BKUP; 30 soc_core_sleepdeep_wait(); 31 32 CODE_UNREACHABLE; 33 } 34