From fe72637972895c16f07813349297943264531f5a Mon Sep 17 00:00:00 2001 From: jspaulsen Date: Sun, 16 May 2021 14:41:38 -0700 Subject: [PATCH] Fix logic issue with delay_ms --- rp2040-hal/src/watchdog.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rp2040-hal/src/watchdog.rs b/rp2040-hal/src/watchdog.rs index 2006af0..1fec62b 100644 --- a/rp2040-hal/src/watchdog.rs +++ b/rp2040-hal/src/watchdog.rs @@ -8,15 +8,14 @@ use embedded_time::{ use crate::pac::WATCHDOG; -//const MAX_LOAD: u32 = 0x7FFFFF; - - +/// pub struct Watchdog { watchdog: WATCHDOG, delay_ms: u32, } impl Watchdog { + /// pub fn new(watchdog: WATCHDOG) -> Self { Self { watchdog, @@ -24,6 +23,7 @@ impl Watchdog { } } + /// pub fn enable_tick_generation(&mut self, cycles: u8) { const WATCHDOG_TICK_ENABLE_BITS: u32 = 0x200; @@ -57,11 +57,11 @@ impl watchdog::WatchdogEnable for Watchdog { /// Due to a logic error, the watchdog decrements by 2 and /// value must be compensated; see RP2040-E1 fn start>(&mut self, period: T) { - let delay_ms = period + self.delay_ms = period .into() .integer() * 2; - self.load_counter(delay_ms); + self.load_counter(self.delay_ms); self.enable(); } }