diff --git a/Components/NVS_Lib/Inc/NVS.hpp b/Components/NVS_Lib/Inc/NVS.hpp index 067fc23..711ebd2 100644 --- a/Components/NVS_Lib/Inc/NVS.hpp +++ b/Components/NVS_Lib/Inc/NVS.hpp @@ -77,6 +77,8 @@ class NVS uint32_t GetAvaliableSpaceInBlocks(void); + void Clear(void); + private: uint32_t GetPageFreeSpace(void); diff --git a/Components/NVS_Lib/Src/NVS.cpp b/Components/NVS_Lib/Src/NVS.cpp index 2e87610..d71ad7c 100644 --- a/Components/NVS_Lib/Src/NVS.cpp +++ b/Components/NVS_Lib/Src/NVS.cpp @@ -97,6 +97,8 @@ void NVS::Init(FlashDesc_t *flash_desc, uint32_t len) { int32_t LastNumTemp = -1; + + WriteNumber = 0; if (flash_desc) { @@ -405,4 +407,16 @@ uint32_t NVS::GetAvaliableSpaceInBytes(void) uint32_t NVS::GetAvaliableSpaceInBlocks(void) { return GetAvaliableSpaceInBytes() / NVS_Cell::MEMORY_CELL_SIZE; +} + + + +void NVS::Clear(void) +{ + for (uint32_t i = 0; i < FlashDescriptorsSize; i++) + { + FlashInterface.PageErase(FlashDescriptors[i].MemPtr, FlashDescriptors[i].Sector, FlashDescriptors[i].Size); + } + + Init(FlashDescriptors, FlashDescriptorsSize); } \ No newline at end of file diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index 88606d7..8b50a0a 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -190,6 +190,8 @@ int main(void) Check(CheckStorage); printf("\r\n\r\n"); + // CheckStorage.Clear(); + // Check(CheckStorage); printf("End"); return 0; }