From 9115c49bba366698c79b3fc07a991bee1c0cd4ca Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 7 Jun 2020 20:31:13 +0200 Subject: [PATCH] Fix reset reason (it returns the actual reset reason instead of hard coded 'hard reset' value). --- src/drivers/Watchdog.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/drivers/Watchdog.cpp b/src/drivers/Watchdog.cpp index 850fd2f1..11da1211 100644 --- a/src/drivers/Watchdog.cpp +++ b/src/drivers/Watchdog.cpp @@ -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; }