Timer

Trait Timer 

Source
pub trait Timer<const TIMER_HZ: u32> {
    type Error: Debug;

    // Required methods
    fn now(&mut self) -> TimerInstantU32<TIMER_HZ>;
    fn start(
        &mut self,
        duration: TimerDurationU32<TIMER_HZ>,
    ) -> Result<(), Self::Error>;
    fn cancel(&mut self) -> Result<(), Self::Error>;
    fn wait(&mut self) -> Result<(), Self::Error>;
}
Expand description

Provides non-blocking CountDown timing capabilities

Required Associated Types§

Source

type Error: Debug

An error that might happen during waiting

Required Methods§

Source

fn now(&mut self) -> TimerInstantU32<TIMER_HZ>

Return current time Instant

Source

fn start( &mut self, duration: TimerDurationU32<TIMER_HZ>, ) -> Result<(), Self::Error>

Start timer with a duration

Source

fn cancel(&mut self) -> Result<(), Self::Error>

Tries to stop this timer. An error will be returned if the timer has already been canceled or was never started. An error is also returned if the timer is not Periodic and has already expired.

Source

fn wait(&mut self) -> Result<(), Self::Error>

Wait until timer duration has expired. Must return nb::Error::WouldBlock if timer duration is not yet over. Must return OK(()) as soon as timer duration has expired.

Implementors§