Struct embassy_stm32::timer::complementary_pwm::ComplementaryPwm
source · pub struct ComplementaryPwm<'d, T> { /* private fields */ }
Expand description
PWM driver with support for standard and complementary outputs.
Implementations§
source§impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T>
impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T>
sourcepub fn new(
tim: impl Peripheral<P = T> + 'd,
_ch1: Option<PwmPin<'d, T, Ch1>>,
_ch1n: Option<ComplementaryPwmPin<'d, T, Ch1>>,
_ch2: Option<PwmPin<'d, T, Ch2>>,
_ch2n: Option<ComplementaryPwmPin<'d, T, Ch2>>,
_ch3: Option<PwmPin<'d, T, Ch3>>,
_ch3n: Option<ComplementaryPwmPin<'d, T, Ch3>>,
_ch4: Option<PwmPin<'d, T, Ch4>>,
_ch4n: Option<ComplementaryPwmPin<'d, T, Ch4>>,
freq: Hertz,
counting_mode: CountingMode
) -> Self
pub fn new( tim: impl Peripheral<P = T> + 'd, _ch1: Option<PwmPin<'d, T, Ch1>>, _ch1n: Option<ComplementaryPwmPin<'d, T, Ch1>>, _ch2: Option<PwmPin<'d, T, Ch2>>, _ch2n: Option<ComplementaryPwmPin<'d, T, Ch2>>, _ch3: Option<PwmPin<'d, T, Ch3>>, _ch3n: Option<ComplementaryPwmPin<'d, T, Ch3>>, _ch4: Option<PwmPin<'d, T, Ch4>>, _ch4n: Option<ComplementaryPwmPin<'d, T, Ch4>>, freq: Hertz, counting_mode: CountingMode ) -> Self
Create a new complementary PWM driver.
sourcepub fn set_frequency(&mut self, freq: Hertz)
pub fn set_frequency(&mut self, freq: Hertz)
Set PWM frequency.
Note: when you call this, the max duty value changes, so you will have to
call set_duty
on all channels with the duty calculated based on the new max duty.
sourcepub fn get_max_duty(&self) -> u16
pub fn get_max_duty(&self) -> u16
Get max duty value.
This value depends on the configured frequency and the timer’s clock rate from RCC.
sourcepub fn set_duty(&mut self, channel: Channel, duty: u16)
pub fn set_duty(&mut self, channel: Channel, duty: u16)
Set the duty for a given channel.
The value ranges from 0 for 0% duty, to get_max_duty
for 100% duty, both included.
sourcepub fn set_polarity(&mut self, channel: Channel, polarity: OutputPolarity)
pub fn set_polarity(&mut self, channel: Channel, polarity: OutputPolarity)
Set the output polarity for a given channel.
sourcepub fn set_dead_time(&mut self, value: u16)
pub fn set_dead_time(&mut self, value: u16)
Set the dead time as a proportion of max_duty
Trait Implementations§
source§impl<'d, T: ComplementaryCaptureCompare16bitInstance> Pwm for ComplementaryPwm<'d, T>
impl<'d, T: ComplementaryCaptureCompare16bitInstance> Pwm for ComplementaryPwm<'d, T>
source§fn get_period(&self) -> Self::Time
fn get_period(&self) -> Self::Time
Returns the current PWM period
source§fn get_max_duty(&self) -> Self::Duty
fn get_max_duty(&self) -> Self::Duty
Returns the maximum duty cycle value
source§fn set_period<P>(&mut self, period: P)
fn set_period<P>(&mut self, period: P)
Sets a new PWM period
Auto Trait Implementations§
impl<'d, T> RefUnwindSafe for ComplementaryPwm<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for ComplementaryPwm<'d, T>where
T: Send,
impl<'d, T> Sync for ComplementaryPwm<'d, T>where
T: Sync,
impl<'d, T> Unpin for ComplementaryPwm<'d, T>where
T: Unpin,
impl<'d, T> !UnwindSafe for ComplementaryPwm<'d, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more