Trait embedded_hal_mock::eh0::timer::Clock

source ·
pub trait Clock: Sized {
    type T: TimeInt + Hash;

    const SCALING_FACTOR: Fraction;

    // Required method
    fn try_now(&self) -> Result<Instant<Self>, Error>;

    // Provided method
    fn new_timer<Dur>(
        &self,
        duration: Dur
    ) -> Timer<'_, OneShot, Armed, Self, Dur>
       where Dur: Duration + FixedPoint { ... }
}
Available on crate features eh0 and embedded-time only.
Expand description

The Clock trait provides an abstraction for 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 defining the duration (in seconds) of one count of the Clock, and a custom error type representing errors that may be generated by the implementation.

In addition to the Clock::try_now() method which returns an Instant, software Timers can be spawned from a Clock object.

Required Associated Types§

source

type T: TimeInt + Hash

The type to hold the tick count

Required Associated Constants§

source

const SCALING_FACTOR: Fraction

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

Required Methods§

source

fn try_now(&self) -> Result<Instant<Self>, Error>

Get the current Instant

§Errors

Provided Methods§

source

fn new_timer<Dur>(&self, duration: Dur) -> Timer<'_, OneShot, Armed, Self, Dur>
where Dur: Duration + FixedPoint,

Spawn a new, OneShot Timer from this clock

Object Safety§

This trait is not object safe.

Implementors§