1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-21 21:22:31 +03:00

Change argument to Esp.deepSleep from uint32 to uint64 to match SDK, add deepSleepMax based on the cali_proc function per SDK

This commit is contained in:
devyte
2018-01-24 17:14:57 -03:00
committed by Ivan Grokhotkov
parent 8b87491700
commit 8da1d78cb4
2 changed files with 12 additions and 2 deletions

View File

@ -107,13 +107,22 @@ void EspClass::wdtFeed(void)
extern "C" void esp_yield(); extern "C" void esp_yield();
void EspClass::deepSleep(uint32_t time_us, WakeMode mode) void EspClass::deepSleep(uint64_t time_us, WakeMode mode)
{ {
system_deep_sleep_set_option(static_cast<int>(mode)); system_deep_sleep_set_option(static_cast<int>(mode));
system_deep_sleep(time_us); system_deep_sleep(time_us);
esp_yield(); esp_yield();
} }
//this calculation was taken verbatim from the SDK api reference for SDK 2.1.0.
//Note: system_rtc_clock_cali_proc() returns a uint32_t, even though system_deep_sleep() takes a uint64_t.
uint64_t EspClass::deepSleepMax()
{
//cali*(2^31-1)/(2^12)
return (uint64_t)system_rtc_clock_cali_proc()*(0x80000000-1)/(0x1000);
}
bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size) bool EspClass::rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size)
{ {
if (size + offset > 512) { if (size + offset > 512) {

View File

@ -92,7 +92,8 @@ class EspClass {
void wdtDisable(); void wdtDisable();
void wdtFeed(); void wdtFeed();
void deepSleep(uint32_t time_us, RFMode mode = RF_DEFAULT); void deepSleep(uint64_t time_us, RFMode mode = RF_DEFAULT);
uint64_t deepSleepMax();
bool rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size); bool rtcUserMemoryRead(uint32_t offset, uint32_t *data, size_t size);
bool rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size); bool rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);