mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-01-23 01:36:35 +11:00
Fix logic issue with delay_ms
This commit is contained in:
parent
596bea309b
commit
fe72637972
1 changed files with 5 additions and 5 deletions
|
@ -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<T: Into<Self::Time>>(&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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue