Struct Delay

Source
pub struct Delay<TIM, const FREQ: u32>(/* private fields */);
Expand description

Periodic non-blocking timer that implements embedded_hal_02::blocking::delay traits.

§Example: Millisecond precision

To instantiate this with the TIM2 timer and millisecond precision:

let mut delay = dp.TIM2.delay_ms(&clocks);
delay.delay_ms(320_u32);

With millisecond precision, you can wait from 2 ms to 49 days.

§Example: Microsecond precision

To instantiate this with the TIM5 timer and microsecond precision:

let delay = dp.TIM5.delay_us(&clocks);
delay.delay_us(30_u32);
delay.delay_ms(5_u32);
delay.delay(5.millis());
delay.delay(3.secs());

With microsecond precision, you can wait from 2 µs to 71 min.

Implementations§

Source§

impl<TIM: Instance, const FREQ: u32> Delay<TIM, FREQ>

Source

pub fn delay(&mut self, time: TimerDurationU32<FREQ>)

Sleep for given time

Source

pub fn max_delay(&self) -> TimerDurationU32<FREQ>

Source

pub fn release(self) -> FTimer<TIM, FREQ>

Releases the TIM peripheral

Methods from Deref<Target = FTimer<T, FREQ>>§

Source

pub fn configure(&mut self, clocks: &Clocks)

Calculate prescaler depending on Clocks state

Source

pub fn set_master_mode(&mut self, mode: TIM::Mms)

Trait Implementations§

Source§

impl<TIM: Instance, const FREQ: u32> Delay<FREQ> for Delay<TIM, FREQ>

Source§

type Error = Infallible

An error that might happen during waiting
Source§

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

Wait until timer duration has expired.
Source§

impl<TIM: Instance, const FREQ: u32> DelayNs for Delay<TIM, FREQ>

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, const FREQ: u32> Deref for Delay<T, FREQ>

Source§

type Target = FTimer<T, FREQ>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, const FREQ: u32> DerefMut for Delay<T, FREQ>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<TIM: Instance, const FREQ: u32> DelayMs<u16> for Delay<TIM, FREQ>

Source§

fn delay_ms(&mut self, ms: u16)

Sleep for ms milliseconds

Source§

impl<TIM: Instance, const FREQ: u32> DelayMs<u32> for Delay<TIM, FREQ>

Source§

fn delay_ms(&mut self, ms: u32)

Sleep for ms milliseconds

Source§

impl<TIM: Instance, const FREQ: u32> DelayMs<u8> for Delay<TIM, FREQ>

Source§

fn delay_ms(&mut self, ms: u8)

Sleep for ms milliseconds

Source§

impl<TIM: Instance, const FREQ: u32> DelayUs<u16> for Delay<TIM, FREQ>

Source§

fn delay_us(&mut self, us: u16)

Sleep for us microseconds

Source§

impl<TIM: Instance, const FREQ: u32> DelayUs<u32> for Delay<TIM, FREQ>

Source§

fn delay_us(&mut self, us: u32)

Sleep for us microseconds

Source§

impl<TIM: Instance, const FREQ: u32> DelayUs<u8> for Delay<TIM, FREQ>

Source§

fn delay_us(&mut self, us: u8)

Sleep for us microseconds

Auto Trait Implementations§

§

impl<TIM, const FREQ: u32> Freeze for Delay<TIM, FREQ>
where TIM: Freeze,

§

impl<TIM, const FREQ: u32> RefUnwindSafe for Delay<TIM, FREQ>
where TIM: RefUnwindSafe,

§

impl<TIM, const FREQ: u32> Send for Delay<TIM, FREQ>
where TIM: Send,

§

impl<TIM, const FREQ: u32> Sync for Delay<TIM, FREQ>
where TIM: Sync,

§

impl<TIM, const FREQ: u32> Unpin for Delay<TIM, FREQ>
where TIM: Unpin,

§

impl<TIM, const FREQ: u32> UnwindSafe for Delay<TIM, FREQ>
where TIM: UnwindSafe,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.