Add clock::Monotonic trait.
This commit is contained in:
@@ -12,3 +12,4 @@ defmt = "0.1.0"
|
||||
cortex-m = "0.6.3"
|
||||
futures = { version = "0.3.5", default-features = false, features = [ "async-await" ] }
|
||||
pin-project = { version = "0.4.23", default-features = false }
|
||||
futures-intrusive = { version = "0.3.1", default-features = false }
|
||||
|
21
embassy/src/clock.rs
Normal file
21
embassy/src/clock.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
/// Monotonic clock with support for setting an alarm.
|
||||
///
|
||||
/// The clock uses a "tick" time unit, whose length is an implementation-dependent constant.
|
||||
pub trait Monotonic {
|
||||
/// Returns the current timestamp in ticks.
|
||||
/// This is guaranteed to be monotonic, i.e. a call to now() will always return
|
||||
/// a greater or equal value than earler calls.
|
||||
fn now(&self) -> u64;
|
||||
|
||||
/// Sets an alarm at the given timestamp. When the clock reaches that
|
||||
/// timestamp, the provided callback funcion will be called.
|
||||
///
|
||||
/// When callback is called, it is guaranteed that now() will return a value greater or equal than timestamp.
|
||||
///
|
||||
/// Only one alarm can be active at a time. This overwrites any previously-set alarm if any.
|
||||
fn set_alarm(&self, timestamp: u64, callback: fn());
|
||||
|
||||
/// Clears the previously-set alarm.
|
||||
/// If no alarm was set, this is a noop.
|
||||
fn clear_alarm(&self);
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
pub mod clock;
|
||||
pub mod flash;
|
||||
pub mod util;
|
||||
pub mod io;
|
||||
pub mod util;
|
||||
|
Reference in New Issue
Block a user