forked from espressif/arduino-esp32
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEsp.h
120 lines (97 loc) · 3.36 KB
/
Esp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
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
#defineESP_H
#include<Arduino.h>
#include<esp_partition.h>
#include<hal/cpu_hal.h>
#include"esp_cpu.h"
/**
* AVR macros for WDT management
*/
typedefenum {
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;
typedefenum {
FM_QIO = 0x00,
FM_QOUT = 0x01,
FM_DIO = 0x02,
FM_DOUT = 0x03,
FM_FAST_READ = 0x04,
FM_SLOW_READ = 0x05,
FM_UNKNOWN = 0xff
} FlashMode_t;
typedefenum {
SKETCH_SIZE_TOTAL = 0,
SKETCH_SIZE_FREE = 1
} sketchSize_t;
classEspClass {
public:
EspClass() {}
~EspClass() {}
voidrestart();
//Internal RAM
uint32_tgetHeapSize(); //total heap size
uint32_tgetFreeHeap(); //available heap
uint32_tgetMinFreeHeap(); //lowest level of free heap since boot
uint32_tgetMaxAllocHeap(); //largest block of heap that can be allocated at once
//SPI RAM
uint32_tgetPsramSize();
uint32_tgetFreePsram();
uint32_tgetMinFreePsram();
uint32_tgetMaxAllocPsram();
uint16_tgetChipRevision();
constchar *getChipModel();
uint8_tgetChipCores();
uint32_tgetCpuFreqMHz() {
returngetCpuFrequencyMhz();
}
inlineuint32_tgetCycleCount() __attribute__((always_inline));
constchar *getSdkVersion(); //version of ESP-IDF
constchar *getCoreVersion(); //version of this core
voiddeepSleep(uint64_t time_us);
uint32_tgetFlashChipSize();
uint32_tgetFlashChipSpeed();
FlashMode_t getFlashChipMode();
uint32_tmagicFlashChipSize(uint8_t byte);
uint32_tmagicFlashChipSpeed(uint8_t byte);
FlashMode_t magicFlashChipMode(uint8_t byte);
uint32_tgetSketchSize();
String getSketchMD5();
uint32_tgetFreeSketchSpace();
boolflashEraseSector(uint32_t sector);
boolflashWrite(uint32_t offset, uint32_t *data, size_t size);
boolflashRead(uint32_t offset, uint32_t *data, size_t size);
boolpartitionEraseRange(constesp_partition_t *partition, uint32_t offset, size_t size);
boolpartitionWrite(constesp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size);
boolpartitionRead(constesp_partition_t *partition, uint32_t offset, uint32_t *data, size_t size);
uint64_tgetEfuseMac();
};
uint32_t ARDUINO_ISR_ATTR EspClass::getCycleCount() {
return (uint32_t)esp_cpu_get_cycle_count();
}
extern EspClass ESP;
#endif//ESP_H