Struct stm32f4xx_hal::timer::Timer
source · [−]pub struct Timer<TIM> { /* private fields */ }
Expand description
Timer wrapper
Implementations
sourceimpl Timer<SYST>
impl Timer<SYST>
sourcepub fn counter_hz(self) -> SysCounterHz
pub fn counter_hz(self) -> SysCounterHz
Creates SysCounterHz which takes Hertz as Duration
sourcepub fn counter<const FREQ: u32>(self) -> SysCounter<FREQ>
pub fn counter<const FREQ: u32>(self) -> SysCounter<FREQ>
Creates SysCounter with custom precision (core frequency recommended is known)
sourcepub fn counter_us(self) -> SysCounterUs
pub fn counter_us(self) -> SysCounterUs
Creates SysCounter 1 microsecond precision
sourceimpl Timer<TIM2>
impl Timer<TIM2>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM2, PINS> where
PINS: Pins<TIM2>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM2, PINS> where
PINS: Pins<TIM2>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM3>
impl Timer<TIM3>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM3, PINS> where
PINS: Pins<TIM3>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM3, PINS> where
PINS: Pins<TIM3>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM4>
impl Timer<TIM4>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM4, PINS> where
PINS: Pins<TIM4>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM4, PINS> where
PINS: Pins<TIM4>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM8>
impl Timer<TIM8>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM8, PINS> where
PINS: Pins<TIM8>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM8, PINS> where
PINS: Pins<TIM8>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM12>
impl Timer<TIM12>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM12, PINS> where
PINS: Pins<TIM12>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM12, PINS> where
PINS: Pins<TIM12>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM1>
impl Timer<TIM1>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM1, PINS> where
PINS: Pins<TIM1>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM1, PINS> where
PINS: Pins<TIM1>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM5>
impl Timer<TIM5>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM5, PINS> where
PINS: Pins<TIM5>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM5, PINS> where
PINS: Pins<TIM5>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<TIM9>
impl Timer<TIM9>
sourcepub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM9, PINS> where
PINS: Pins<TIM9>,
pub fn pwm_input<PINS>(
self,
best_guess: Hertz,
pins: PINS
) -> PwmInput<TIM9, PINS> where
PINS: Pins<TIM9>,
Configures this timer for PWM input. Accepts the best_guess
frequency of the signal
Note: this should be as close as possible to the frequency of the PWM waveform for best
accuracy.
This device will emit an interrupt on CC1, which occurs at two times in this mode:
- When a new cycle is started: the duty cycle will be
1.00
- When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
sourceimpl Timer<SYST>
impl Timer<SYST>
sourceimpl<TIM: Instance> Timer<TIM>
impl<TIM: Instance> Timer<TIM>
pub fn configure(&mut self, clocks: &Clocks)
pub fn counter_hz(self) -> CounterHz<TIM>
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.
sourceimpl<TIM: Instance + MasterTimer> Timer<TIM>
impl<TIM: Instance + MasterTimer> Timer<TIM>
pub fn set_master_mode(&mut self, mode: TIM::Mms)
Auto Trait Implementations
impl<TIM> RefUnwindSafe for Timer<TIM> where
TIM: RefUnwindSafe,
impl<TIM> Send for Timer<TIM> where
TIM: Send,
impl<TIM> Sync for Timer<TIM> where
TIM: Sync,
impl<TIM> Unpin for Timer<TIM> where
TIM: Unpin,
impl<TIM> UnwindSafe for Timer<TIM> where
TIM: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more