I have enabled the IDLE hook and using it to put the processor into a low power mode. How do I exit low power mode? It would seem I would need another hook that tells me when a non-IDLE task is scheduled… I am also using tickles mode.
I can see that the scheduler is turned off (SUSPEND) and there is a call to RESUME when FreeRTOS exits sleep mode (see portTASK_FUNCTION()). One solution could be to trigger a special (highest priority) task that restores the CPU (exit low power) before any of the other tasks run, which I guess could be done with a semaphore to a high priority task, and GIVE the semaphore when xTaskResumeAll() is called. However I don’t want to touch FreeRTOS functions, so I don’t think this is the right approach.
I tried putting my exit_low_power code in vPortSuppressTicksAndSleep() but the target crashes hard… I suspect because my exit_low_power uses FreeRTOS APIs, and vPortSuppressTicksAndSleep() is probably running in special (interrupt?) context where I can’t call those APIs. Because I am using tickles mode, my openOCD GDB connection won’t work to debug it further.