Refactor, document and fix the Watchdog driver (#1710)

* Refactor and document the Watchdog driver to make it more readable.

Fix the configuration of the behaviours configuration that was not properly implemented (but it didn't cause any side effect since the correct value was eventually set in NRF_WDT->CONFIG).

Fix the wrong interpretation of the reset reasons caused by implicit conversions of int to bool.
This commit is contained in:
JF
2023-04-30 15:56:13 +02:00
committed by GitHub
parent c22e30a4a6
commit 5f19f689f9
4 changed files with 187 additions and 69 deletions

View File

@@ -101,24 +101,24 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
auto batteryPercent = batteryController.PercentRemaining();
const auto* resetReason = [this]() {
switch (watchdog.ResetReason()) {
case Drivers::Watchdog::ResetReasons::Watchdog:
switch (watchdog.GetResetReason()) {
case Drivers::Watchdog::ResetReason::Watchdog:
return "wtdg";
case Drivers::Watchdog::ResetReasons::HardReset:
case Drivers::Watchdog::ResetReason::HardReset:
return "hardr";
case Drivers::Watchdog::ResetReasons::NFC:
case Drivers::Watchdog::ResetReason::NFC:
return "nfc";
case Drivers::Watchdog::ResetReasons::SoftReset:
case Drivers::Watchdog::ResetReason::SoftReset:
return "softr";
case Drivers::Watchdog::ResetReasons::CpuLockup:
case Drivers::Watchdog::ResetReason::CpuLockup:
return "cpulock";
case Drivers::Watchdog::ResetReasons::SystemOff:
case Drivers::Watchdog::ResetReason::SystemOff:
return "off";
case Drivers::Watchdog::ResetReasons::LpComp:
case Drivers::Watchdog::ResetReason::LpComp:
return "lpcomp";
case Drivers::Watchdog::ResetReasons::DebugInterface:
case Drivers::Watchdog::ResetReason::DebugInterface:
return "dbg";
case Drivers::Watchdog::ResetReasons::ResetPin:
case Drivers::Watchdog::ResetReason::ResetPin:
return "rst";
default:
return "?";