mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Return to scheduler context from ESP::deepSleep (#609)
This commit is contained in:
parent
e02932fcdd
commit
cc152de907
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Esp.cpp - ESP8266-specific APIs
|
Esp.cpp - ESP8266-specific APIs
|
||||||
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
@ -32,7 +32,7 @@ extern struct rst_info resetInfo;
|
|||||||
|
|
||||||
//#define DEBUG_SERIAL Serial
|
//#define DEBUG_SERIAL Serial
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User-defined Literals
|
* User-defined Literals
|
||||||
* usage:
|
* usage:
|
||||||
@ -92,7 +92,7 @@ void EspClass::wdtEnable(WDTO_t timeout_ms)
|
|||||||
|
|
||||||
void EspClass::wdtDisable(void)
|
void EspClass::wdtDisable(void)
|
||||||
{
|
{
|
||||||
/// Please don’t stop software watchdog too long (less than 6 seconds),
|
/// Please don't stop software watchdog too long (less than 6 seconds),
|
||||||
/// otherwise it will trigger hardware watchdog reset.
|
/// otherwise it will trigger hardware watchdog reset.
|
||||||
system_soft_wdt_stop();
|
system_soft_wdt_stop();
|
||||||
}
|
}
|
||||||
@ -102,13 +102,15 @@ void EspClass::wdtFeed(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void esp_yield();
|
||||||
|
|
||||||
void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
|
void EspClass::deepSleep(uint32_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();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void esp_yield();
|
|
||||||
extern "C" void __real_system_restart_local();
|
extern "C" void __real_system_restart_local();
|
||||||
void EspClass::reset(void)
|
void EspClass::reset(void)
|
||||||
{
|
{
|
||||||
@ -119,9 +121,6 @@ void EspClass::restart(void)
|
|||||||
{
|
{
|
||||||
system_restart();
|
system_restart();
|
||||||
esp_yield();
|
esp_yield();
|
||||||
// todo: provide an alternative code path if this was called
|
|
||||||
// from system context, not from continuation
|
|
||||||
// (implement esp_is_cont_ctx()?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t EspClass::getVcc(void)
|
uint16_t EspClass::getVcc(void)
|
||||||
@ -333,7 +332,7 @@ uint32_t EspClass::getSketchSize() {
|
|||||||
DEBUG_SERIAL.printf("num_segments=%u\r\n", image_header.num_segments);
|
DEBUG_SERIAL.printf("num_segments=%u\r\n", image_header.num_segments);
|
||||||
#endif
|
#endif
|
||||||
for (uint32_t section_index = 0;
|
for (uint32_t section_index = 0;
|
||||||
section_index < image_header.num_segments;
|
section_index < image_header.num_segments;
|
||||||
++section_index)
|
++section_index)
|
||||||
{
|
{
|
||||||
section_header_t section_header = {0};
|
section_header_t section_header = {0};
|
||||||
@ -395,8 +394,7 @@ bool EspClass::updateSketch(Stream& in, uint32_t size, bool restartOnFail, bool
|
|||||||
|
|
||||||
#ifdef DEBUG_SERIAL
|
#ifdef DEBUG_SERIAL
|
||||||
DEBUG_SERIAL.println("Update SUCCESS");
|
DEBUG_SERIAL.println("Update SUCCESS");
|
||||||
#endif
|
#endif
|
||||||
if(restartOnSuccess) ESP.restart();
|
if(restartOnSuccess) ESP.restart();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,9 @@ extern "C" void abort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void esp_yield() {
|
extern "C" void esp_yield() {
|
||||||
cont_yield(&g_cont);
|
if (cont_can_yield(&g_cont)) {
|
||||||
|
cont_yield(&g_cont);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void esp_schedule() {
|
extern "C" void esp_schedule() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user