diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp index 404697b8ea3acc..b13e414c671198 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp @@ -51,7 +51,7 @@ extern InitFunc __init_array_start; extern InitFunc __init_array_end; /* needed for FreeRtos Heap 4 */ -uint8_t __attribute__((section(".heap"))) ucHeap[0xF000]; +uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; extern "C" void main_task(void const * argument) { diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index 34981331f7f4fa..cfcc6ad007e264 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -74,5 +74,35 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) return err; } +CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapFree(uint64_t & currentHeapFree) +{ + size_t freeHeapSize; + + freeHeapSize = xPortGetFreeHeapSize(); + currentHeapFree = static_cast(freeHeapSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapUsed(uint64_t & currentHeapUsed) +{ + size_t freeHeapSize; + size_t usedHeapSize; + + freeHeapSize = xPortGetFreeHeapSize(); + usedHeapSize = HEAP_SIZE - freeHeapSize; + + currentHeapUsed = static_cast(usedHeapSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) +{ + size_t highWatermarkHeapSize; + + highWatermarkHeapSize = HEAP_SIZE - xPortGetMinimumEverFreeHeapSize(); + currentHeapHighWatermark = static_cast(highWatermarkHeapSize); + return CHIP_NO_ERROR; +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h index 4e0e355b75bdc2..29c17d6f9cdbcc 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.h @@ -54,6 +54,9 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener // ===== Methods that implement the PlatformManager abstract interface. CHIP_ERROR _InitChipStack(void); + CHIP_ERROR _GetCurrentHeapFree(uint64_t & currentHeapFree); + CHIP_ERROR _GetCurrentHeapUsed(uint64_t & currentHeapUsed); + CHIP_ERROR _GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark); // ===== Members for internal use by the following friends.