Skip to content

Commit 8388b57

Browse files
committed
Disable watchdog on last watchdog test
1 parent ebead1b commit 8388b57

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/watchdog.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ impl IndependentWatchDog {
9292
self.iwdg.kr.write(|w| w.key().reset());
9393
a
9494
}
95+
96+
/// Stop the watchdog timer
97+
pub fn stop(&mut self) -> Self {
98+
self.access_registers(|iwdg| {
99+
iwdg.pr.reset();
100+
iwdg.rlr.reset();
101+
});
102+
}
103+
104+
/// Release the independent watchdog peripheral.
105+
///
106+
/// Disables the watchdog before releasing it.
107+
pub fn free(mut self) -> IWDG {
108+
self.stop();
109+
self.iwdg
110+
}
95111
}
96112

97113
impl WatchdogEnable for IndependentWatchDog {

testsuite/tests/watchdog.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,11 @@ mod tests {
8181
asm::delay(delay);
8282
}
8383
}
84+
85+
// It takes some time, until defmt_test exits.
86+
// In this time, the wathcodg can not be fed. So disable it in the last test.
87+
#[test]
88+
fn disable(state: &mut State) {
89+
state.iwdg.stop();
90+
}
8491
}

0 commit comments

Comments
 (0)