diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-01-22 00:34:40 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-22 00:34:40 +0100 |
| commit | 010d4622f988de813ecddf69b84273f72ab122cf (patch) | |
| tree | e8d227d7806c9adeae44ad53f830292b6e169746 | |
| parent | 1d8ef6faa2cf5d407729eb128a9f730a4800893b (diff) | |
| parent | 1c9fa804929d3418292b55d653c489f50eec3805 (diff) | |
Merge pull request #3765 from dimpolo/hertz-display
stm32: impl Display for time::Hertz
| -rw-r--r-- | embassy-stm32/src/time.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/embassy-stm32/src/time.rs b/embassy-stm32/src/time.rs index 802ff41ce..71fe668a9 100644 --- a/embassy-stm32/src/time.rs +++ b/embassy-stm32/src/time.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | //! Time units | 1 | //! Time units |
| 2 | 2 | ||
| 3 | use core::fmt::Display; | ||
| 3 | use core::ops::{Div, Mul}; | 4 | use core::ops::{Div, Mul}; |
| 4 | 5 | ||
| 5 | /// Hertz | 6 | /// Hertz |
| @@ -7,6 +8,12 @@ use core::ops::{Div, Mul}; | |||
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 8 | pub struct Hertz(pub u32); | 9 | pub struct Hertz(pub u32); |
| 9 | 10 | ||
| 11 | impl Display for Hertz { | ||
| 12 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| 13 | write!(f, "{} Hz", self.0) | ||
| 14 | } | ||
| 15 | } | ||
| 16 | |||
| 10 | impl Hertz { | 17 | impl Hertz { |
| 11 | /// Create a `Hertz` from the given hertz. | 18 | /// Create a `Hertz` from the given hertz. |
| 12 | pub const fn hz(hertz: u32) -> Self { | 19 | pub const fn hz(hertz: u32) -> Self { |
