Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of RTCMEM storage #1420

Merged
merged 13 commits into from
May 8, 2019
Prev Previous commit
Next Next commit
fixup! Fix naming
  • Loading branch information
mcspr committed Mar 17, 2019
commit a3f2239a0bd725b27d8b7aeaa6dba9ef601977d1
6 changes: 6 additions & 0 deletions code/espurna/config/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ extern "C" {
extern struct rst_info resetInfo;
}

// -----------------------------------------------------------------------------
// System
// -----------------------------------------------------------------------------

uint32_t systemResetReason();
uint8_t systemStabilityCounter();
void systemStabilityCounter(uint8_t);

// -----------------------------------------------------------------------------
// API
Expand Down
10 changes: 5 additions & 5 deletions code/espurna/system.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ union system_rtcmem_t {
uint32_t value;
};

uint8_t _systemStabilityCounter() {
uint8_t systemStabilityCounter() {
system_rtcmem_t data;
data.value = Rtcmem->sys;
return data.parts.stability_counter;
}

void _systemStabilityCounter(uint8_t counter) {
void systemStabilityCounter(uint8_t counter) {
system_rtcmem_t data;
data.value = Rtcmem->sys;
data.parts.stability_counter = counter;
Expand Down Expand Up @@ -76,11 +76,11 @@ void systemCheck(bool stable) {
DEBUG_MSG_P(PSTR("[MAIN] System OK\n"));
} else {
if (!rtcmemStatus()) {
_systemStabilityCounter(1);
systemStabilityCounter(1);
return;
}

value = _systemStabilityCounter();
value = systemStabilityCounter();

if (++value > SYSTEM_CHECK_MAX) {
_systemStable = false;
Expand All @@ -89,7 +89,7 @@ void systemCheck(bool stable) {
}
}

_systemStabilityCounter(value);
systemStabilityCounter(value);
}

bool systemCheck() {
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/terminal.ino
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void _terminalInitCommand() {
});

terminalRegisterCommand(F("RESET.SAFE"), [](Embedis* e) {
_rtcmemStabilityCounter(SYSTEM_CHECK_MAX);
systemStabilityCounter(SYSTEM_CHECK_MAX);
terminalOK();
deferredReset(100, CUSTOM_RESET_TERMINAL);
});
Expand Down