samples: boards: mimxrt595_evk_cm33: system_off: use sys_poweroff

Use the new sys_poweroff() API to power off the system.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2023-07-20 12:58:36 +02:00 committed by Carles Cufí
commit a99a6756aa
2 changed files with 3 additions and 15 deletions

View file

@ -3,7 +3,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_PM=y
CONFIG_POWEROFF=y
# Enable the RTC
CONFIG_COUNTER=y

View file

@ -9,11 +9,8 @@
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/counter.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
#include <zephyr/sys/poweroff.h>
#define BUSY_WAIT_S 2U
#define SLEEP_S 2U
#define SOFT_OFF_S 10U
#define RTC_NODE DT_NODELABEL(rtc)
@ -54,16 +51,7 @@ int main(void)
counter_ticks_to_us(rtc_dev, alarm_cfg.ticks) / (1000ULL * 1000ULL));
printk("Entering system off");
pm_state_force(0u, &(struct pm_state_info){ PM_STATE_SOFT_OFF, 0, 0 });
sys_poweroff();
/* Now we need to go sleep. This will let the idle thread runs and
* the pm subsystem will use the forced state.
*/
k_sleep(K_SECONDS(SLEEP_S));
printk("ERROR: System off failed\n");
while (true) {
/* spin to avoid fall-off behavior */
}
return 0;
}