8000 Add more methods to access memory properties · Bmooij/arduino-esp32@80c110e · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80c110e

Browse files
committed
Add more methods to access memory properties
1 parent 65511b2 commit 80c110e

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

cores/esp32/Esp.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,50 @@ void EspClass::restart(void)
112112
esp_restart();
113113
}
114114

115+
uint32_t EspClass::getHeapSize(void)
116+
{
117+
multi_heap_info_t info;
118+
heap_caps_get_info(&info, MALLOC_CAP_INTERNAL);
119+
return info.total_free_bytes + info.total_allocated_bytes;
120+
}
121+
115122
uint32_t EspClass::getFreeHeap(void)
116123
{
117124
return heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
118125
}
119126

127+
uint32_t EspClass::getMinFreeHeap(void)
128+
{
129+
return heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL);
130+
}
131+
132+
uint32_t EspClass::getMaxAllocHeap(void)
133+
{
134+
return heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
135+
}
136+
137+
uint32_t EspClass::getPsramSize(void)
138+
{
139+
multi_heap_info_t info;
140+
heap_caps_get_info(&info, MALLOC_CAP_SPIRAM);
141+
return info.total_free_bytes + info.total_allocated_bytes;
142+
}
143+
120144
uint32_t EspClass::getFreePsram(void)
121145
{
122146
return heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
123147
}
124148

149+
uint32_t EspClass::getMinFreePsram(void)
150+
{
151+
return heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM);
152+
}
153+
154+
uint32_t EspClass::getMaxAllocPsram(void)
155+
{
156+
return heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM);
157+
}
158+
125159
uint8_t EspClass::getChipRevision(void)
126160
{
127161
esp_chip_info_t chip_info;

cores/esp32/Esp.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,19 @@ class EspClass
5656
EspClass() {}
5757
~EspClass() {}
5858
void restart();
59-
uint32_t getFreeHeap();
59+
60+
//Internal RAM
61+
uint32_t getHeapSize(); //total heap size
62+
uint32_t getFreeHeap(); //available heap
63+
uint32_t getMinFreeHeap(); //lowest level of free heap since boot
64+
uint32_t getMaxAllocHeap(); //largest block of heap that can be allocated at once
65+
66+
//SPI RAM
67+
uint32_t getPsramSize();
6068
uint32_t getFreePsram();
69+
uint32_t getMinFreePsram();
70+
uint32_t getMaxAllocPsram();
71+
6172
uint8_t getChipRevision();
6273
uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; }
6374
uint32_t getCycleCount();

0 commit comments

Comments
 (0)
0