13
13
//! Originally from stm32h7-hal, adapted for stm32g4xx-hal
14
14
use crate :: {
15
15
stm32:: { iwdg:: pr:: PR_A , IWDG } ,
16
- time:: { MicroSecond , U32Ext } ,
16
+ time:: MicroSecond ,
17
17
} ;
18
+ use fugit:: ExtU32 ;
18
19
19
20
/// The implementation of the hardware IWDG
20
21
pub struct IndependentWatchdog {
@@ -83,7 +84,7 @@ impl IndependentWatchdog {
83
84
// Set the prescaler
84
85
let ( prescaler, _) = Self :: MAX_MILLIS_FOR_PRESCALER
85
86
. iter ( )
86
- . find ( |( _, max_millis) | * max_millis >= max_window_time. 0 / 1000 )
87
+ . find ( |( _, max_millis) | * max_millis >= max_window_time. to_millis ( ) )
87
88
. expect ( "IWDG max time is greater than is possible" ) ;
88
89
while self . iwdg . sr . read ( ) . pvu ( ) . bit_is_set ( ) {
89
90
cortex_m:: asm:: nop ( ) ;
@@ -99,9 +100,9 @@ impl IndependentWatchdog {
99
100
. write ( |w| w. win ( ) . bits ( Self :: MAX_COUNTER_VALUE as u16 ) ) ;
100
101
101
102
// Calculate the counter values
102
- let reload_value = ( max_window_time. 0 / 1000 ) * ( Self :: CLOCK_SPEED / 1000 )
103
+ let reload_value = max_window_time. to_millis ( ) * ( Self :: CLOCK_SPEED / 1000 )
103
104
/ 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. to_millis ( ) * ( Self :: CLOCK_SPEED / 1000 )
105
106
/ Self :: get_prescaler_divider ( prescaler) ;
106
107
107
108
// Set the reload value
@@ -132,7 +133,7 @@ impl IndependentWatchdog {
132
133
133
134
/// Start the watchdog with the given max time and no minimal time
134
135
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 ( ) ) ;
136
137
}
137
138
138
139
fn get_prescaler_divider ( prescaler : & PR_A ) -> u32 {
0 commit comments