Add pause_on_debug, disable watchdog prior to enabling

This commit is contained in:
jspaulsen 2021-05-16 15:17:36 -07:00 committed by 9names
parent fe72637972
commit cdd9a553ad

View file

@ -29,7 +29,20 @@ impl Watchdog {
self.watchdog self.watchdog
.tick .tick
.write(|w| unsafe { w.bits(WATCHDOG_TICK_ENABLE_BITS | cycles as u32)}) .write(|w| unsafe { w.bits(WATCHDOG_TICK_ENABLE_BITS | cycles as u32) })
}
///
pub fn pause_on_debug(&mut self, pause: bool) {
self.watchdog
.ctrl
.write(|w| {
w
.pause_dbg0().bit(pause)
.pause_dbg1().bit(pause)
.pause_jtag().bit(pause)
})
} }
fn load_counter(&self, counter: u32) { fn load_counter(&self, counter: u32) {
@ -38,10 +51,10 @@ impl Watchdog {
.write(|w| unsafe { w.bits(counter)}); .write(|w| unsafe { w.bits(counter)});
} }
fn enable(&self) { fn enable(&self, bit: bool) {
self.watchdog self.watchdog
.ctrl .ctrl
.write(|w| w.enable().set_bit()) .write(|w| w.enable().bit(bit))
} }
} }
@ -61,15 +74,14 @@ impl watchdog::WatchdogEnable for Watchdog {
.into() .into()
.integer() * 2; .integer() * 2;
self.enable(false);
self.load_counter(self.delay_ms); self.load_counter(self.delay_ms);
self.enable(); self.enable(true);
} }
} }
impl watchdog::WatchdogDisable for Watchdog { impl watchdog::WatchdogDisable for Watchdog {
fn disable(&mut self) { fn disable(&mut self) {
self.watchdog self.enable(false)
.ctrl
.write(|w| w.enable().clear_bit())
} }
} }