esp_hal::timer

Struct OneShotTimer

Source
pub struct OneShotTimer<'d, T> { /* private fields */ }
Expand description

A one-shot timer.

Implementations§

Source§

impl<'d, T> OneShotTimer<'d, T>
where T: Timer,

Source

pub fn new(inner: impl Peripheral<P = T> + 'd) -> Self

Construct a new instance of OneShotTimer.

Source

pub fn delay_millis(&self, ms: u32)

Pauses execution for at least ms milliseconds.

Source

pub fn delay_micros(&self, us: u32)

Pauses execution for at least us microseconds.

Source

pub fn delay_nanos(&self, ns: u32)

Pauses execution for at least ns nanoseconds.

Source

pub fn schedule(&mut self, timeout: MicrosDurationU64) -> Result<(), Error>

Start counting until the given timeout and raise an interrupt

Source

pub fn stop(&mut self)

Stop the timer

Source

pub fn set_interrupt_handler(&mut self, handler: InterruptHandler)

Set the interrupt handler

Note that this will replace any previously set interrupt handler

Source

pub fn enable_interrupt(&mut self, enable: bool)

Enable listening for interrupts

Source

pub fn clear_interrupt(&mut self)

Clear the interrupt flag

Trait Implementations§

Source§

impl<T> DelayNs for OneShotTimer<'_, T>
where T: Timer,

Source§

fn delay_ns(&mut self, ns: u32)

Pauses execution for at minimum ns nanoseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_us(&mut self, us: u32)

Pauses execution for at minimum us microseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_ms(&mut self, ms: u32)

Pauses execution for at minimum ms milliseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

impl<T> InterruptConfigurable for OneShotTimer<'_, T>
where T: Timer,

Source§

fn set_interrupt_handler(&mut self, handler: InterruptHandler)

Set the interrupt handler Read more
Source§

impl<T, UXX> DelayMs<UXX> for OneShotTimer<'_, T>
where T: Timer, UXX: Into<u32>,

Source§

fn delay_ms(&mut self, ms: UXX)

Pauses execution for ms milliseconds
Source§

impl<T, UXX> DelayUs<UXX> for OneShotTimer<'_, T>
where T: Timer, UXX: Into<u32>,

Source§

fn delay_us(&mut self, us: UXX)

Pauses execution for us microseconds

Auto Trait Implementations§

§

impl<'d, T> Freeze for OneShotTimer<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for OneShotTimer<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for OneShotTimer<'d, T>
where T: Send,

§

impl<'d, T> Sync for OneShotTimer<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for OneShotTimer<'d, T>
where T: Unpin,

§

impl<'d, T> !UnwindSafe for OneShotTimer<'d, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.