Reputation: 23
I work on project where I use FreeRTOS tasks and I would like to go into deep_sleep. Is there anything that I should do before going into the deep_sleep ? Or after wake up, RTOS scheduler works as nothing happen ?
Upvotes: 2
Views: 1702
Reputation: 395
There's no easy way to mix freeRTOS and deep_sleep mode. During deep sleep the CPU is powered down and its context is lost, yet the RTC memory can be retained. As all SRAM's content is lost, there's no easy backup-restore we can do here to safely restore everything after coming out from deep sleep.
But what you can do is to bring everything down to a safe state before entering deep-sleep, you can signal all your tasks to finish what they're doing and exit, and then take some advantage of ESP32's relatively low wake-up latency. It is a very unpleasant inconvenient for a Wi-Fi connected device, but more or less acceptable for BLE devices that will wake up and send a beacon once in a few seconds.
You would also want to fine-tune the second stage bootloader's configuration by enabling the CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP option so waking-up from deep-sleep would be faster than booting from a cold reset.
Upvotes: 1