Struct stm32_hal2::timer::Timer[][src]

pub struct Timer<TIM> { /* fields omitted */ }

Hardware timers

Implementations

impl Timer<TIM1>[src]

pub fn new_tim1<T, C>(tim: TIM1, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM1[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM7>[src]

pub fn new_tim7<T, C>(tim: TIM7, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM7[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM2>[src]

pub fn new_tim2<T, C>(tim: TIM2, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM2[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM6>[src]

pub fn new_tim6<T, C>(tim: TIM6, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM6[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM16>[src]

pub fn new_tim16<T, C>(tim: TIM16, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM16[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM15>[src]

pub fn new_tim15<T, C>(tim: TIM15, freq: T, clocks: &C, rcc: &mut RCC) -> Self where
    T: Into<f32>,
    C: ClockCfg
[src]

Configures a TIM peripheral as a periodic count down timer

pub fn listen(&mut self, event: Event)[src]

Starts listening for an event. Used to enable interrupts.

pub fn enable(&mut self)[src]

Enable the timer.

pub fn disable(&mut self)[src]

Disable the timer.

pub fn is_enabled(&self) -> bool[src]

Check if the timer is enabled.

pub fn clear_interrupt(&mut self)[src]

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

pub fn unlisten(&mut self, event: Event)[src]

Stops listening for an xcevent. Used to disable interrupts.

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn free(self) -> TIM15[src]

Releases the TIM peripheral

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>[src]

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If you use center aligned PWM, make sure to enter twice the freq you normally would.

pub fn set_auto_reload(&mut self, arr: u32)[src]

Set the auto-reload register value. Used for adjusting frequency.

pub fn set_prescaler(&mut self, psc: u32)[src]

Set the prescaler value. Used for adjusting frequency.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM2>[src]

pub fn set_output_compare(&mut self, channel: Channel, mode: OutputCompare)[src]

Set Output Compare Mode. See docs on the OutputCompare enum.

pub fn get_duty(&self, channel: Channel) -> u32[src]

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

pub fn set_duty(&mut self, channel: Channel, duty: u32)[src]

Set the duty cycle, as a portion of get_max_duty().

pub fn get_max_duty(&self) -> u32[src]

Return the integer associated with the maximum duty period. todo: Duty could be u16 for low-precision timers.

pub fn set_alignment(&mut self, alignment: Alignment)[src]

Set timer alignment to Edge, or one of 3 center modes. STM32F303 ref man, section 21.4.1: Bits 6:5 CMS: Center-aligned mode selection 00: Edge-aligned mode. The counter counts up or down depending on the direction bit (DIR). 01: Center-aligned mode 1. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting down. 10: Center-aligned mode 2. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting up. 11: Center-aligned mode 3. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set both when the counter is counting up or down.

pub fn set_polarity(&mut self, channel: Channel, polarity: Polarity)[src]

Set output polarity. See docs on the Polarity enum.

pub fn set_complementary_polarity(
    &mut self,
    channel: Channel,
    polarity: Polarity
)
[src]

Set complementary output polarity. See docs on the Polarity enum.

pub fn disable_capture_compare(&mut self, channel: Channel)[src]

Disables capture compare on a specific channel.

pub fn enable_capture_compare(&mut self, channel: Channel)[src]

Enables capture compare on a specific channel.

pub fn set_capture_compare(&mut self, channel: Channel, mode: CaptureCompare)[src]

Set Capture Compare Mode. See docs on the CaptureCompare enum.

pub fn set_auto_reload_preload(&mut self, mode: bool)[src]

Set auto reload preloader; useful when changing period and duty mid-run.

pub fn set_preload(&mut self, channel: Channel, value: bool)[src]

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Trait Implementations

impl CountDown for Timer<TIM1>[src]

type Time = f32

The unit of time used by this timer

impl CountDown for Timer<TIM7>[src]

type Time = f32

The unit of time used by this timer

impl CountDown for Timer<TIM2>[src]

type Time = f32

The unit of time used by this timer

impl CountDown for Timer<TIM6>[src]

type Time = f32

The unit of time used by this timer

impl CountDown for Timer<TIM16>[src]

type Time = f32

The unit of time used by this timer

impl CountDown for Timer<TIM15>[src]

type Time = f32

The unit of time used by this timer

impl Periodic for Timer<TIM1>[src]

impl Periodic for Timer<TIM7>[src]

impl Periodic for Timer<TIM2>[src]

impl Periodic for Timer<TIM6>[src]

impl Periodic for Timer<TIM16>[src]

impl Periodic for Timer<TIM15>[src]

Auto Trait Implementations

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.