mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
@ -158,6 +158,7 @@ volatile uint32_t* portModeRegister(uint32_t port);
|
|||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
|
|
||||||
#include "HardwareSerial.h"
|
#include "HardwareSerial.h"
|
||||||
|
#include "Esp.h"
|
||||||
|
|
||||||
uint16_t makeWord(uint16_t w);
|
uint16_t makeWord(uint16_t w);
|
||||||
uint16_t makeWord(byte h, byte l);
|
uint16_t makeWord(byte h, byte l);
|
||||||
|
57
hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
Normal file
57
hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
Normal 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);
|
||||||
|
}
|
46
hardware/esp8266com/esp8266/cores/esp8266/Esp.h
Normal file
46
hardware/esp8266com/esp8266/cores/esp8266/Esp.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Esp.h - 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ESP_H
|
||||||
|
#define ESP_H
|
||||||
|
|
||||||
|
|
||||||
|
enum WakeMode {
|
||||||
|
WAKE_RF_DEFAULT = 0, // RF_CAL or not after deep-sleep wake up, depends on init data byte 108.
|
||||||
|
WAKE_RFCAL = 1, // RF_CAL after deep-sleep wake up, there will be large current.
|
||||||
|
WAKE_NO_RFCAL = 2, // no RF_CAL after deep-sleep wake up, there will only be small current.
|
||||||
|
WAKE_RF_DISABLED = 4 // disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current.
|
||||||
|
};
|
||||||
|
|
||||||
|
class EspClass {
|
||||||
|
public:
|
||||||
|
EspClass();
|
||||||
|
|
||||||
|
void wdtEnable(int timeout_ms = 0);
|
||||||
|
// TODO: figure out how to set WDT timeout
|
||||||
|
void wdtDisable();
|
||||||
|
void wdtFeed();
|
||||||
|
|
||||||
|
void deepSleep(uint32_t time_us, WakeMode mode = WAKE_RF_DEFAULT);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern EspClass ESP;
|
||||||
|
|
||||||
|
#endif //ESP_H
|
Reference in New Issue
Block a user