From 560f0736989cae2b3ae11e30080228d35cca4af7 Mon Sep 17 00:00:00 2001 From: Doru Gucea Date: Thu, 28 Oct 2021 23:29:32 -0700 Subject: [PATCH 1/2] [K32W0][THREADIP-3663] Add Software Diagnosis Center Signed-off-by: Doru Gucea --- .../lighting-app/nxp/k32w/k32w0/main/main.cpp | 2 +- .../nxp/k32w/k32w0/PlatformManagerImpl.cpp | 30 +++++++++++++++++++ .../nxp/k32w/k32w0/PlatformManagerImpl.h | 3 ++ 3 files changed, 34 insertions(+), 1 deletion(-) 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..6546dd842f2a7c 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. From 85ada09141cd7493b5a21d4a13d46728eb6d83e4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 29 Oct 2021 14:10:18 +0000 Subject: [PATCH 2/2] Restyled by clang-format --- src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index 6546dd842f2a7c..cfcc6ad007e264 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -78,7 +78,7 @@ CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapFree(uint64_t & currentHeapFree) { size_t freeHeapSize; - freeHeapSize = xPortGetFreeHeapSize(); + freeHeapSize = xPortGetFreeHeapSize(); currentHeapFree = static_cast(freeHeapSize); return CHIP_NO_ERROR; } @@ -99,7 +99,7 @@ CHIP_ERROR PlatformManagerImpl::_GetCurrentHeapHighWatermark(uint64_t & currentH { size_t highWatermarkHeapSize; - highWatermarkHeapSize = HEAP_SIZE - xPortGetMinimumEverFreeHeapSize(); + highWatermarkHeapSize = HEAP_SIZE - xPortGetMinimumEverFreeHeapSize(); currentHeapHighWatermark = static_cast(highWatermarkHeapSize); return CHIP_NO_ERROR; }