Skip to content

Commit 57931ca

Browse files
committed
Fix time types in independent_watchdog
1 parent 494ac00 commit 57931ca

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/independent_watchdog.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
//! - [IWDG Example](todo-insert-link-here)
1212
//!
1313
//! Originally from stm32h7-hal, adapted for stm32g4xx-hal
14+
use fugit::ExtU32;
1415
use crate::{
1516
stm32::{iwdg::pr::PR_A, IWDG},
16-
time::{MicroSecond, U32Ext},
17+
time::{MicroSecond},
1718
};
1819

1920
/// The implementation of the hardware IWDG
@@ -83,7 +84,7 @@ impl IndependentWatchdog {
8384
// Set the prescaler
8485
let (prescaler, _) = Self::MAX_MILLIS_FOR_PRESCALER
8586
.iter()
86-
.find(|(_, max_millis)| *max_millis >= max_window_time.0 / 1000)
87+
.find(|(_, max_millis)| *max_millis >= max_window_time.to_millis())
8788
.expect("IWDG max time is greater than is possible");
8889
while self.iwdg.sr.read().pvu().bit_is_set() {
8990
cortex_m::asm::nop();
@@ -99,9 +100,9 @@ impl IndependentWatchdog {
99100
.write(|w| w.win().bits(Self::MAX_COUNTER_VALUE as u16));
100101

101102
// Calculate the counter values
102-
let reload_value = (max_window_time.0 / 1000) * (Self::CLOCK_SPEED / 1000)
103+
let reload_value = (max_window_time.ticks() / 1000) * (Self::CLOCK_SPEED / 1000)
103104
/ Self::get_prescaler_divider(prescaler);
104-
let window_value = (min_window_time.0 / 1000) * (Self::CLOCK_SPEED / 1000)
105+
let window_value = (min_window_time.ticks() / 1000) * (Self::CLOCK_SPEED / 1000)
105106
/ Self::get_prescaler_divider(prescaler);
106107

107108
// Set the reload value
@@ -132,7 +133,7 @@ impl IndependentWatchdog {
132133

133134
/// Start the watchdog with the given max time and no minimal time
134135
pub fn start<T: Into<MicroSecond>>(&mut self, max_time: T) {
135-
self.start_windowed(0_u32.ms(), max_time.into());
136+
self.start_windowed(0_u32.millis(), max_time.into());
136137
}
137138

138139
fn get_prescaler_divider(prescaler: &PR_A) -> u32 {

0 commit comments

Comments
 (0)