aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/duration.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-time/src/duration.rs')
-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 5b140eeff..b3ea0468d 100644
--- a/embassy-time/src/duration.rs
+++ b/embassy-time/src/duration.rs
@@ -37,6 +37,11 @@ impl Duration {
37 self.ticks * (1_000_000 / GCD_1M) / (TICK_HZ / GCD_1M) 37 self.ticks * (1_000_000 / GCD_1M) / (TICK_HZ / GCD_1M)
38 } 38 }
39 39
40 /// Convert the `Duration` to nanoseconds, rounding down.
41 pub const fn as_nanos(&self) -> u64 {
42 self.ticks * (1_000_000_000 / GCD_1G) / (TICK_HZ / GCD_1G)
43 }
44
40 /// Creates a duration from the specified number of clock ticks 45 /// Creates a duration from the specified number of clock ticks
41 pub const fn from_ticks(ticks: u64) -> Duration { 46 pub const fn from_ticks(ticks: u64) -> Duration {
42 Duration { ticks } 47 Duration { ticks }