aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-01-22 00:34:40 +0100
committerGitHub <[email protected]>2025-01-22 00:34:40 +0100
commit010d4622f988de813ecddf69b84273f72ab122cf (patch)
treee8d227d7806c9adeae44ad53f830292b6e169746
parent1d8ef6faa2cf5d407729eb128a9f730a4800893b (diff)
parent1c9fa804929d3418292b55d653c489f50eec3805 (diff)
Merge pull request #3765 from dimpolo/hertz-display
stm32: impl Display for time::Hertz
-rw-r--r--embassy-stm32/src/time.rs7
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
3use core::fmt::Display;
3use core::ops::{Div, Mul}; 4use 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))]
8pub struct Hertz(pub u32); 9pub struct Hertz(pub u32);
9 10
11impl Display for Hertz {
12 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
13 write!(f, "{} Hz", self.0)
14 }
15}
16
10impl Hertz { 17impl 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 {