aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-time/src/duration.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/embassy-time/src/duration.rs b/embassy-time/src/duration.rs
index d3c6f42a9..846a9c3d5 100644
--- a/embassy-time/src/duration.rs
+++ b/embassy-time/src/duration.rs
@@ -81,6 +81,11 @@ impl Duration {
81 } 81 }
82 } 82 }
83 83
84 /// Creates a duration corresponding to the specified Hz.
85 pub const fn from_hz(hz: u64) -> Duration {
86 Duration { ticks: TICK_HZ / hz }
87 }
88
84 /// Adds one Duration to another, returning a new Duration or None in the event of an overflow. 89 /// Adds one Duration to another, returning a new Duration or None in the event of an overflow.
85 pub fn checked_add(self, rhs: Duration) -> Option<Duration> { 90 pub fn checked_add(self, rhs: Duration) -> Option<Duration> {
86 self.ticks.checked_add(rhs.ticks).map(|ticks| Duration { ticks }) 91 self.ticks.checked_add(rhs.ticks).map(|ticks| Duration { ticks })