2016-10-06 13:21:30 +02:00
|
|
|
/*
|
|
|
|
Esp.h - ESP31B-specific APIs
|
|
|
|
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AVR macros for WDT managment
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
WDTO_0MS = 0, //!< WDTO_0MS
|
|
|
|
WDTO_15MS = 15, //!< WDTO_15MS
|
|
|
|
WDTO_30MS = 30, //!< WDTO_30MS
|
|
|
|
WDTO_60MS = 60, //!< WDTO_60MS
|
|
|
|
WDTO_120MS = 120, //!< WDTO_120MS
|
|
|
|
WDTO_250MS = 250, //!< WDTO_250MS
|
|
|
|
WDTO_500MS = 500, //!< WDTO_500MS
|
|
|
|
WDTO_1S = 1000,//!< WDTO_1S
|
|
|
|
WDTO_2S = 2000,//!< WDTO_2S
|
|
|
|
WDTO_4S = 4000,//!< WDTO_4S
|
|
|
|
WDTO_8S = 8000 //!< WDTO_8S
|
|
|
|
} WDTO_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FM_QIO = 0x00,
|
|
|
|
FM_QOUT = 0x01,
|
|
|
|
FM_DIO = 0x02,
|
|
|
|
FM_DOUT = 0x03,
|
2017-02-23 01:23:27 +01:00
|
|
|
FM_FAST_READ = 0x04,
|
|
|
|
FM_SLOW_READ = 0x05,
|
2016-10-06 13:21:30 +02:00
|
|
|
FM_UNKNOWN = 0xff
|
|
|
|
} FlashMode_t;
|
|
|
|
|
2018-11-19 17:03:36 +01:00
|
|
|
typedef enum {
|
|
|
|
SKETCH_SIZE_TOTAL = 0,
|
|
|
|
SKETCH_SIZE_FREE = 1
|
|
|
|
} sketchSize_t;
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
class EspClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EspClass() {}
|
|
|
|
~EspClass() {}
|
|
|
|
void restart();
|
2018-08-18 17:10:35 +02:00
|
|
|
|
|
|
|
//Internal RAM
|
|
|
|
uint32_t getHeapSize(); //total heap size
|
|
|
|
uint32_t getFreeHeap(); //available heap
|
|
|
|
uint32_t getMinFreeHeap(); //lowest level of free heap since boot
|
|
|
|
uint32_t getMaxAllocHeap(); //largest block of heap that can be allocated at once
|
|
|
|
|
|
|
|
//SPI RAM
|
|
|
|
uint32_t getPsramSize();
|
2018-08-18 16:34:41 +02:00
|
|
|
uint32_t getFreePsram();
|
2018-08-18 17:10:35 +02:00
|
|
|
uint32_t getMinFreePsram();
|
|
|
|
uint32_t getMaxAllocPsram();
|
|
|
|
|
2017-02-23 01:23:27 +01:00
|
|
|
uint8_t getChipRevision();
|
2019-08-20 15:48:26 +02:00
|
|
|
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
|
2019-09-11 13:29:53 +02:00
|
|
|
inline uint32_t getCycleCount() __attribute__((always_inline));
|
2016-10-06 13:21:30 +02:00
|
|
|
const char * getSdkVersion();
|
|
|
|
|
2017-02-08 19:32:49 +01:00
|
|
|
void deepSleep(uint32_t time_us);
|
2016-10-06 13:21:30 +02:00
|
|
|
|
|
|
|
uint32_t getFlashChipSize();
|
|
|
|
uint32_t getFlashChipSpeed();
|
|
|
|
FlashMode_t getFlashChipMode();
|
|
|
|
|
|
|
|
uint32_t magicFlashChipSize(uint8_t byte);
|
|
|
|
uint32_t magicFlashChipSpeed(uint8_t byte);
|
|
|
|
FlashMode_t magicFlashChipMode(uint8_t byte);
|
|
|
|
|
2018-11-19 17:03:36 +01:00
|
|
|
uint32_t getSketchSize();
|
2018-12-11 02:06:58 +01:00
|
|
|
String getSketchMD5();
|
2018-11-19 17:03:36 +01:00
|
|
|
uint32_t getFreeSketchSpace();
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
bool flashEraseSector(uint32_t sector);
|
|
|
|
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
|
|
|
|
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
|
|
|
|
|
2017-05-05 08:59:54 +02:00
|
|
|
uint64_t getEfuseMac();
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
};
|
|
|
|
|
2019-09-11 13:29:53 +02:00
|
|
|
uint32_t IRAM_ATTR EspClass::getCycleCount()
|
|
|
|
{
|
|
|
|
uint32_t ccount;
|
|
|
|
__asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
|
|
|
|
return ccount;
|
|
|
|
}
|
|
|
|
|
2016-10-06 13:21:30 +02:00
|
|
|
extern EspClass ESP;
|
|
|
|
|
|
|
|
#endif //ESP_H
|