pub struct CountDownTimer<TIMERX> { /* private fields */ }Expand description
A running timer, counting down the interval Timer::start was given.
Free-running: the counter reloads and starts over on every rollover, so the interval repeats until the timer is stopped.
Implementations§
Source§impl<TIMERX: Instance> CountDownTimer<TIMERX>
impl<TIMERX: Instance> CountDownTimer<TIMERX>
Sourcepub fn cnt(&self) -> u16
pub fn cnt(&self) -> u16
Returns the current counter value, in timer ticks.
Says where inside the current interval the timer is, not how many
intervals passed. One tick is psc() + 1 cycles of the timer clock.
Sourcepub fn car(&self) -> u16
pub fn car(&self) -> u16
Returns the value the counter rolls over at, in timer ticks.
Read back from the hardware, so it holds for a raw
start too. One interval is car() + 1 ticks: cnt()
reaching this value is the last tick before a rollover, not the rollover.
Sourcepub fn psc(&self) -> u16
pub fn psc(&self) -> u16
Returns the prescaler the counter is running on.
One tick is psc() + 1 cycles of the timer clock — what turns a
cnt reading into time. Read back from the hardware.
Sourcepub fn elapsed<const NOM: u64, const DENOM: u64>(
&self,
) -> Duration<u32, NOM, DENOM>
pub fn elapsed<const NOM: u64, const DENOM: u64>( &self, ) -> Duration<u32, NOM, DENOM>
Returns how far into the current interval the counter is, as a duration.
Restarts from zero at every rollover and never exceeds one interval;
counting intervals is the caller’s business. The scale comes from the
binding (let t: MillisDuration = timer.elapsed();) — coarser than one
tick floors to zero, finer than u32 spans saturates. Resolution is one
tick.
Sourcepub fn listen(&mut self, event: Event)
pub fn listen(&mut self, event: Event)
Lets event raise an interrupt. Unmasking the line in the NVIC is the
caller’s.
Sourcepub fn unlisten(&mut self, event: Event)
pub fn unlisten(&mut self, event: Event)
Stops event from raising an interrupt. Leaves the NVIC alone.
Sourcepub fn is_listening(&self, event: Event) -> bool
pub fn is_listening(&self, event: Event) -> bool
Whether event reaches the NVIC.
Sourcepub fn is_pending(&self, event: Event) -> bool
pub fn is_pending(&self, event: Event) -> bool
Whether the flag event raises is standing.
The enable and the flag are independent: this reports rollovers whether or not anything is listening for them.
Sourcepub fn clear_interrupt(&mut self, event: Event)
pub fn clear_interrupt(&mut self, event: Event)
Clears the flag event raised.
A handler must call this, first thing: the request is the flag being set, and hardware never clears it, so returning with it still set re-enters the handler at once and starves everything else.
Sourcepub fn wait(&mut self)
pub fn wait(&mut self)
Blocks until the counter rolls over, then clears the update flag.
Leaves the timer running, so calling this in a loop yields one full interval per call.