Skip to content

Commit

Permalink
extend ticks calculation in timer start from u32 to u64
Browse files Browse the repository at this point in the history
  • Loading branch information
apatrushev committed Sep 4, 2023
1 parent dac158e commit 206276e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ where
let timeout: Self::Time = timeout.into();
let clock = TIM::clock(&self.clocks);

let ticks = clock.integer().saturating_mul(timeout.integer()) * *timeout.scaling_factor();
let ticks = (clock.integer() as u64).saturating_mul(timeout.integer() as u64) * *timeout.scaling_factor();

let psc: u32 = (ticks.saturating_sub(1)) / (1 << 16);
let psc: u32 = (ticks.saturating_sub(1) / (1 << 16)) as u32;
self.tim.set_psc(crate::unwrap!(u16::try_from(psc).ok()));

let mut arr = ticks / psc.saturating_add(1);
let mut arr = (ticks / psc.saturating_add(1) as u64) as u32;
// If the set frequency is to high to get a meaningful timer resolution,
// set arr to one, so the timer can at least do something and code waiting
// on it is not stuck.
Expand Down

0 comments on commit 206276e

Please sign in to comment.