Trait kernel::hil::time::Alarm
[−]
[src]
pub trait Alarm: Time { fn now(&self) -> u32; fn set_alarm(&self, tics: u32); fn get_alarm(&self) -> u32; }
The Alarm
trait models a wrapping counter capapable of notifying when the
counter reaches a certain value.
Alarms represent a resource that keeps track of time in some fixed unit
(usually clock tics). Implementors should use the
Client
trait to signal when the counter has
reached a pre-specified value set in set_alarm
.
Required Methods
fn now(&self) -> u32
Returns the current time in hardware clock units.
fn set_alarm(&self, tics: u32)
Sets a one-shot alarm fire when the clock reaches tics
.
Client#fired
is signaled
when tics
is reached.
Examples
let delta = 1337; let tics = alarm.now().wrapping_add(delta); alarm.set_alarm(tics);
fn get_alarm(&self) -> u32
Returns the value set in set_alarm