Struct esp32_hal::mcpwm::timer::Timer

source ·
pub struct Timer<const TIM: u8, PWM> { /* private fields */ }
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> Timer<TIM, PWM>
where PWM: PwmPeripheral,

source

pub fn start(&mut self, timer_config: TimerClockConfig<'_>)

Apply the given timer configuration.

§Note:

The prescaler and period configuration will be applied immediately 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).

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

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.