[][src]Struct stm32f3xx_hal_v2::timer::Timer

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

Hardware timers

Implementations

impl Timer<TIM1>[src]

pub fn tim1<T>(tim: TIM1, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM2>[src]

pub fn tim2<T>(tim: TIM2, timeout: T, clocks: Clocks, apb1: &mut APB1) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM3>[src]

pub fn tim3<T>(tim: TIM3, timeout: T, clocks: Clocks, apb1: &mut APB1) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn release(self) -> TIM3[src]

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM4>[src]

pub fn tim4<T>(tim: TIM4, timeout: T, clocks: Clocks, apb1: &mut APB1) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn release(self) -> TIM4[src]

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM6>[src]

pub fn tim6<T>(tim: TIM6, timeout: T, clocks: Clocks, apb1: &mut APB1) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM7>[src]

pub fn tim7<T>(tim: TIM7, timeout: T, clocks: Clocks, apb1: &mut APB1) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM8>[src]

pub fn tim8<T>(tim: TIM8, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn release(self) -> TIM8[src]

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM15>[src]

pub fn tim15<T>(tim: TIM15, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM16>[src]

pub fn tim16<T>(tim: TIM16, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

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

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM17>[src]

pub fn tim17<T>(tim: TIM17, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn release(self) -> TIM17[src]

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM20>[src]

pub fn tim20<T>(tim: TIM20, timeout: T, clocks: Clocks, apb2: &mut APB2) -> Self where
    T: Into<Hertz>, 
[src]

Configures a TIM peripheral as a periodic count down timer

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

Starts listening for an event

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

Stops listening for an event

pub fn stop(&mut self)[src]

Stops the timer

pub fn clear_update_interrupt_flag(&mut self)[src]

Clears Update Interrupt Flag

pub fn release(self) -> TIM20[src]

Releases the TIM peripheral

pub fn set_period(
    &mut self,
    period: f32,
    clocks: &Clocks
) -> Result<(), ValueError>
[src]

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. This allows you to set periods greater than 1hz.

pub fn reset_countdown(&mut self)[src]

Reset the countdown; set the counter to 0.

impl Timer<TIM2>[src]

pub fn set_resolution(&mut self, word: u32)[src]

Set the value of the auto-reload resolution. Use a lower value to increase precision. If you wish for a precise tick speed, multiply the system clock speed by the desired frequency, then round to the nearest integer.

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(&mut self, channel: Channel)[src]

Disables the timer.

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

Enables the timer.

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_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.

impl Timer<TIM3>[src]

pub fn set_resolution(&mut self, word: u16)[src]

Set the value of the auto-reload resolution. Use a lower value to increase precision. If you wish for a precise tick speed, multiply the system clock speed by the desired frequency, then round to the nearest integer.

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) -> u16[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: u16)[src]

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

pub fn get_max_duty(&self) -> u16[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(&mut self, channel: Channel)[src]

Disables the timer.

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

Enables the timer.

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_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.

impl Timer<TIM4>[src]

pub fn set_resolution(&mut self, word: u16)[src]

Set the value of the auto-reload resolution. Use a lower value to increase precision. If you wish for a precise tick speed, multiply the system clock speed by the desired frequency, then round to the nearest integer.

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) -> u16[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: u16)[src]

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

pub fn get_max_duty(&self) -> u16[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(&mut self, channel: Channel)[src]

Disables the timer.

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

Enables the timer.

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_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 = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM2>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM20>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM3>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM4>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM6>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM7>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM8>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM15>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM16>[src]

type Time = Hertz

The unit of time used by this timer

impl CountDown for Timer<TIM17>[src]

type Time = Hertz

The unit of time used by this timer

impl Periodic for Timer<TIM1>[src]

impl Periodic for Timer<TIM2>[src]

impl Periodic for Timer<TIM20>[src]

impl Periodic for Timer<TIM3>[src]

impl Periodic for Timer<TIM4>[src]

impl Periodic for Timer<TIM6>[src]

impl Periodic for Timer<TIM7>[src]

impl Periodic for Timer<TIM8>[src]

impl Periodic for Timer<TIM15>[src]

impl Periodic for Timer<TIM16>[src]

impl Periodic for Timer<TIM17>[src]

Auto Trait Implementations

impl<TIM> Send for Timer<TIM> where
    TIM: Send
[src]

impl<TIM> Sync for Timer<TIM> where
    TIM: Sync
[src]

impl<TIM> Unpin for Timer<TIM> where
    TIM: Unpin
[src]

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.