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

Add watchdog and deep sleep APIs

requested in #34
This commit is contained in:
Ivan Grokhotkov
2015-04-11 10:58:57 +08:00
parent 91d5fe73c0
commit 5c94d333c5
3 changed files with 104 additions and 0 deletions

57
cores/esp8266/Esp.cpp Normal file
View File

@ -0,0 +1,57 @@
/*
Esp.cpp - ESP8266-specific APIs
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
This file is part of the esp8266 core for Arduino environment.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "Arduino.h"
extern "C" {
#include "user_interface.h"
}
extern "C" void ets_wdt_enable (void);
extern "C" void ets_wdt_disable (void);
extern "C" void wdt_feed (void);
EspClass ESP;
EspClass::EspClass()
{
}
void EspClass::wdtEnable(int)
{
ets_wdt_enable();
}
void EspClass::wdtDisable()
{
ets_wdt_disable();
}
void EspClass::wdtFeed()
{
wdt_feed();
}
void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
{
system_deep_sleep_set_option(static_cast<int>(mode));
system_deep_sleep(time_us);
}