Skip to content

Commit

Permalink
Merge pull request #3765 from dimpolo/hertz-display
Browse files Browse the repository at this point in the history
stm32: impl Display for time::Hertz
  • Loading branch information
Dirbaio authored Jan 21, 2025
2 parents 1d8ef6f + 1c9fa80 commit 010d462
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions embassy-stm32/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
//! Time units
use core::fmt::Display;
use core::ops::{Div, Mul};

/// Hertz
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Hertz(pub u32);

impl Display for Hertz {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{} Hz", self.0)
}
}

impl Hertz {
/// Create a `Hertz` from the given hertz.
pub const fn hz(hertz: u32) -> Self {
Expand Down

0 comments on commit 010d462

Please sign in to comment.