mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-13 13:01:55 +03:00
Merge remote-tracking branch 'remotes/esp8266/esp8266' into esp8266
Conflicts: hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp
This commit is contained in:
@ -32,13 +32,7 @@ extern struct rst_info resetInfo;
|
||||
|
||||
// #define DEBUG_SERIAL Serial
|
||||
|
||||
//extern "C" void ets_wdt_init(uint32_t val);
|
||||
extern "C" void ets_wdt_enable(void);
|
||||
extern "C" void ets_wdt_disable(void);
|
||||
extern "C" void wdt_feed(void) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* User-defined Literals
|
||||
* usage:
|
||||
@ -85,30 +79,20 @@ unsigned long long operator"" _GB(unsigned long long x) {
|
||||
|
||||
EspClass ESP;
|
||||
|
||||
EspClass::EspClass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EspClass::wdtEnable(uint32_t timeout_ms)
|
||||
{
|
||||
//todo find doku for ets_wdt_init may set the timeout
|
||||
ets_wdt_enable();
|
||||
}
|
||||
|
||||
void EspClass::wdtEnable(WDTO_t timeout_ms)
|
||||
{
|
||||
wdtEnable((uint32_t) timeout_ms);
|
||||
}
|
||||
|
||||
void EspClass::wdtDisable(void)
|
||||
{
|
||||
ets_wdt_disable();
|
||||
}
|
||||
|
||||
void EspClass::wdtFeed(void)
|
||||
{
|
||||
wdt_feed();
|
||||
}
|
||||
|
||||
void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
|
||||
@ -117,18 +101,20 @@ void EspClass::deepSleep(uint32_t time_us, WakeMode mode)
|
||||
system_deep_sleep(time_us);
|
||||
}
|
||||
|
||||
extern "C" void esp_yield();
|
||||
extern "C" void __real_system_restart_local();
|
||||
void EspClass::reset(void)
|
||||
{
|
||||
((void (*)(void))0x40000080)();
|
||||
__real_system_restart_local();
|
||||
}
|
||||
|
||||
void EspClass::restart(void)
|
||||
{
|
||||
system_restart();
|
||||
delay(5000);
|
||||
system_restart();
|
||||
delay(20000);
|
||||
reset(); // if we still have not reset force it!
|
||||
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)
|
||||
|
@ -61,6 +61,15 @@ enum RFMode {
|
||||
#define WAKE_NO_RFCAL RF_NO_CAL
|
||||
#define WAKE_RF_DISABLED RF_DISABLED
|
||||
|
||||
enum ADCMode {
|
||||
ADC_TOUT = 33,
|
||||
ADC_TOUT_3V3 = 33,
|
||||
ADC_VCC = 255,
|
||||
ADC_VDD = 255
|
||||
};
|
||||
|
||||
#define ADC_MODE(mode) extern "C" int __get_adc_mode() { return (int) (mode); }
|
||||
|
||||
typedef enum {
|
||||
FM_QIO = 0x00,
|
||||
FM_QOUT = 0x01,
|
||||
@ -71,8 +80,6 @@ typedef enum {
|
||||
|
||||
class EspClass {
|
||||
public:
|
||||
EspClass();
|
||||
|
||||
// TODO: figure out how to set WDT timeout
|
||||
void wdtEnable(uint32_t timeout_ms = 0);
|
||||
// note: setting the timeout value is not implemented at the moment
|
||||
|
@ -224,6 +224,7 @@ static uint8_t phy_init_data[128] =
|
||||
|
||||
extern int __real_register_chipv6_phy(uint8_t* init_data);
|
||||
extern int __wrap_register_chipv6_phy(uint8_t* unused) {
|
||||
phy_init_data[107] = __get_adc_mode();
|
||||
return __real_register_chipv6_phy(phy_init_data);
|
||||
}
|
||||
|
||||
@ -243,6 +244,10 @@ extern int __get_rf_mode()
|
||||
return 0; // default mode
|
||||
}
|
||||
|
||||
|
||||
extern int __get_adc_mode() __attribute__((weak));
|
||||
extern int __get_adc_mode()
|
||||
{
|
||||
return 33; // default ADC mode
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,17 +17,18 @@
|
||||
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
|
||||
|
||||
|
||||
18/06/2015 analogRead bugfix by Testato
|
||||
*/
|
||||
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
extern uint16_t readvdd33(void);
|
||||
|
||||
void analogReference(uint8_t mode) {}
|
||||
|
||||
extern int __analogRead(uint8_t pin) {
|
||||
if(pin == 17){
|
||||
return readvdd33() >> 2; // readvdd33 is 12 bit
|
||||
return system_adc_read();
|
||||
}
|
||||
return digitalRead(pin) * 1023;
|
||||
}
|
||||
|
Reference in New Issue
Block a user