1 /* 2 * Copyright (c) 2024 Nuvoton Technology Corporation. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/kernel.h> 8 #include <zephyr/devicetree.h> 9 #include <zephyr/sys/poweroff.h> 10 #include <NuMicro.h> 11 z_sys_poweroff(void)12void z_sys_poweroff(void) 13 { 14 SYS_UnlockReg(); 15 16 /* Clear all wake-up flag */ 17 CLK->PMUSTS |= CLK_PMUSTS_CLRWK_Msk; 18 19 /* Select Power-down mode */ 20 CLK_SetPowerDownMode(DT_PROP_OR(DT_NODELABEL(scc), powerdown_mode, CLK_PMUCTL_PDMSEL_SPD0)); 21 22 /* Enable RTC wake-up */ 23 CLK_ENABLE_RTCWK(); 24 25 /* Enter to Power-down mode */ 26 CLK_PowerDown(); 27 28 k_cpu_idle(); 29 30 CODE_UNREACHABLE; 31 } 32