samples: boards: ti: cc13x2_cc26x2: system_off: use sys_poweroff()

Use the new sys_poweroff API to power off the board.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2023-08-08 12:06:35 +02:00 committed by Carles Cufí
parent c315c9b97c
commit d52c88d4c3
2 changed files with 4 additions and 19 deletions

View file

@ -1,5 +1,3 @@
CONFIG_GPIO=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_POWEROFF=y

View file

@ -10,7 +10,7 @@
#include <zephyr/init.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/pm/pm.h>
#include <zephyr/sys/poweroff.h>
#include <driverlib/ioc.h>
@ -53,26 +53,13 @@ int main(void)
printk("Sleep %u s (STANDBY)\n", SLEEP_S);
k_sleep(K_SECONDS(SLEEP_S));
printk("Entering system off (SHUTDOWN); press BUTTON1 to restart\n");
printk("Powering off; press BUTTON1 to restart\n");
/* Clear GPIO interrupt */
status = GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK);
GPIO_clearEventMultiDio(status);
/*
* Force the SOFT_OFF state.
*/
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. To confirm that the
* forced state is used, lets set the same timeout used previously.
*/
k_sleep(K_SECONDS(SLEEP_S));
printk("ERROR: System off failed\n");
while (true) {
/* spin to avoid fall-off behavior */
}
return 0;
}