esp_hal::timer::timg

Struct Timer

Source
pub struct Timer<T, DM>
where DM: Mode,
{ /* private fields */ }
Expand description

General-purpose timer.

Implementations§

Source§

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

Source

pub fn new(timg: T, apb_clk_freq: HertzU32) -> Self

Construct a new instance of Timer

Source

pub fn has_elapsed(&mut self) -> bool

Check if the timer has elapsed

Source

pub fn wait(&mut self)

Block until the timer has elapsed.

Trait Implementations§

Source§

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

Source§

type Error = Error

Error returned when a countdown can’t be canceled.
Source§

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

Tries to cancel this countdown. Read more
Source§

impl<T> DelayNs for Timer<T, Async>
where T: Instance,

Source§

async 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§

async 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§

async 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, DM> Deref for Timer<T, DM>
where T: Instance, DM: Mode,

Source§

type Target = T

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

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

Source§

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

Mutably dereferences the value.
Source§

impl From<Timer<TimerX<TIMG0>, Blocking>> for AnyTimer

Source§

fn from(value: Timer<Timer0<TIMG0>, Blocking>) -> Self

Converts to this type from the input type.
Source§

impl From<Timer<TimerX<TIMG1>, Blocking>> for AnyTimer

Source§

fn from(value: Timer<Timer0<TIMG1>, Blocking>) -> Self

Converts to this type from the input type.
Source§

impl<T> InterruptConfigurable for Timer<T, Blocking>
where T: Instance,

Source§

fn set_interrupt_handler(&mut self, handler: InterruptHandler)

Set the interrupt handler Read more
Source§

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

Source§

type P = Timer<T, DM>

Peripheral singleton type
Source§

unsafe fn clone_unchecked(&self) -> Self::P

Unsafely clone (duplicate) a peripheral singleton. Read more
Source§

fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>
where Self: 'a,

Convert a value into a PeripheralRef. Read more
Source§

fn map_into<U>(self) -> U
where Self::P: Into<U>, U: Peripheral<P = U>,

Map the peripheral using Into. Read more
Source§

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

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 Read more
Source§

fn is_interrupt_set(&self) -> bool

Has the timer triggered?
Source§

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

Source§

type Time = Duration<u64, 1, 1000000>

The unit of time used by this timer
Source§

fn start<Time>(&mut self, timeout: Time)
where Time: Into<Self::Time>,

Starts a new count down
Source§

fn wait(&mut self) -> Result<(), Void>

Non-blockingly “waits” until the count down finishes Read more
Source§

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

Auto Trait Implementations§

§

impl<T, DM> Freeze for Timer<T, DM>
where T: Freeze,

§

impl<T, DM> RefUnwindSafe for Timer<T, DM>

§

impl<T, DM> Send for Timer<T, DM>
where T: Send, DM: Send,

§

impl<T, DM> Sync for Timer<T, DM>
where T: Sync, DM: Sync,

§

impl<T, DM> Unpin for Timer<T, DM>
where T: Unpin, DM: Unpin,

§

impl<T, DM> UnwindSafe for Timer<T, DM>
where T: UnwindSafe, DM: 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.