diff options
| author | Caleb Jamison <[email protected]> | 2025-03-28 17:45:41 -0400 |
|---|---|---|
| committer | Caleb Jamison <[email protected]> | 2025-03-28 17:45:41 -0400 |
| commit | 49badcff1a4f3e448f81a1703ee55e5bc2d368d4 (patch) | |
| tree | 0eace3a65f9721f73fb87b9495db130482ed5039 | |
| parent | 954d1554d4c04a245adadb5ebd97205d1442635e (diff) | |
RP235x watchdog doesn't have the double count bug
| -rw-r--r-- | embassy-rp/src/watchdog.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs index 760d6aac2..49cf03850 100644 --- a/embassy-rp/src/watchdog.rs +++ b/embassy-rp/src/watchdog.rs | |||
| @@ -89,17 +89,25 @@ impl Watchdog { | |||
| 89 | 89 | ||
| 90 | /// Start the watchdog timer | 90 | /// Start the watchdog timer |
| 91 | pub fn start(&mut self, period: Duration) { | 91 | pub fn start(&mut self, period: Duration) { |
| 92 | #[cfg(feature = "rp2040")] | ||
| 93 | const MAX_PERIOD: u32 = 0xFFFFFF / 2; | ||
| 94 | #[cfg(feature = "_rp235x")] | ||
| 92 | const MAX_PERIOD: u32 = 0xFFFFFF; | 95 | const MAX_PERIOD: u32 = 0xFFFFFF; |
| 93 | 96 | ||
| 94 | let delay_us = period.as_micros(); | 97 | let delay_us = period.as_micros(); |
| 95 | if delay_us > (MAX_PERIOD / 2) as u64 { | 98 | if delay_us > (MAX_PERIOD) as u64 { |
| 96 | panic!("Period cannot exceed {} microseconds", MAX_PERIOD / 2); | 99 | panic!("Period cannot exceed {} microseconds", MAX_PERIOD); |
| 97 | } | 100 | } |
| 98 | let delay_us = delay_us as u32; | 101 | let delay_us = delay_us as u32; |
| 99 | 102 | ||
| 100 | // Due to a logic error, the watchdog decrements by 2 and | 103 | // Due to a logic error, the watchdog decrements by 2 and |
| 101 | // the load value must be compensated; see RP2040-E1 | 104 | // the load value must be compensated; see RP2040-E1 |
| 102 | self.load_value = delay_us * 2; | 105 | // This errata is fixed in the RP235x |
| 106 | if cfg!(feature = "rp2040") { | ||
| 107 | self.load_value = delay_us * 2; | ||
| 108 | } else { | ||
| 109 | self.load_value = delay_us; | ||
| 110 | } | ||
| 103 | 111 | ||
| 104 | self.enable(false); | 112 | self.enable(false); |
| 105 | self.configure_wdog_reset_triggers(); | 113 | self.configure_wdog_reset_triggers(); |
