esp8266: Let RTC work correctly after deepsleep.
By design, at wake up from deepsleep, the RTC timer will be reset, but
the data stored in RTC memory will not [1]. Therefore, we have to adjust
delta in RTC memory before going into deepsleep to get almost correct
time after waking up.
[1] http://bbs.espressif.com/viewtopic.php?t=1184#p4082
diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c
index 36872c9..80ae7ac 100644
--- a/esp8266/modmachine.c
+++ b/esp8266/modmachine.c
@@ -103,6 +103,8 @@
}
}
+ // prepare for RTC reset at wake up
+ rtc_prepare_deepsleep(sleep_us);
// put the device in a deep-sleep state
system_deep_sleep_set_option(0); // default power down mode; TODO check this
system_deep_sleep(sleep_us);