ESP32 - EN pin when in Deep Sleep State
When my board is in deep sleep state ( machine.deepsleep() ), when I press the EN button the machine.reset_cause() returns the machine.PWRON_RESET instead of the machine.DEEPSLEEP_RESET. Is this supposed to happen? How can I get the machine.DEEPSLEEP_RESET by pressing a button?
I tried the embedded EN button and connecting a physical button to the EN pin.
nrf/modules/machine: Implement deepsleep()
Replace the previous dummy implementation of machine.deepsleep() with one that invokes the nRF's deep sleep state System OFF. The argument is ignored, nRF microcontrollers are incapable of waking on a timer as all clocks are off in the deep sleep state.
Pins are configured as wake sources using an additional argument sense to the machine.Pin constructor. This choice is up for debate, it seemed appropriate because it internally is a matter of GPIO configuration. I also considered using the unused wake argument to Pin.irq(), but rejected that because the configuration has nothing to do with IRQs. Another possibility would be a special function in the nrf module, akin to esp32.wake_on_ext0().
machine.reset_cause() returns the newly added DEEPSLEEP_RESET, like on other ports – the previous mapping to PWRON_RESET seemed wrong.
I am unsure where to document this, as there is no port-specific documentation for the nrf port. Should I add a Quick reference for the nRF51/52 section just for this?
Tested on nRF52832 (DS-D6) and nRF52840 (ItsyBitsy).