embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

Ostimer

Struct Ostimer 

Source
pub struct Ostimer<'d, I: Instance> { /* private fields */ }
Expand description

OSTIMER peripheral instance

Implementations§

Source§

impl<'d, I: Instance> Ostimer<'d, I>

Source

pub fn new(_inst: Peri<'d, I>, cfg: Config) -> Self

Construct OSTIMER handle. Requires clocks for the instance to be enabled by the board before calling. Does not enable NVIC or INTENA; use time_driver::init() for async operation.

Source

pub fn clock_frequency_hz(&self) -> u64

Get the configured clock frequency in Hz

Source

pub fn now(&self) -> u64

Read the current timer counter value in timer ticks

§Returns

Current timer counter value as a 64-bit unsigned integer

Source

pub fn reset(&self, _peripherals: &Peripherals)

Reset the timer counter to zero

This performs a hardware reset of the OSTIMER peripheral, which will reset the counter to zero and clear any pending interrupts. Note that this will affect all timer operations including embassy-time.

§Safety

This operation will reset the entire OSTIMER peripheral. Any active alarms or time_driver operations will be disrupted. Use with caution.

Source

pub fn schedule_alarm_delay(&self, alarm: &Alarm<'_>, delay_us: u64) -> bool

Schedule a single-shot alarm to expire after the specified delay in microseconds

§Parameters
  • alarm - The alarm instance to schedule
  • delay_us - Delay in microseconds from now
§Returns

true if the alarm was scheduled successfully, false if it would exceed timer capacity

Source

pub fn schedule_alarm_at(&self, alarm: &Alarm<'_>, target_ticks: u64) -> bool

Schedule a single-shot alarm to expire at the specified absolute time in timer ticks

§Parameters
  • alarm - The alarm instance to schedule
  • target_ticks - Absolute time in timer ticks when the alarm should expire
§Returns

true if the alarm was scheduled successfully, false if it would exceed timer capacity

Source

pub fn cancel_alarm(&self, alarm: &Alarm<'_>)

Cancel any active alarm

Source

pub fn check_alarm_expired(&self, alarm: &Alarm<'_>) -> bool

Check if an alarm has expired (call this from your interrupt handler) Returns true if the alarm was active and has now expired

Auto Trait Implementations§

§

impl<'d, I> Freeze for Ostimer<'d, I>

§

impl<'d, I> RefUnwindSafe for Ostimer<'d, I>
where I: RefUnwindSafe,

§

impl<'d, I> Send for Ostimer<'d, I>
where I: Send,

§

impl<'d, I> Sync for Ostimer<'d, I>
where I: Sync,

§

impl<'d, I> Unpin for Ostimer<'d, I>
where I: Unpin,

§

impl<'d, I> !UnwindSafe for Ostimer<'d, I>

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.