pub struct CountdownTimer { /* private fields */ }Expand description
Hardware timers
Implementations§
Source§impl CountdownTimer
impl CountdownTimer
Sourcepub fn new<Tim: TimInstance>(_tim: Tim, sys_clk: Hertz) -> Self
pub fn new<Tim: TimInstance>(_tim: Tim, sys_clk: Hertz) -> Self
Create a countdown timer structure for a given TIM peripheral.
This does not enable the timer. You can use the Self::load, Self::start, Self::enable_interrupt and Self::enable API to set up and configure the countdown timer.
pub fn perid(&self) -> u32
pub fn enable(&mut self)
pub fn disable(&mut self)
pub fn enable_interrupt(&mut self, irq_cfg: InterruptConfig)
Sourcepub fn disable_interrupt(&mut self)
pub fn disable_interrupt(&mut self)
This function only clears the interrupt enable bit.
It does not mask the interrupt in the NVIC or un-route the IRQ.
Sourcepub fn start(&mut self, frequency: impl Into<Hertz>)
pub fn start(&mut self, frequency: impl Into<Hertz>)
Calls Self::load to configure the specified frequency and then calls Self::enable.
Sourcepub fn wait(&mut self) -> Result<(), Infallible>
pub fn wait(&mut self) -> Result<(), Infallible>
Return Ok if the timer has wrapped. Peripheral will automatically clear the
flag and restart the time if configured correctly
Sourcepub fn load(&mut self, timeout: impl Into<Hertz>)
pub fn load(&mut self, timeout: impl Into<Hertz>)
Load the count down timer with a timeout but do not start it.
pub fn set_reload(&mut self, val: u32)
pub fn set_count(&mut self, val: u32)
pub fn counter(&self) -> u32
Sourcepub fn auto_disable(&mut self, enable: bool)
pub fn auto_disable(&mut self, enable: bool)
Disable the counter, setting both enable and active bit to 0
Sourcepub fn auto_deactivate(&mut self, enable: bool)
pub fn auto_deactivate(&mut self, enable: bool)
This option only applies when the Auto-Disable functionality is 0.
The active bit is changed to 0 when count reaches 0, but the counter stays enabled. When Auto-Disable is 1, Auto-Deactivate is implied
Sourcepub fn cascade_control(&mut self, ctrl: CascadeControl)
pub fn cascade_control(&mut self, ctrl: CascadeControl)
Configure the cascade parameters
pub fn cascade_source( &mut self, cascade_index: CascadeSelect, src: CascadeSource, ) -> Result<(), InvalidCascadeSourceId>
pub fn curr_freq(&self) -> Hertz
Sourcepub fn stop_with_clock_disable(self)
pub fn stop_with_clock_disable(self)
Disables the TIM and the dedicated TIM clock.
Trait Implementations§
Source§impl DelayNs for CountdownTimer
impl DelayNs for CountdownTimer
Source§fn delay_ns(&mut self, ns: u32)
fn delay_ns(&mut self, ns: u32)
ns nanoseconds. Pause can be longer
if the implementation requires it due to precision/timing issues.