Struct Timer

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

Timer wrapper

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<P, PINS>(self, _pins: PINS, freq: Hertz) -> PwmHz<TIM, P, PINS>
where PINS: Pins<TIM, P>,

Source§

impl Timer<TIM1>

Source

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:

  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<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:

  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<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:

  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

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.

Source

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.

Source

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

Stops listening for an event

Source§

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

Source

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

Auto Trait Implementations§

§

impl<TIM> Freeze for Timer<TIM>
where TIM: Freeze,

§

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>,

Source§

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>,

Source§

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.