[][src]Trait kernel::hil::time::Alarm

pub trait Alarm<'a, W = u32>: Time<W> {
    fn set_alarm(&self, tics: W);
fn get_alarm(&self) -> W;
fn set_client(&'a self, client: &'a dyn AlarmClient);
fn is_enabled(&self) -> bool;
fn disable(&self); fn enable(&self) { ... } }

The Alarm trait models a wrapping counter capable 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). Implementers should use the Client trait to signal when the counter has reached a pre-specified value set in set_alarm.

Required methods

fn set_alarm(&self, tics: W)

Sets a one-shot alarm to fire when the clock reaches tics.

Client#fired is signaled when tics is reached.

Examples

This example is not tested
let delta = 1337;
let tics = alarm.now().wrapping_add(delta);
alarm.set_alarm(tics);

fn get_alarm(&self) -> W

Returns the value set in set_alarm

fn set_client(&'a self, client: &'a dyn AlarmClient)

Set the client for interrupt events.

fn is_enabled(&self) -> bool

Returns whether this alarm is currently active (will eventually trigger a callback if there is a client).

fn disable(&self)

Disables the alarm.

The implementation will always disable the alarm and prevent events related to previously set alarms from being delivered to the client.

Loading content...

Provided methods

fn enable(&self)

Enables the alarm using the previously set tics for the alarm.

Most implementations should use the default implementation which calls set_alarm with the value returned by get_alarm unless there is a more efficient way to achieve the same semantics.

Loading content...

Implementors

Loading content...