Skip to content

Commit

Permalink
Implement Reset Heap HighWaterMark
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs committed Jun 2, 2022
1 parent 0bf3ba4 commit abbc37e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/platform/efr32/heap_4_silabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ size_t xPortGetMinimumEverFreeHeapSize(void)
{
return xMinimumEverFreeBytesRemaining;
}

void xPortResetHeapMinimumEverFreeHeapSize(void)
{
taskENTER_CRITICAL();
{
xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;
}
taskEXIT_CRITICAL();
}

/*-----------------------------------------------------------*/

void vPortInitialiseBlocks(void)
Expand Down
2 changes: 2 additions & 0 deletions examples/platform/efr32/heap_4_silabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ extern "C" {
void * pvPortCalloc(size_t num, size_t size);
void * pvPortRealloc(void * pv, size_t size);

void xPortResetHeapMinimumEverFreeHeapSize(void);

#ifdef __cplusplus
}
#endif
11 changes: 11 additions & 0 deletions src/platform/EFR32/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "AppConfig.h"
#include "FreeRTOS.h"
#include "heap_4_silabs.h"

using namespace ::chip::app::Clusters::GeneralDiagnostics;

Expand Down Expand Up @@ -81,6 +82,16 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu
return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks()
{
// If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the
// value of the CurrentHeapUsed.

xPortResetHeapMinimumEverFreeHeapSize();

return CHIP_NO_ERROR;
}

// General Diagnostics Getters

CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount)
Expand Down
1 change: 1 addition & 0 deletions src/platform/EFR32/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override;
CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override;
CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override;
CHIP_ERROR ResetWatermarks() override;
CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override;
CHIP_ERROR GetBootReason(BootReasonType & bootReason) override;
CHIP_ERROR GetUpTime(uint64_t & upTime) override;
Expand Down

0 comments on commit abbc37e

Please sign in to comment.