2023-07-26 23:48:04 +00:00
|
|
|
/**
|
|
|
|
* @file memGet.cpp
|
|
|
|
* @brief Implementation of MemGet class that provides functions to get memory information.
|
|
|
|
*
|
|
|
|
* This file contains the implementation of MemGet class that provides functions to get
|
|
|
|
* information about free heap, heap size, free psram and psram size. The functions are
|
|
|
|
* implemented for ESP32 and NRF52 architectures. If the platform does not have heap
|
|
|
|
* management function implemented, the functions return UINT32_MAX or 0.
|
|
|
|
*/
|
2023-02-17 11:31:51 +00:00
|
|
|
#include "memGet.h"
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
|
|
MemGet memGet;
|
|
|
|
|
2023-07-26 23:48:04 +00:00
|
|
|
/**
|
|
|
|
* Returns the amount of free heap memory in bytes.
|
|
|
|
* @return uint32_t The amount of free heap memory in bytes.
|
|
|
|
*/
|
2023-02-17 11:31:51 +00:00
|
|
|
uint32_t MemGet::getFreeHeap()
|
|
|
|
{
|
|
|
|
#ifdef ARCH_ESP32
|
|
|
|
return ESP.getFreeHeap();
|
|
|
|
#elif defined(ARCH_NRF52)
|
|
|
|
return dbgHeapFree();
|
|
|
|
#else
|
|
|
|
// this platform does not have heap management function implemented
|
|
|
|
return UINT32_MAX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-07-26 23:48:04 +00:00
|
|
|
/**
|
|
|
|
* Returns the size of the heap memory in bytes.
|
|
|
|
* @return uint32_t The size of the heap memory in bytes.
|
|
|
|
*/
|
2023-02-17 11:31:51 +00:00
|
|
|
uint32_t MemGet::getHeapSize()
|
|
|
|
{
|
|
|
|
#ifdef ARCH_ESP32
|
|
|
|
return ESP.getHeapSize();
|
|
|
|
#elif defined(ARCH_NRF52)
|
|
|
|
return dbgHeapTotal();
|
|
|
|
#else
|
|
|
|
// this platform does not have heap management function implemented
|
|
|
|
return UINT32_MAX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-07-26 23:48:04 +00:00
|
|
|
/**
|
|
|
|
* Returns the amount of free psram memory in bytes.
|
|
|
|
*
|
|
|
|
* @return The amount of free psram memory in bytes.
|
|
|
|
*/
|
2023-02-17 11:31:51 +00:00
|
|
|
uint32_t MemGet::getFreePsram()
|
|
|
|
{
|
|
|
|
#ifdef ARCH_ESP32
|
|
|
|
return ESP.getFreePsram();
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-07-26 23:48:04 +00:00
|
|
|
/**
|
|
|
|
* @brief Returns the size of the PSRAM memory.
|
|
|
|
*
|
|
|
|
* @return uint32_t The size of the PSRAM memory.
|
|
|
|
*/
|
2023-02-17 11:31:51 +00:00
|
|
|
uint32_t MemGet::getPsramSize()
|
|
|
|
{
|
|
|
|
#ifdef ARCH_ESP32
|
|
|
|
return ESP.getPsramSize();
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|