Add more methods to access memory properties

This commit is contained in:
me-no-dev 2018-08-18 17:10:35 +02:00
parent 65511b23d3
commit 80c110ece7
2 changed files with 46 additions and 1 deletions

View File

@ -112,16 +112,50 @@ void EspClass::restart(void)
esp_restart(); 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) uint32_t EspClass::getFreeHeap(void)
{ {
return heap_caps_get_free_size(MALLOC_CAP_INTERNAL); 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) uint32_t EspClass::getFreePsram(void)
{ {
return heap_caps_get_free_size(MALLOC_CAP_SPIRAM); 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) uint8_t EspClass::getChipRevision(void)
{ {
esp_chip_info_t chip_info; esp_chip_info_t chip_info;

View File

@ -56,8 +56,19 @@ public:
EspClass() {} EspClass() {}
~EspClass() {} ~EspClass() {}
void restart(); 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 getFreePsram();
uint32_t getMinFreePsram();
uint32_t getMaxAllocPsram();
uint8_t getChipRevision(); uint8_t getChipRevision();
uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; } uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; }
uint32_t getCycleCount(); uint32_t getCycleCount();