mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-23 09:46:33 +11:00
Fix watchdog counter load (#464)
Fix the watchdog load to reflect the 1us tick rate. This was changed in #361, which presumably used the field name (delay_ms) and assumed it was in milliseconds. So this also fixes the name to reflect that it's microseconds.
This commit is contained in:
parent
eac51cdd16
commit
39190c357f
1 changed files with 6 additions and 6 deletions
|
@ -41,7 +41,7 @@ use fugit::MicrosDurationU32;
|
||||||
/// Watchdog peripheral
|
/// Watchdog peripheral
|
||||||
pub struct Watchdog {
|
pub struct Watchdog {
|
||||||
watchdog: WATCHDOG,
|
watchdog: WATCHDOG,
|
||||||
delay_ms: u32,
|
delay_us: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Watchdog {
|
impl Watchdog {
|
||||||
|
@ -49,7 +49,7 @@ impl Watchdog {
|
||||||
pub fn new(watchdog: WATCHDOG) -> Self {
|
pub fn new(watchdog: WATCHDOG) -> Self {
|
||||||
Self {
|
Self {
|
||||||
watchdog,
|
watchdog,
|
||||||
delay_ms: 0,
|
delay_us: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ impl Watchdog {
|
||||||
|
|
||||||
impl watchdog::Watchdog for Watchdog {
|
impl watchdog::Watchdog for Watchdog {
|
||||||
fn feed(&mut self) {
|
fn feed(&mut self) {
|
||||||
self.load_counter(self.delay_ms)
|
self.load_counter(self.delay_us)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ impl watchdog::WatchdogEnable for Watchdog {
|
||||||
|
|
||||||
// Due to a logic error, the watchdog decrements by 2 and
|
// Due to a logic error, the watchdog decrements by 2 and
|
||||||
// the load value must be compensated; see RP2040-E1
|
// the load value must be compensated; see RP2040-E1
|
||||||
self.delay_ms = period.into().to_millis() * 2;
|
self.delay_us = period.into().to_micros() * 2;
|
||||||
|
|
||||||
if self.delay_ms > MAX_PERIOD {
|
if self.delay_us > MAX_PERIOD {
|
||||||
panic!("Period cannot exceed maximum load value of {}", MAX_PERIOD);
|
panic!("Period cannot exceed maximum load value of {}", MAX_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ impl watchdog::WatchdogEnable for Watchdog {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.configure_wdog_reset_triggers();
|
self.configure_wdog_reset_triggers();
|
||||||
}
|
}
|
||||||
self.load_counter(self.delay_ms);
|
self.load_counter(self.delay_us);
|
||||||
self.enable(true);
|
self.enable(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue