Hello everyone,
I am having trouble understanding how to enter power saving modes. I understand that once there are no tasks to run, the scheduler selects idle task which puts the mcu into system on power saving mode. However, it is not exactly clear to me how to enter this mode at command and stay in it for as long as i request. Take this completely unhinged pseudocode for example where I have two tasks running and a callback:
task1()
{
// some code to read sensor data
k_msleep(100);
}
task2()
{
// do some calculations, transmit data somewhere
k_msleep(50);
}
some_gpio_callback_function()
{
// register interrupt, command enter to sleep mode
}
How am I supposed to enter any of the low power modes and stay in them until, say, another gpio input callback is received? Perhaps, when gpio interrupt fires, I should create a new task which would just idle forever - until another interrupt from gpio comes in, after which i would just kill the newly created idling task? Or is the a better way to do it since we already have an idle task spawned automatically by zephyr?
I hope you understand my problem, please assist.