-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename ConfigParamaBase to FlashParam
- Loading branch information
Showing
9 changed files
with
81 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*-----------------------------------------------------------/ | ||
/ ConfigParam.h | ||
/------------------------------------------------------------/ | ||
/ Copyright (c) 2024, Elehobica | ||
/ Released under the BSD-2-Clause | ||
/ refer to https://opensource.org/licenses/BSD-2-Clause | ||
/-----------------------------------------------------------*/ | ||
|
||
#include "ConfigParam.h" | ||
|
||
namespace FlashParamNs { | ||
//================================= | ||
// Implementation of ConfigParam class | ||
//================================= | ||
ConfigParam& ConfigParam::instance() // Singleton | ||
{ | ||
static ConfigParam instance; | ||
return instance; | ||
} | ||
|
||
uint32_t ConfigParam::getBootCountFromFlash() | ||
{ | ||
auto& param = P_CFG_BOOT_COUNT; | ||
ReadFromFlashVisitor visitor; | ||
visitor(¶m); | ||
return param.get(); | ||
} | ||
|
||
void ConfigParam::incBootCount() | ||
{ | ||
auto& param = P_CFG_BOOT_COUNT; | ||
param.set(param.get() + 1); | ||
} | ||
|
||
void ConfigParam::initialize() | ||
{ | ||
loadDefault(); | ||
// don't load from Flash if flash is blank | ||
if (getBootCountFromFlash() == 0xffffffffUL) { return; } | ||
// load from flash and get format revision | ||
uint32_t formatRevExpected = P_CFG_FORMAT_REV.get(); | ||
loadFromFlash(); | ||
uint32_t formatRev = P_CFG_FORMAT_REV.get(); | ||
// Force to reset to default due to format revision changed (parameter/address) to avoid mulfunction | ||
if (formatRevExpected != formatRev) { loadDefault(); } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters