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: Peri<'d, T>,
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: Peri<'d, T>, 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.
The actual frequency may differ from the requested value due to hardware limitations. The timer will round towards a slower (longer) period.
Note: that the frequency will not be applied in the timer until an update event occurs.
Sourcepub fn get_frequency(&self) -> Hertz
pub fn get_frequency(&self) -> Hertz
Get the PWM driver frequency.
Sourcepub fn set_period_ms(&mut self, ms: u32)
pub fn set_period_ms(&mut self, ms: u32)
Set PWM period in milliseconds.
The actual period may differ from the requested value due to hardware limitations. The timer will round towards a slower (longer) period.
Note: that the period will not be applied in the timer until an update event occurs.
Sourcepub fn set_period_us(&mut self, us: u32)
pub fn set_period_us(&mut self, us: u32)
Set PWM period in microseconds.
The actual period may differ from the requested value due to hardware limitations. The timer will round towards a slower (longer) period.
Note: that the period will not be applied in the timer until an update event occurs.
Sourcepub fn set_period_secs(&mut self, secs: u32)
pub fn set_period_secs(&mut self, secs: u32)
Set PWM period in seconds.
The actual period may differ from the requested value due to hardware limitations. The timer will round towards a slower (longer) period.
Note: that the period will not be applied in the timer until an update event occurs.
Sourcepub fn set_period(&mut self, period: Duration)
pub fn set_period(&mut self, period: Duration)
Set PWM period using an embassy_time::Duration.
The actual period may differ from the requested value due to hardware limitations. The timer will round towards a slower (longer) period.
Note: that the period will not be applied in the timer until an update event occurs.
Sourcepub fn max_duty_cycle(&self) -> u32
pub fn max_duty_cycle(&self) -> u32
Get max duty value.
This value depends on the configured frequency and the timer’s clock rate from RCC.
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