[][src]Trait embedded_time::clock::Clock

pub trait Clock: Sized {
    type Rep: TimeInt;
    type ImplError: Error;

    const PERIOD: Period;

    fn now(&self) -> Result<Instant<Self>, Error<Self::ImplError>>;

    fn new_timer<Dur: Duration>(
        &self,
        duration: Dur
    ) -> Timer<OneShot, Armed, Self, Dur> { ... } }

The Clock trait provides an abstraction of hardware-specific timer peripherals, external timer devices, RTCs, etc.

The Clock is characterized by an inner unsigned integer storage type (either u32 or u64), a u32/u32 fraction (Period) defining the duration (in seconds) of one count of this Clock, and a custom error type (must implement crate::Error) representing errors that may be generated by the implementation.

In addition to the Clock::now() method which returns an Instant, an unlimited number of software Timers can be spawned from a single Clock instance.

Associated Types

type Rep: TimeInt

The type to hold the tick count

type ImplError: Error

Implementation-defined error type

This type can be returned using the clock::Error::Other(E)

Loading content...

Associated Constants

const PERIOD: Period

The duration of one clock tick in seconds, AKA the clock precision.

Loading content...

Required methods

fn now(&self) -> Result<Instant<Self>, Error<Self::ImplError>>

Get the current Instant

Errors

Implementation-specific error returned as Error::Other(Self::ImplError)

Loading content...

Provided methods

fn new_timer<Dur: Duration>(
    &self,
    duration: Dur
) -> Timer<OneShot, Armed, Self, Dur>

Spawn a new, OneShot Timer from this clock

Loading content...

Implementors

Loading content...