Skip to main content

OneShotTimer

Struct OneShotTimer 

Source
pub struct OneShotTimer<'a> { /* private fields */ }
Expand description

One-shot timer wrapper.

Counts down from a loaded value and stops when it reaches zero.

Implementations§

Source§

impl OneShotTimer<'_>

Source

pub fn start(&mut self, count: u32)

Start the one-shot timer with a count value.

count is in timer clock ticks (TCXO = 24MHz → 1 tick ≈ 41.7ns).

Source

pub fn start_micros(&mut self, us: u32)

Start the timer for the given duration in microseconds.

Max duration: ~178 seconds at 24MHz (u32 ticks limit). For longer durations, use start_millis() or loop start_micros().

Source

pub fn start_millis(&mut self, ms: u32)

Start the timer for the given duration in milliseconds.

Max duration: ~178,956ms (~178s) at 24MHz. For longer durations, repeat this call in a loop.

Source

pub fn expired(&self) -> bool

Check if the timer has expired.

Source

pub fn wait(&self)

Wait for the timer to expire (busy-loop).

Source

pub fn current(&self) -> u32

Get the current counter value.

Source

pub fn stop(&self)

Stop the timer.

Source

pub fn clear(&self)

Clear the interrupt flag.

Trait Implementations§

Source§

impl DelayNs for OneShotTimer<'_>

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.

Auto Trait Implementations§

§

impl<'a> Freeze for OneShotTimer<'a>

§

impl<'a> RefUnwindSafe for OneShotTimer<'a>

§

impl<'a> Send for OneShotTimer<'a>

§

impl<'a> Sync for OneShotTimer<'a>

§

impl<'a> Unpin for OneShotTimer<'a>

§

impl<'a> UnsafeUnpin for OneShotTimer<'a>

§

impl<'a> UnwindSafe for OneShotTimer<'a>

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.