pub struct SimplePwm<'d, T: GeneralInstance4Channel> { /* private fields */ }
Expand description
Simple PWM driver.
Implementations§
source§impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
sourcepub fn new(
tim: impl Peripheral<P = T> + 'd,
_ch1: Option<PwmPin<'d, T, Ch1>>,
_ch2: Option<PwmPin<'d, T, Ch2>>,
_ch3: Option<PwmPin<'d, T, Ch3>>,
_ch4: Option<PwmPin<'d, T, Ch4>>,
freq: Hertz,
counting_mode: CountingMode,
) -> Self
pub fn new( tim: impl Peripheral<P = T> + 'd, _ch1: Option<PwmPin<'d, T, Ch1>>, _ch2: Option<PwmPin<'d, T, Ch2>>, _ch3: Option<PwmPin<'d, T, Ch3>>, _ch4: Option<PwmPin<'d, T, Ch4>>, freq: Hertz, counting_mode: CountingMode, ) -> Self
Create a new simple PWM driver.
sourcepub fn channel(&mut self, channel: Channel) -> SimplePwmChannel<'_, T>
pub fn channel(&mut self, channel: Channel) -> SimplePwmChannel<'_, T>
Get a single channel
If you need to use multiple channels, use Self::split
.
sourcepub fn ch1(&mut self) -> SimplePwmChannel<'_, T>
pub fn ch1(&mut self) -> SimplePwmChannel<'_, T>
Channel 1
This is just a convenience wrapper around Self::channel
.
If you need to use multiple channels, use Self::split
.
sourcepub fn ch2(&mut self) -> SimplePwmChannel<'_, T>
pub fn ch2(&mut self) -> SimplePwmChannel<'_, T>
Channel 2
This is just a convenience wrapper around Self::channel
.
If you need to use multiple channels, use Self::split
.
sourcepub fn ch3(&mut self) -> SimplePwmChannel<'_, T>
pub fn ch3(&mut self) -> SimplePwmChannel<'_, T>
Channel 3
This is just a convenience wrapper around Self::channel
.
If you need to use multiple channels, use Self::split
.
sourcepub fn ch4(&mut self) -> SimplePwmChannel<'_, T>
pub fn ch4(&mut self) -> SimplePwmChannel<'_, T>
Channel 4
This is just a convenience wrapper around Self::channel
.
If you need to use multiple channels, use Self::split
.
sourcepub fn split(self) -> SimplePwmChannels<'static, T>where
'd: 'static,
pub fn split(self) -> SimplePwmChannels<'static, T>where
'd: 'static,
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 max_duty_cycle(&self) -> u16
pub fn max_duty_cycle(&self) -> u16
Get max duty value.
This value depends on the configured frequency and the timer’s clock rate from RCC.
sourcepub async fn waveform_up(
&mut self,
dma: impl Peripheral<P = impl UpDma<T>>,
channel: Channel,
duty: &[u16],
)
pub async fn waveform_up( &mut self, dma: impl Peripheral<P = impl UpDma<T>>, channel: Channel, duty: &[u16], )
Generate a sequence of PWM waveform
Note:
you will need to provide corresponding TIMx_UP DMA channel to use this method.
source§impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
sourcepub async fn waveform_ch1(
&mut self,
dma: impl Peripheral<P = impl Ch1Dma<T>>,
duty: &[u16],
)
pub async fn waveform_ch1( &mut self, dma: impl Peripheral<P = impl Ch1Dma<T>>, duty: &[u16], )
Generate a sequence of PWM waveform
Note: you will need to provide corresponding TIMx_CHy DMA channel to use this method.
source§impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
sourcepub async fn waveform_ch2(
&mut self,
dma: impl Peripheral<P = impl Ch2Dma<T>>,
duty: &[u16],
)
pub async fn waveform_ch2( &mut self, dma: impl Peripheral<P = impl Ch2Dma<T>>, duty: &[u16], )
Generate a sequence of PWM waveform
Note: you will need to provide corresponding TIMx_CHy DMA channel to use this method.
source§impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
sourcepub async fn waveform_ch3(
&mut self,
dma: impl Peripheral<P = impl Ch3Dma<T>>,
duty: &[u16],
)
pub async fn waveform_ch3( &mut self, dma: impl Peripheral<P = impl Ch3Dma<T>>, duty: &[u16], )
Generate a sequence of PWM waveform
Note: you will need to provide corresponding TIMx_CHy DMA channel to use this method.
source§impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T>
sourcepub async fn waveform_ch4(
&mut self,
dma: impl Peripheral<P = impl Ch4Dma<T>>,
duty: &[u16],
)
pub async fn waveform_ch4( &mut self, dma: impl Peripheral<P = impl Ch4Dma<T>>, duty: &[u16], )
Generate a sequence of PWM waveform
Note: you will need to provide corresponding TIMx_CHy DMA channel to use this method.
Trait Implementations§
source§impl<'d, T: GeneralInstance4Channel> Pwm for SimplePwm<'d, T>
impl<'d, T: GeneralInstance4Channel> Pwm for SimplePwm<'d, T>
source§type Channel = Channel
type Channel = Channel
Pwm
interface Read more