esp_hal::timer

Trait Timer

Source
pub trait Timer: Sealed {
    // Required methods
    fn start(&self);
    fn stop(&self);
    fn reset(&self);
    fn is_running(&self) -> bool;
    fn now(&self) -> Instant<u64, 1, 1_000_000>;
    fn load_value(&self, value: MicrosDurationU64) -> Result<(), Error>;
    fn enable_auto_reload(&self, auto_reload: bool);
    fn enable_interrupt(&self, state: bool);
    fn clear_interrupt(&self);
    fn set_interrupt_handler(&self, handler: InterruptHandler);
    fn is_interrupt_set(&self) -> bool;
}
Expand description

Functionality provided by any timer peripheral.

Required Methods§

Source

fn start(&self)

Start the timer.

Source

fn stop(&self)

Stop the timer.

Source

fn reset(&self)

Reset the timer value to 0.

Source

fn is_running(&self) -> bool

Is the timer running?

Source

fn now(&self) -> Instant<u64, 1, 1_000_000>

The current timer value.

Source

fn load_value(&self, value: MicrosDurationU64) -> Result<(), Error>

Load a target value into the timer.

Source

fn enable_auto_reload(&self, auto_reload: bool)

Enable auto reload of the loaded value.

Source

fn enable_interrupt(&self, state: bool)

Enable or disable the timer’s interrupt.

Source

fn clear_interrupt(&self)

Clear the timer’s interrupt.

Source

fn set_interrupt_handler(&self, handler: InterruptHandler)

Set the interrupt handler

Note that this will replace any previously set interrupt handler

Source

fn is_interrupt_set(&self) -> bool

Has the timer triggered?

Implementors§

Source§

impl Timer for AnyTimer

Source§

impl<T, DM> Timer for Timer<T, DM>
where T: Instance, DM: Mode,

Source§

impl<T, DM, COMP: Comparator, UNIT: Unit> Timer for Alarm<'_, T, DM, COMP, UNIT>
where DM: Mode,