Fix reset reason (it returns the actual reset reason instead of hard coded 'hard reset' value).

This commit is contained in:
JF 2020-06-07 20:31:13 +02:00
parent 421af9625b
commit 9115c49bba

View File

@ -32,17 +32,17 @@ void Watchdog::Kick() {
}
Watchdog::ResetReasons Watchdog::ActualResetReason() const {
uint32_t resetReason;
// sd_power_reset_reason_get(&resetReason);
// sd_power_reset_reason_clr(0xFFFFFFFF);
// if(resetReason & 0x01u) return ResetReasons::ResetPin;
// if((resetReason >> 1u) & 0x01u) return ResetReasons::Watchdog;
// if((resetReason >> 2u) & 0x01u) return ResetReasons::SoftReset;
// if((resetReason >> 3u) & 0x01u) return ResetReasons::CpuLockup;
// if((resetReason >> 16u) & 0x01u) return ResetReasons::SystemOff;
// if((resetReason >> 17u) & 0x01u) return ResetReasons::LpComp;
// if((resetReason >> 18u) & 0x01u) return ResetReasons::DebugInterface;
// if((resetReason >> 19u) & 0x01u) return ResetReasons::NFC;
uint32_t reason = NRF_POWER->RESETREAS;
NRF_POWER->RESETREAS = 0xffffffff;
if(reason & 0x01u) return ResetReasons::ResetPin;
if((reason >> 1u) & 0x01u) return ResetReasons::Watchdog;
if((reason >> 2u) & 0x01u) return ResetReasons::SoftReset;
if((reason >> 3u) & 0x01u) return ResetReasons::CpuLockup;
if((reason >> 16u) & 0x01u) return ResetReasons::SystemOff;
if((reason >> 17u) & 0x01u) return ResetReasons::LpComp;
if((reason) & 0x01u) return ResetReasons::DebugInterface;
if((reason >> 19u) & 0x01u) return ResetReasons::NFC;
return ResetReasons::HardReset;
}