esp_hal::timer::systimer

Struct Alarm

Source
pub struct Alarm<'d, MODE, DM, COMP = AnyComparator<'d>, UNIT = AnyUnit<'d>>
where DM: Mode,
{ /* private fields */ }
Expand description

A single alarm.

Implementations§

Source§

impl<'d, T, COMP: Comparator, UNIT: Unit> Alarm<'d, T, Blocking, COMP, UNIT>

Source

pub fn new(comparator: COMP, unit: &FrozenUnit<'d, UNIT>) -> Self

Creates a new alarm from a comparator and unit, in blocking mode.

Source§

impl<'d, T, COMP: Comparator, UNIT: Unit> Alarm<'d, T, Async, COMP, UNIT>

Source

pub fn new_async(comparator: COMP, unit: &FrozenUnit<'d, UNIT>) -> Self

Creates a new alarm from a comparator and unit, in async mode.

Source§

impl<'d, DM, COMP: Comparator, UNIT: Unit> Alarm<'d, Target, DM, COMP, UNIT>
where DM: Mode,

Source

pub fn set_target(&self, timestamp: u64)

Set the target value of this Alarm

Source

pub fn wait_until(&self, timestamp: u64)

Block waiting until the timer reaches the timestamp

Source

pub fn into_periodic(self) -> Alarm<'d, Periodic, DM, COMP, UNIT>

Converts this Alarm into Periodic mode

Source§

impl<'d, DM, COMP: Comparator, UNIT: Unit> Alarm<'d, Periodic, DM, COMP, UNIT>
where DM: Mode,

Source

pub fn set_period(&self, period: MicrosDurationU32)

Set the period of this Alarm

Source

pub fn into_target(self) -> Alarm<'d, Target, DM, COMP, UNIT>

Converts this Alarm into Target mode

Trait Implementations§

Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<COMP: Comparator, UNIT: Unit> DelayNs for Alarm<'_, Target, Async, COMP, UNIT>

Source§

async fn delay_ns(&mut self, nanos: 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_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§

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§

impl From<Alarm<'static, Periodic, Blocking>> for AnyTimer

Source§

fn from(value: Alarm<'static, Periodic, Blocking>) -> Self

Converts to this type from the input type.
Source§

impl From<Alarm<'static, Target, Blocking>> for AnyTimer

Source§

fn from(value: Alarm<'static, Target, Blocking>) -> Self

Converts to this type from the input type.
Source§

impl<T, COMP: Comparator, UNIT: Unit> InterruptConfigurable for Alarm<'_, T, Blocking, COMP, UNIT>

Source§

fn set_interrupt_handler(&mut self, handler: InterruptHandler)

Set the interrupt handler Read more
Source§

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

Source§

type P = Alarm<'_, T, DM, COMP, UNIT>

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, COMP: Comparator, UNIT: Unit> Timer for Alarm<'_, T, DM, COMP, UNIT>
where 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 is_interrupt_set(&self) -> bool

Has the timer triggered?
Source§

fn set_interrupt_handler(&self, handler: InterruptHandler)

Set the interrupt handler Read more

Auto Trait Implementations§

§

impl<'d, MODE, DM, COMP, UNIT> Freeze for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: Freeze,

§

impl<'d, MODE, DM, COMP, UNIT> RefUnwindSafe for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: RefUnwindSafe, UNIT: RefUnwindSafe, MODE: RefUnwindSafe, DM: RefUnwindSafe,

§

impl<'d, MODE, DM, COMP, UNIT> Send for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: Send, UNIT: Sync, MODE: Send, DM: Send,

§

impl<'d, MODE, DM, COMP, UNIT> Sync for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: Sync, UNIT: Sync, MODE: Sync, DM: Sync,

§

impl<'d, MODE, DM, COMP, UNIT> Unpin for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: Unpin, MODE: Unpin, DM: Unpin,

§

impl<'d, MODE, DM, COMP, UNIT> UnwindSafe for Alarm<'d, MODE, DM, COMP, UNIT>
where COMP: UnwindSafe, UNIT: RefUnwindSafe, MODE: 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<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.