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:
parent
c315c9b97c
commit
d52c88d4c3
|
@ -1,5 +1,3 @@
|
|||
CONFIG_GPIO=y
|
||||
|
||||
CONFIG_PM=y
|
||||
|
||||
CONFIG_PM_DEVICE=y
|
||||
CONFIG_POWEROFF=y
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue