pub struct SimplePwm<'d> { /* private fields */ }Expand description
SimplePwm is the traditional pwm interface you’re probably used to, allowing to simply set a duty cycle across up to four channels.
Implementations§
Source§impl<'d> SimplePwm<'d>
impl<'d> SimplePwm<'d>
Sourcepub fn new_1ch<T: Instance>(
pwm: Peri<'d, T>,
ch0: Peri<'d, impl GpioPin>,
config: &SimpleConfig,
) -> Self
pub fn new_1ch<T: Instance>( pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, config: &SimpleConfig, ) -> Self
Create a new 1-channel PWM
Sourcepub fn new_2ch<T: Instance>(
pwm: Peri<'d, T>,
ch0: Peri<'d, impl GpioPin>,
ch1: Peri<'d, impl GpioPin>,
config: &SimpleConfig,
) -> Self
pub fn new_2ch<T: Instance>( pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, ch1: Peri<'d, impl GpioPin>, config: &SimpleConfig, ) -> Self
Create a new 2-channel PWM
Sourcepub fn new_3ch<T: Instance>(
pwm: Peri<'d, T>,
ch0: Peri<'d, impl GpioPin>,
ch1: Peri<'d, impl GpioPin>,
ch2: Peri<'d, impl GpioPin>,
config: &SimpleConfig,
) -> Self
pub fn new_3ch<T: Instance>( pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, ch1: Peri<'d, impl GpioPin>, ch2: Peri<'d, impl GpioPin>, config: &SimpleConfig, ) -> Self
Create a new 3-channel PWM
Sourcepub fn new_4ch<T: Instance>(
pwm: Peri<'d, T>,
ch0: Peri<'d, impl GpioPin>,
ch1: Peri<'d, impl GpioPin>,
ch2: Peri<'d, impl GpioPin>,
ch3: Peri<'d, impl GpioPin>,
config: &SimpleConfig,
) -> Self
pub fn new_4ch<T: Instance>( pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, ch1: Peri<'d, impl GpioPin>, ch2: Peri<'d, impl GpioPin>, ch3: Peri<'d, impl GpioPin>, config: &SimpleConfig, ) -> Self
Create a new 4-channel PWM
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns the enable state of the pwm counter
Sourcepub fn disable(&self)
pub fn disable(&self)
Disables the PWM generator. Does NOT clear the last duty cycle from the pin.
Sourcepub fn set_duty(&mut self, channel: usize, duty: DutyCycle)
pub fn set_duty(&mut self, channel: usize, duty: DutyCycle)
Sets duty cycle (15 bit) and polarity for a PWM channel.
Sourcepub fn set_all_duties(&mut self, duty: [DutyCycle; 4])
pub fn set_all_duties(&mut self, duty: [DutyCycle; 4])
Sets the duty cycle (15 bit) and polarity for all PWM channels.
You can safely set the duty cycle of disabled PWM channels.
When using this function, a single DMA transfer sets all the duty cycles.
If you call Self::set_duty() multiple times,
each duty cycle will be set by a separate DMA transfer.
Sourcepub fn set_prescaler(&self, div: Prescaler)
pub fn set_prescaler(&self, div: Prescaler)
Sets the PWM clock prescaler.
Sourcepub fn set_max_duty(&self, duty: u16)
pub fn set_max_duty(&self, duty: u16)
Sets the maximum duty cycle value.
Sourcepub fn set_period(&self, freq: u32)
pub fn set_period(&self, freq: u32)
Sets the PWM output frequency.
Sourcepub fn set_ch0_drive(&self, drive: OutputDrive)
pub fn set_ch0_drive(&self, drive: OutputDrive)
Sets the PWM-Channel0 output drive strength
Sourcepub fn set_ch1_drive(&self, drive: OutputDrive)
pub fn set_ch1_drive(&self, drive: OutputDrive)
Sets the PWM-Channel1 output drive strength
Sourcepub fn set_ch2_drive(&self, drive: OutputDrive)
pub fn set_ch2_drive(&self, drive: OutputDrive)
Sets the PWM-Channel2 output drive strength
Sourcepub fn set_ch3_drive(&self, drive: OutputDrive)
pub fn set_ch3_drive(&self, drive: OutputDrive)
Sets the PWM-Channel3 output drive strength