Zephyr Power Management PM_STATE_SOFT_OFF

I am having trouble figuring out how to put system in PM_STATE_SOFT_OFF from inside workqueue. If I put system to sleep inside workqueue it does't go to sleep, looks like execution continues. How should I approach this problem?

void power_down(void) {
    pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
    k_sleep(K_SECONDS(2U));
}

static void work_handler(struct k_work *work) {
    power_down();
}

void main(void) {
    k_work_init(&work, work_handler);
    k_work_submit(&work);
    while(1) {
		printk("Loop...\r\n");
	}
}

In current example the loop continues. If I replace k_work_submit with just direct power_down call then system goes to sleep and any execution stops.

Parents Reply Children
No Data
Related