Merge pull request #4021 from CBJamo/rp23-watchdog-fix

RP235x watchdog doesn't have the double count bug
This commit is contained in:
Dario Nieuwenhuis 2025-03-29 15:19:44 +00:00 committed by GitHub
commit cae954a87e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,17 +89,25 @@ impl Watchdog {
/// Start the watchdog timer /// Start the watchdog timer
pub fn start(&mut self, period: Duration) { pub fn start(&mut self, period: Duration) {
#[cfg(feature = "rp2040")]
const MAX_PERIOD: u32 = 0xFFFFFF / 2;
#[cfg(feature = "_rp235x")]
const MAX_PERIOD: u32 = 0xFFFFFF; const MAX_PERIOD: u32 = 0xFFFFFF;
let delay_us = period.as_micros(); let delay_us = period.as_micros();
if delay_us > (MAX_PERIOD / 2) as u64 { if delay_us > (MAX_PERIOD) as u64 {
panic!("Period cannot exceed {} microseconds", MAX_PERIOD / 2); panic!("Period cannot exceed {} microseconds", MAX_PERIOD);
} }
let delay_us = delay_us as u32; let delay_us = delay_us as u32;
// 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.load_value = delay_us * 2; // This errata is fixed in the RP235x
if cfg!(feature = "rp2040") {
self.load_value = delay_us * 2;
} else {
self.load_value = delay_us;
}
self.enable(false); self.enable(false);
self.configure_wdog_reset_triggers(); self.configure_wdog_reset_triggers();