Skip to content

Commit

Permalink
Add get_f64
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyoshaVasilieva authored and mciantyre committed Nov 17, 2020
1 parent 665e1c8 commit 597a113
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions imxrt-hal/src/srtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ impl SRTC {
get(&self.reg)
}

/// Gets the current time as a floating point amount of seconds.
pub fn get_f64(&self) -> f64 {
let (sec, ticks) = self.get_with_ticks();
(sec as f64) + (ticks as f64 / 32768.0)
}

/// Set the current time as a count of seconds since some point in the past and the sub-second
/// time as 32768Hz ticks.
pub fn set(&mut self, time: u32, ticks: u16) {
Expand Down

0 comments on commit 597a113

Please sign in to comment.