Struct stm32f4xx_hal::timer::pwm::Pwm

source ·
pub struct Pwm<TIM, PINS, const FREQ: u32>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,
{ /* private fields */ }

Implementations§

source§

impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,

source

pub fn split(self) -> PINS::Channels

source

pub fn release(self) -> FTimer<TIM, FREQ>

source§

impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,

source

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

Enable PWM output of the timer on channel channel

source

pub fn disable(&mut self, channel: Channel)

Disable PWM output of the timer on channel channel

source

pub fn set_polarity(&mut self, channel: Channel, p: Polarity)

Set the polarity of the active state for the primary PWM output of the timer on channel channel

source

pub fn get_duty(&self, channel: Channel) -> u16

Get the current duty cycle of the timer on channel channel

source

pub fn get_duty_time(&self, channel: Channel) -> TimerDurationU32<FREQ>

Get the current duty cycle of the timer on channel channel and convert to a duration

source

pub fn set_duty(&mut self, channel: Channel, duty: u16)

Set the duty cycle of the timer on channel channel

source

pub fn set_duty_time(&mut self, channel: Channel, duty: TimerDurationU32<FREQ>)

Set the duty cycle of the timer on channel channel from a duration

source

pub fn get_max_duty(&self) -> u16

Get the maximum duty cycle value of the timer

If 0 returned means max_duty is 2^16

source

pub fn get_period(&self) -> TimerDurationU32<FREQ>

Get the PWM frequency of the timer as a duration

source

pub fn set_period(&mut self, period: TimerDurationU32<FREQ>)

Set the PWM frequency for the timer from a duration

source

pub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity)

Set the polarity of the active state for the complementary PWM output of the advanced timer on channel channel

source§

impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm + Advanced, PINS: Pins<TIM>,

source

pub fn enable_complementary(&mut self, channel: Channel)

Enable complementary PWM output of the timer on channel channel

source

pub fn disable_complementary(&mut self, channel: Channel)

Disable complementary PWM output of the timer on channel channel

source

pub fn set_dead_time(&mut self, dts_ticks: u16)

Set number DTS ticks during that the primary and complementary PWM pins are simultaneously forced to their inactive states ( see Polarity setting ) when changing PWM state. This duration when both channels are in an ‘off’ state is called ‘dead time’.

This is necessary in applications like motor control or power converters to prevent the destruction of the switching elements by short circuit in the moment of switching.

source

pub fn set_dead_time_bits(&mut self, bits: u8)

Set raw dead time (DTG) bits

The dead time generation is nonlinear and constrained by the DTS tick duration. DTG register configuration and calculation of the actual resulting dead time is described in the application note RM0368 from ST Microelectronics

source

pub fn get_dead_time(&self) -> u16

Return dead time for complementary pins in the unit of DTS ticks

source

pub fn get_dead_time_bits(&self) -> u8

Get raw dead time (DTG) bits

source

pub fn set_idle_state(&mut self, channel: Channel, s: IdleState)

Set the pin idle state

source

pub fn set_complementary_idle_state(&mut self, channel: Channel, s: IdleState)

Set the complementary pin idle state

Methods from Deref<Target = FTimer<TIM, FREQ>>§

source

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

Calculate prescaler depending on Clocks state

source

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

Trait Implementations§

source§

impl<TIM, PINS, const FREQ: u32> Deref for Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,

§

type Target = FTimer<TIM, FREQ>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<TIM, PINS, const FREQ: u32> DerefMut for Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<TIM, PINS, const FREQ: u32> Pwm for Pwm<TIM, PINS, FREQ>
where TIM: Instance + WithPwm, PINS: Pins<TIM>,

source§

fn get_max_duty(&self) -> Self::Duty

If 0 returned means max_duty is 2^16

§

type Channel = Channel

Enumeration of channels that can be used with this Pwm interface Read more
§

type Duty = u16

Type for the duty methods Read more
§

type Time = Duration<u32, 1, FREQ>

A time unit that can be converted into a human time unit (e.g. seconds)
source§

fn enable(&mut self, channel: Self::Channel)

Enables a PWM channel
source§

fn disable(&mut self, channel: Self::Channel)

Disables a PWM channel
source§

fn get_duty(&self, channel: Self::Channel) -> Self::Duty

Returns the current duty cycle
source§

fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty)

Sets a new duty cycle
source§

fn get_period(&self) -> Self::Time

Returns the current PWM period
source§

fn set_period<T>(&mut self, period: T)
where T: Into<Self::Time>,

Sets a new PWM period

Auto Trait Implementations§

§

impl<TIM, PINS, const FREQ: u32> RefUnwindSafe for Pwm<TIM, PINS, FREQ>
where PINS: RefUnwindSafe, TIM: RefUnwindSafe,

§

impl<TIM, PINS, const FREQ: u32> Send for Pwm<TIM, PINS, FREQ>
where PINS: Send, TIM: Send,

§

impl<TIM, PINS, const FREQ: u32> Sync for Pwm<TIM, PINS, FREQ>
where PINS: Sync, TIM: Sync,

§

impl<TIM, PINS, const FREQ: u32> Unpin for Pwm<TIM, PINS, FREQ>
where PINS: Unpin, TIM: Unpin,

§

impl<TIM, PINS, const FREQ: u32> UnwindSafe for Pwm<TIM, PINS, FREQ>
where PINS: UnwindSafe, 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.