diff --git a/embassy/src/time/duration.rs b/embassy/src/time/duration.rs index c9600774..474d0621 100644 --- a/embassy/src/time/duration.rs +++ b/embassy/src/time/duration.rs @@ -37,6 +37,7 @@ impl Duration { ticks: secs * TICKS_PER_SECOND, } } + /// Creates a duration from the specified number of milliseconds pub const fn from_millis(millis: u64) -> Duration { Duration { @@ -61,19 +62,21 @@ impl Duration { .checked_add(rhs.ticks) .map(|ticks| Duration { ticks }) } + /// Subtracts one Duration to another, returning a new Duration or None in the event of an overflow. pub fn checked_sub(self, rhs: Duration) -> Option { self.ticks .checked_sub(rhs.ticks) .map(|ticks| Duration { ticks }) } - /// Multiplies one Duration to another, returning a new Duration or None in the event of an overflow. + /// Multiplies one Duration to another, returning a new Duration or None in the event of an overflow. pub fn checked_mul(self, rhs: u32) -> Option { self.ticks .checked_mul(rhs as _) .map(|ticks| Duration { ticks }) } + /// Divides one Duration against another, returning a new Duration or None in the event of an overflow. pub fn checked_div(self, rhs: u32) -> Option { self.ticks diff --git a/embassy/src/time/instant.rs b/embassy/src/time/instant.rs index 9a544fc4..61a61def 100644 --- a/embassy/src/time/instant.rs +++ b/embassy/src/time/instant.rs @@ -31,6 +31,7 @@ impl Instant { ticks: millis * TICKS_PER_SECOND as u64 / 1000, } } + /// Instant representing seconds since MCU start. pub const fn from_secs(seconds: u64) -> Self { Self {