Struct stm32f4xx_hal::timer::pwm::Pwm
source · pub struct Pwm<TIM, PINS, const FREQ: u32>{ /* private fields */ }
Implementations§
source§impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
sourcepub fn set_polarity(&mut self, channel: Channel, p: Polarity)
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
sourcepub fn get_duty(&self, channel: Channel) -> u16
pub fn get_duty(&self, channel: Channel) -> u16
Get the current duty cycle of the timer on channel channel
sourcepub fn get_duty_time(&self, channel: Channel) -> TimerDurationU32<FREQ>
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
sourcepub fn set_duty(&mut self, channel: Channel, duty: u16)
pub fn set_duty(&mut self, channel: Channel, duty: u16)
Set the duty cycle of the timer on channel channel
sourcepub fn set_duty_time(&mut self, channel: Channel, duty: TimerDurationU32<FREQ>)
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
sourcepub fn get_max_duty(&self) -> u16
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
sourcepub fn get_period(&self) -> TimerDurationU32<FREQ>
pub fn get_period(&self) -> TimerDurationU32<FREQ>
Get the PWM frequency of the timer as a duration
sourcepub fn set_period(&mut self, period: TimerDurationU32<FREQ>)
pub fn set_period(&mut self, period: TimerDurationU32<FREQ>)
Set the PWM frequency for the timer from a duration
sourcepub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity)
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>
impl<TIM, PINS, const FREQ: u32> Pwm<TIM, PINS, FREQ>
sourcepub fn enable_complementary(&mut self, channel: Channel)
pub fn enable_complementary(&mut self, channel: Channel)
Enable complementary PWM output of the timer on channel channel
sourcepub fn disable_complementary(&mut self, channel: Channel)
pub fn disable_complementary(&mut self, channel: Channel)
Disable complementary PWM output of the timer on channel channel
sourcepub fn set_dead_time(&mut self, dts_ticks: u16)
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.
sourcepub fn set_dead_time_bits(&mut self, bits: u8)
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
sourcepub fn get_dead_time(&self) -> u16
pub fn get_dead_time(&self) -> u16
Return dead time for complementary pins in the unit of DTS ticks
sourcepub fn get_dead_time_bits(&self) -> u8
pub fn get_dead_time_bits(&self) -> u8
Get raw dead time (DTG) bits
sourcepub fn set_idle_state(&mut self, channel: Channel, s: IdleState)
pub fn set_idle_state(&mut self, channel: Channel, s: IdleState)
Set the pin idle state
sourcepub fn set_complementary_idle_state(&mut self, channel: Channel, s: IdleState)
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>>§
pub fn set_master_mode(&mut self, mode: TIM::Mms)
Trait Implementations§
source§impl<TIM, PINS, const FREQ: u32> Pwm for Pwm<TIM, PINS, FREQ>
impl<TIM, PINS, const FREQ: u32> Pwm for Pwm<TIM, PINS, FREQ>
source§fn get_max_duty(&self) -> Self::Duty
fn get_max_duty(&self) -> Self::Duty
If 0
returned means max_duty is 2^16