[][src]Trait embedded_async_timer::Timer

pub trait Timer {
    type Duration: Clone;
    type Instant: Clone + Ord + AddAssign<Self::Duration>;

    const DELTA: Self::Duration;

    fn reset(&mut self);
fn interrupt_free<F: FnOnce(&CriticalSection) -> R, R>(f: F) -> R;
fn now(&self) -> Self::Instant;
fn disarm(&mut self);
fn arm(&mut self, deadline: &Self::Instant); }

A clock device that supports throwing alarm interrupts at given instant.

This trait assumes that the clock is not (re)set after initial configuration.

Associated Types

type Duration: Clone

A length of time.

You will probably want to make this type as close to your Instant type as possible, with a focus on making addition and storage efficient.

type Instant: Clone + Ord + AddAssign<Self::Duration>

A moment in time.

You will probably make this type as close to the internal representation of an instant as used by your RTC peripheral.

Loading content...

Associated Constants

const DELTA: Self::Duration

A minimal time increment, i.e. the time it takes to execute a handful of instructions.

Used when scheduling the next deadline, but in the meantime the deadline has passed.

Loading content...

Required methods

fn reset(&mut self)

Initialize the clock and start counting.

You will need to run this sometime after initializing the static memory in which the timer lives, such that the interrupt handler can access the timer.

fn interrupt_free<F: FnOnce(&CriticalSection) -> R, R>(f: F) -> R

Execute the function in an interrupt free critical section.

Probably you want to directly feed through cortex_m::interrupt::free or similar.

fn now(&self) -> Self::Instant

Yield the current time.

fn disarm(&mut self)

Disarm the set alarm.

fn arm(&mut self, deadline: &Self::Instant)

Set the alarm for a given time.

Loading content...

Implementations on Foreign Types

impl Timer for Rtc[src]

type Instant = InstantU32

type Duration = DurationU32

Loading content...

Implementors

impl Timer for Lptim1Rtc[src]

type Instant = InstantU32

type Duration = DurationU32

Loading content...