From a99a6756aaaa162aa2e829629be42da53c32a110 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Thu, 20 Jul 2023 12:58:36 +0200 Subject: [PATCH] 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 --- .../mimxrt595_evk_cm33/system_off/prj.conf | 2 +- .../mimxrt595_evk_cm33/system_off/src/main.c | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/samples/boards/mimxrt595_evk_cm33/system_off/prj.conf b/samples/boards/mimxrt595_evk_cm33/system_off/prj.conf index a635459b712..a742075018c 100644 --- a/samples/boards/mimxrt595_evk_cm33/system_off/prj.conf +++ b/samples/boards/mimxrt595_evk_cm33/system_off/prj.conf @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -CONFIG_PM=y +CONFIG_POWEROFF=y # Enable the RTC CONFIG_COUNTER=y diff --git a/samples/boards/mimxrt595_evk_cm33/system_off/src/main.c b/samples/boards/mimxrt595_evk_cm33/system_off/src/main.c index 36a50595ec4..ad8f78b45a1 100644 --- a/samples/boards/mimxrt595_evk_cm33/system_off/src/main.c +++ b/samples/boards/mimxrt595_evk_cm33/system_off/src/main.c @@ -9,11 +9,8 @@ #include #include #include -#include -#include +#include -#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; }