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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 187 additions and 69 deletions

View file

@ -99,9 +99,9 @@ void SystemTask::Process(void* instance) {
void SystemTask::Work() {
BootErrors bootError = BootErrors::None;
watchdog.Setup(7);
watchdog.Setup(7, Drivers::Watchdog::SleepBehaviour::Run, Drivers::Watchdog::HaltBehaviour::Pause);
watchdog.Start();
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::Watchdog::ResetReasonToString(watchdog.ResetReason()));
NRF_LOG_INFO("Last reset reason : %s", Pinetime::Drivers::ResetReasonToString(watchdog.GetResetReason()));
APP_GPIOTE_INIT(2);
spi.Init();
@ -403,7 +403,7 @@ void SystemTask::Work() {
dateTimeController.UpdateTime(systick_counter);
NoInit_BackUpTime = dateTimeController.CurrentDateTime();
if (nrf_gpio_pin_read(PinMap::Button) == 0) {
watchdog.Kick();
watchdog.Reload();
}
}
#pragma clang diagnostic pop