Skip to content

Change argument to Esp.deepSleep from uint32 to uint64 to match SDK, … #4234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,22 @@ void EspClass::wdtFeed(void)

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(time_us);
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)
{
if (size + offset > 512) {
Expand Down
3 changes: 2 additions & 1 deletion cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class EspClass {
void wdtDisable();
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 rtcUserMemoryWrite(uint32_t offset, uint32_t *data, size_t size);
Expand Down