|
9 | 9 | //! # Examples
|
10 | 10 | //!
|
11 | 11 | //! - [IWDG Example](todo-insert-link-here)
|
12 |
| -//! |
| 12 | +//! |
13 | 13 | //! Originally from stm32h7-hal, adapted for stm32g4xx-hal
|
14 |
| -use crate::{time::{MicroSecond, U32Ext}, stm32::{ |
15 |
| - IWDG, |
16 |
| - iwdg::pr::PR_A, |
17 |
| -}}; |
| 14 | +use crate::{ |
| 15 | + stm32::{iwdg::pr::PR_A, IWDG}, |
| 16 | + time::{MicroSecond, U32Ext}, |
| 17 | +}; |
18 | 18 |
|
19 | 19 | /// The implementation of the hardware IWDG
|
20 | 20 | pub struct IndependentWatchdog {
|
@@ -71,11 +71,7 @@ impl IndependentWatchdog {
|
71 | 71 |
|
72 | 72 | /// Start the watchdog where it must be fed before the max time is over and
|
73 | 73 | /// not before the min time has passed
|
74 |
| - pub fn start_windowed<T: Into<MicroSecond>>( |
75 |
| - &mut self, |
76 |
| - min_window_time: T, |
77 |
| - max_window_time: T, |
78 |
| - ) { |
| 74 | + pub fn start_windowed<T: Into<MicroSecond>>(&mut self, min_window_time: T, max_window_time: T) { |
79 | 75 | let min_window_time: MicroSecond = min_window_time.into();
|
80 | 76 | let max_window_time: MicroSecond = max_window_time.into();
|
81 | 77 |
|
@@ -103,11 +99,9 @@ impl IndependentWatchdog {
|
103 | 99 | .write(|w| w.win().bits(Self::MAX_COUNTER_VALUE as u16));
|
104 | 100 |
|
105 | 101 | // Calculate the counter values
|
106 |
| - let reload_value = (max_window_time.0 / 1000) |
107 |
| - * (Self::CLOCK_SPEED / 1000) |
| 102 | + let reload_value = (max_window_time.0 / 1000) * (Self::CLOCK_SPEED / 1000) |
108 | 103 | / Self::get_prescaler_divider(prescaler);
|
109 |
| - let window_value = (min_window_time.0 / 1000) |
110 |
| - * (Self::CLOCK_SPEED / 1000) |
| 104 | + let window_value = (min_window_time.0 / 1000) * (Self::CLOCK_SPEED / 1000) |
111 | 105 | / Self::get_prescaler_divider(prescaler);
|
112 | 106 |
|
113 | 107 | // Set the reload value
|
|
0 commit comments