diff options
| author | Joshua Salzedo <[email protected]> | 2021-03-21 16:45:24 -0700 |
|---|---|---|
| committer | Joshua Salzedo <[email protected]> | 2021-03-21 16:45:24 -0700 |
| commit | cf1323fb67b2841a99bb497d7947ffa772ff354d (patch) | |
| tree | 03eff74320cbba5cb50ab6f76cabd747586d13f5 | |
| parent | 3e4e292cb70394a05b007e98e6fc9b513f63b7b2 (diff) | |
Add module-level documentation for embassy::time
| -rw-r--r-- | embassy/src/time/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/embassy/src/time/mod.rs b/embassy/src/time/mod.rs index b45a608dd..b19ab6dbb 100644 --- a/embassy/src/time/mod.rs +++ b/embassy/src/time/mod.rs | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | /// Time abstractions | ||
| 2 | /// To use these abstractions, first call `set_clock` with an instance of an monotonic `Clock`. | ||
| 3 | /// | ||
| 1 | mod duration; | 4 | mod duration; |
| 2 | mod instant; | 5 | mod instant; |
| 3 | mod traits; | 6 | mod traits; |
| @@ -14,10 +17,16 @@ pub const TICKS_PER_SECOND: u64 = 32768; | |||
| 14 | 17 | ||
| 15 | static mut CLOCK: Option<&'static dyn Clock> = None; | 18 | static mut CLOCK: Option<&'static dyn Clock> = None; |
| 16 | 19 | ||
| 20 | /// Sets the clock used for the timing abstractions | ||
| 21 | /// | ||
| 22 | /// Safety: Sets a mutable global. | ||
| 17 | pub unsafe fn set_clock(clock: &'static dyn Clock) { | 23 | pub unsafe fn set_clock(clock: &'static dyn Clock) { |
| 18 | CLOCK = Some(clock); | 24 | CLOCK = Some(clock); |
| 19 | } | 25 | } |
| 20 | 26 | ||
| 27 | /// Return the current timestamp in ticks. | ||
| 28 | /// This is guaranteed to be monotonic, i.e. a call to now() will always return | ||
| 29 | /// a greater or equal value than earler calls. | ||
| 21 | pub(crate) fn now() -> u64 { | 30 | pub(crate) fn now() -> u64 { |
| 22 | unsafe { unwrap!(CLOCK, "No clock set").now() } | 31 | unsafe { unwrap!(CLOCK, "No clock set").now() } |
| 23 | } | 32 | } |
