Struct Timer

Source
pub struct Timer<const TIM: u8, PWM> { /* private fields */ }
Available on crate feature unstable only.
Expand description

A MCPWM timer

Every timer of a particular MCPWM peripheral can be used as a timing reference for every Operator of that peripheral

Implementations§

Source§

impl<const TIM: u8, PWM: PwmPeripheral> Timer<TIM, PWM>

Source

pub fn start(&mut self, timer_config: TimerClockConfig)

Apply the given timer configuration.

§Note:

The prescaler and period configuration will be applied immediately by default and before setting the PwmWorkingMode. If the timer is already running you might want to call Timer::stop and/or Timer::set_counter first (if the new period is larger than the current counter value this will cause weird behavior).

If configured via TimerClockConfig::with_period_updating_method, another behavior can be applied. Currently, only PeriodUpdatingMethod::Immediately and PeriodUpdatingMethod::TimerEqualsZero are useful as the sync method is not yet implemented.

The hardware supports writing these settings in sync with certain timer events but this HAL does not expose these for now.

Source

pub fn stop(&mut self)

Stop the timer in its current state

Source

pub fn set_counter(&mut self, phase: u16, direction: CounterDirection)

Set the timer counter to the provided value

Source

pub fn status(&self) -> (u16, CounterDirection)

Read the counter value and counter direction of the timer

Auto Trait Implementations§

§

impl<const TIM: u8, PWM> Freeze for Timer<TIM, PWM>

§

impl<const TIM: u8, PWM> RefUnwindSafe for Timer<TIM, PWM>
where PWM: RefUnwindSafe,

§

impl<const TIM: u8, PWM> Send for Timer<TIM, PWM>
where PWM: Send,

§

impl<const TIM: u8, PWM> Sync for Timer<TIM, PWM>
where PWM: Sync,

§

impl<const TIM: u8, PWM> Unpin for Timer<TIM, PWM>
where PWM: Unpin,

§

impl<const TIM: u8, PWM> UnwindSafe for Timer<TIM, PWM>
where PWM: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.