aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Salzedo <[email protected]>2021-03-21 16:45:24 -0700
committerJoshua Salzedo <[email protected]>2021-03-21 16:45:24 -0700
commitcf1323fb67b2841a99bb497d7947ffa772ff354d (patch)
tree03eff74320cbba5cb50ab6f76cabd747586d13f5
parent3e4e292cb70394a05b007e98e6fc9b513f63b7b2 (diff)
Add module-level documentation for embassy::time
-rw-r--r--embassy/src/time/mod.rs9
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///
1mod duration; 4mod duration;
2mod instant; 5mod instant;
3mod traits; 6mod traits;
@@ -14,10 +17,16 @@ pub const TICKS_PER_SECOND: u64 = 32768;
14 17
15static mut CLOCK: Option<&'static dyn Clock> = None; 18static 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.
17pub unsafe fn set_clock(clock: &'static dyn Clock) { 23pub 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.
21pub(crate) fn now() -> u64 { 30pub(crate) fn now() -> u64 {
22 unsafe { unwrap!(CLOCK, "No clock set").now() } 31 unsafe { unwrap!(CLOCK, "No clock set").now() }
23} 32}