diff --git a/embassy/src/time/duration.rs b/embassy/src/time/duration.rs index 8135961ea..2d78c06b2 100644 --- a/embassy/src/time/duration.rs +++ b/embassy/src/time/duration.rs @@ -38,6 +38,15 @@ impl Duration { } } + /* + NOTE: us delays may not be as accurate + */ + pub const fn from_us(millis: u64) -> Duration { + Duration { + ticks: millis * TICKS_PER_SECOND / 1_000_000, + } + } + pub fn checked_add(self, rhs: Duration) -> Option { self.ticks .checked_add(rhs.ticks)