Skip to content

Commit 6b1c43d

Browse files
committed
IWDT fmt
1 parent 6f8b36f commit 6b1c43d

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

examples/independent_watchdog.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
//#[macro_use]
77
//mod utils;
8-
use stm32g4xx_hal::{
9-
independent_watchdog::IndependentWatchdog, prelude::*,
10-
stm32::Peripherals
11-
};
8+
use stm32g4xx_hal::{independent_watchdog::IndependentWatchdog, prelude::*, stm32::Peripherals};
129

1310
use cortex_m_rt::entry;
1411

1512
// TODO: Use utils instead
13+
use defmt::Logger;
1614
use defmt_rtt as _; // global logger
1715
use panic_probe as _;
18-
pub use defmt::Logger;
1916

2017
use defmt::info; // TODO: Use utils::logger instead
2118

src/independent_watchdog.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
//! # Examples
1010
//!
1111
//! - [IWDG Example](todo-insert-link-here)
12-
//!
12+
//!
1313
//! 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+
};
1818

1919
/// The implementation of the hardware IWDG
2020
pub struct IndependentWatchdog {
@@ -71,11 +71,7 @@ impl IndependentWatchdog {
7171

7272
/// Start the watchdog where it must be fed before the max time is over and
7373
/// 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) {
7975
let min_window_time: MicroSecond = min_window_time.into();
8076
let max_window_time: MicroSecond = max_window_time.into();
8177

@@ -103,11 +99,9 @@ impl IndependentWatchdog {
10399
.write(|w| w.win().bits(Self::MAX_COUNTER_VALUE as u16));
104100

105101
// 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)
108103
/ 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)
111105
/ Self::get_prescaler_divider(prescaler);
112106

113107
// Set the reload value

0 commit comments

Comments
 (0)