pub struct Ostimer<'d, I: Instance> { /* private fields */ }Expand description
OSTIMER peripheral instance
Implementations§
Source§impl<'d, I: Instance> Ostimer<'d, I>
impl<'d, I: Instance> Ostimer<'d, I>
Sourcepub fn new(_inst: Peri<'d, I>, cfg: Config) -> Self
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.
Sourcepub fn clock_frequency_hz(&self) -> u64
pub fn clock_frequency_hz(&self) -> u64
Get the configured clock frequency in Hz
Sourcepub fn now(&self) -> u64
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
Sourcepub fn reset(&self, _peripherals: &Peripherals)
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.
Sourcepub fn schedule_alarm_delay(&self, alarm: &Alarm<'_>, delay_us: u64) -> bool
pub fn schedule_alarm_delay(&self, alarm: &Alarm<'_>, delay_us: u64) -> bool
Sourcepub fn schedule_alarm_at(&self, alarm: &Alarm<'_>, target_ticks: u64) -> bool
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 scheduletarget_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
Sourcepub fn cancel_alarm(&self, alarm: &Alarm<'_>)
pub fn cancel_alarm(&self, alarm: &Alarm<'_>)
Cancel any active alarm
Sourcepub fn check_alarm_expired(&self, alarm: &Alarm<'_>) -> bool
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