Commit 80c110ec authored by me-no-dev's avatar me-no-dev

Add more methods to access memory properties

parent 65511b23
......@@ -112,16 +112,50 @@ void EspClass::restart(void)
esp_restart();
}
uint32_t EspClass::getHeapSize(void)
{
multi_heap_info_t info;
heap_caps_get_info(&info, MALLOC_CAP_INTERNAL);
return info.total_free_bytes + info.total_allocated_bytes;
}
uint32_t EspClass::getFreeHeap(void)
{
return heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
}
uint32_t EspClass::getMinFreeHeap(void)
{
return heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL);
}
uint32_t EspClass::getMaxAllocHeap(void)
{
return heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
}
uint32_t EspClass::getPsramSize(void)
{
multi_heap_info_t info;
heap_caps_get_info(&info, MALLOC_CAP_SPIRAM);
return info.total_free_bytes + info.total_allocated_bytes;
}
uint32_t EspClass::getFreePsram(void)
{
return heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
}
uint32_t EspClass::getMinFreePsram(void)
{
return heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM);
}
uint32_t EspClass::getMaxAllocPsram(void)
{
return heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM);
}
uint8_t EspClass::getChipRevision(void)
{
esp_chip_info_t chip_info;
......
......@@ -56,8 +56,19 @@ public:
EspClass() {}
~EspClass() {}
void restart();
uint32_t getFreeHeap();
//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();
uint32_t getFreePsram();
uint32_t getMinFreePsram();
uint32_t getMaxAllocPsram();
uint8_t getChipRevision();
uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; }
uint32_t getCycleCount();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment