Struct stm32f4xx_hal::timer::Timer

source ·
pub struct Timer<TIM> { /* private fields */ }
Expand description

Timer wrapper.

This wrapper can be used both for the system timer (SYST) or the general-purpose timers (TIMx).

Note: If you want to use the timer to sleep a certain amount of time, use Delay.

Implementations§

source§

impl Timer<SYST>

source

pub fn counter_hz(self) -> SysCounterHz

Creates SysCounterHz which takes Hertz as Duration

source

pub fn counter<const FREQ: u32>(self) -> SysCounter<FREQ>

Creates SysCounter with custom precision (core frequency recommended is known)

source

pub fn counter_us(self) -> SysCounterUs

Creates SysCounter 1 microsecond precision

source§

impl Timer<SYST>

source

pub fn delay(self) -> SysDelay

source§

impl<TIM: Instance + WithPwm> Timer<TIM>

source

pub fn pwm_hz<PINS>(self, _pins: PINS, freq: Hertz) -> PwmHz<TIM, PINS>
where PINS: Pins<TIM>,

source§

impl Timer<TIM1>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM1 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM2>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM2 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM3>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM3 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM4>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM4 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM5>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM5 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM8>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM8 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM9>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM9 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<TIM12>

source

pub fn pwm_input( self, best_guess: Hertz, pins: impl Into<<TIM12 as CPin<0>>::Ch<PushPull>> ) -> PwmInput<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:

  1. When a new cycle is started: the duty cycle will be 1.00
  2. When the period is captured. the duty cycle will be an observable value. See the pwm input example for an suitable interrupt handler.
source§

impl Timer<SYST>

source

pub fn syst(tim: SYST, clocks: &Clocks) -> Self

Initialize SysTick timer

source

pub fn syst_external(tim: SYST, clocks: &Clocks) -> Self

Initialize SysTick timer and set it frequency to HCLK / 8

source

pub fn configure(&mut self, clocks: &Clocks)

source

pub fn configure_external(&mut self, clocks: &Clocks)

source

pub fn release(self) -> SYST

source

pub fn listen(&mut self, event: SysEvent)

Starts listening for an event

source

pub fn unlisten(&mut self, event: SysEvent)

Stops listening for an event

source§

impl<TIM: Instance> Timer<TIM>

source

pub fn new(tim: TIM, clocks: &Clocks) -> Self

Initialize timer

source

pub fn configure(&mut self, clocks: &Clocks)

source

pub fn counter_hz(self) -> CounterHz<TIM>

source

pub fn release(self) -> TIM

source§

impl<TIM: Instance + MasterTimer> Timer<TIM>

source

pub fn set_master_mode(&mut self, mode: TIM::Mms)

Trait Implementations§

source§

impl<TIM: Instance> ClearFlags for Timer<TIM>

§

type Flag = Flag

Enum of manually clearable flags
source§

fn clear_flags(&mut self, event: impl Into<BitFlags<Flag>>)

Clear interrupts flags with Self::Flagss Read more
source§

fn clear_all_flags(&mut self)

Clears all interrupts flags
source§

impl<TIM: Instance> Listen for Timer<TIM>

§

type Event = Event

Enum of bit flags associated with events
source§

fn listen(&mut self, event: impl Into<BitFlags<Event>>)

Start listening for Events Read more
source§

fn listen_only(&mut self, event: impl Into<BitFlags<Event>>)

Start listening for Events, stop all other Read more
source§

fn unlisten(&mut self, event: impl Into<BitFlags<Event>>)

Stop listening for Events
source§

fn listen_all(&mut self)

Start listening all Events
source§

fn unlisten_all(&mut self)

Stop listening all Events
source§

impl<TIM: Instance> ReadFlags for Timer<TIM>

§

type Flag = Flag

Enum of bit flags
source§

fn flags(&self) -> BitFlags<Flag>

Get all interrupts flags a once.

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.