pub struct Timer<TIM> { /* private fields */ }Expand description
Timer wrapper
Implementations§
Source§impl<TIM: Instance + Steal> Timer<TIM>
impl<TIM: Instance + Steal> Timer<TIM>
Sourcepub fn counter<const FREQ: u32>(self) -> Counter<TIM, FREQ>
pub fn counter<const FREQ: u32>(self) -> Counter<TIM, FREQ>
Non-blocking Counter with custom fixed precision
Sourcepub fn counter_ms(self) -> CounterMs<TIM>
pub fn counter_ms(self) -> CounterMs<TIM>
Non-blocking Counter with fixed precision of 1 ms (1 kHz sampling)
Can wait from 2 ms to 65 sec for 16-bit timer and from 2 ms to 49 days for 32-bit timer.
NOTE: don’t use this if your system frequency more than 65 MHz
Sourcepub fn counter_us(self) -> CounterUs<TIM>
pub fn counter_us(self) -> CounterUs<TIM>
Non-blocking Counter with fixed precision of 1 μs (1 MHz sampling)
Can wait from 2 μs to 65 ms for 16-bit timer and from 2 μs to 71 min for 32-bit timer.
Sourcepub fn counter_hz(self) -> CounterHz<TIM>
pub fn counter_hz(self) -> CounterHz<TIM>
Non-blocking Counter with dynamic precision which uses Hertz as Duration units
Sourcepub fn delay<const FREQ: u32>(self) -> Delay<TIM, FREQ>
pub fn delay<const FREQ: u32>(self) -> Delay<TIM, FREQ>
Blocking Delay with custom fixed precision
Sourcepub fn delay_ms(self) -> DelayMs<TIM>
pub fn delay_ms(self) -> DelayMs<TIM>
Blocking Delay with fixed precision of 1 ms (1 kHz sampling)
Can wait from 2 ms to 49 days.
NOTE: don’t use this if your system frequency more than 65 MHz
Sourcepub fn delay_us(self) -> DelayUs<TIM>
pub fn delay_us(self) -> DelayUs<TIM>
Blocking Delay with fixed precision of 1 μs (1 MHz sampling)
Can wait from 2 μs to 71 min.
pub fn release(self) -> TIM
Sourcepub fn listen(&mut self, event: Event)
pub fn listen(&mut self, event: Event)
Starts listening for an event
Note, you will also have to enable the TIM2 interrupt in the NVIC to start receiving events.
Sourcepub fn clear_interrupt(&mut self, event: Event)
pub fn clear_interrupt(&mut self, event: Event)
Clears interrupt associated with event.
If the interrupt is not cleared, it will immediately retrigger after the ISR has finished.
pub fn get_interrupt(&mut self) -> Event
Sourcepub fn stop_in_debug(&mut self, state: bool)
pub fn stop_in_debug(&mut self, state: bool)
Stopping timer in debug mode can cause troubles when sampling the signal