summaryrefslogtreecommitdiff
path: root/esp8266/modpybrtc.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-04-21 11:43:37 +0100
committerDamien George <damien.p.george@gmail.com>2016-04-21 11:43:37 +0100
commit32d7cf6e441660caed00620309d1faa4b7df5dd4 (patch)
treebd6e160d08d0882fef538faf3a1ea134765670f5 /esp8266/modpybrtc.h
parent2a51f72ed18c075742655257c13f78225746d9bb (diff)
esp8266: Implement basic deep-sleep capabilities.
Use the machine.deepsleep() function to enter the sleep mode. Use the RTC to configure the alarm to wake the device. Basic use is the following: import machine # configure RTC's ALARM0 to wake device from deep sleep rtc = machine.RTC() rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP) # do other things # ... # set ALARM0's alarm to wake after 10 seconds rtc.alarm(rtc.ALARM0, 10000) # enter deep-sleep state (system is reset upon waking) machine.deepsleep() To detect if the system woke from a deep sleep use: if machine.reset_cause() == machine.DEEPSLEEP_RESET: print('woke from deep sleep')
Diffstat (limited to 'esp8266/modpybrtc.h')
-rw-r--r--esp8266/modpybrtc.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/esp8266/modpybrtc.h b/esp8266/modpybrtc.h
index 2a982d38f..b4ca78071 100644
--- a/esp8266/modpybrtc.h
+++ b/esp8266/modpybrtc.h
@@ -24,6 +24,9 @@
* THE SOFTWARE.
*/
+extern uint32_t pyb_rtc_alarm0_wake;
+extern uint64_t pyb_rtc_alarm0_expiry;
+
void pyb_rtc_set_us_since_2000(uint64_t nowus);
uint64_t pyb_rtc_get_us_since_2000();