pub struct Pwm<'d, T: Instance> { /* private fields */ }
Expand description
PWM driver.
Implementations§
Source§impl<'d, T: Instance> Pwm<'d, T>
impl<'d, T: Instance> Pwm<'d, T>
Sourcepub fn new(
tim: impl Peripheral<P = T> + 'd,
_output_pin: PwmPin<'d, T, Output>,
freq: Hertz,
) -> Self
pub fn new( tim: impl Peripheral<P = T> + 'd, _output_pin: PwmPin<'d, T, Output>, freq: Hertz, ) -> Self
Create a new PWM driver.
Sourcepub fn set_duty(&mut self, duty: u16)
pub fn set_duty(&mut self, duty: u16)
Set the duty.
The value ranges from 0 for 0% duty, to get_max_duty
for 100% duty, both included.
Sourcepub fn get_duty(&self) -> u16
pub fn get_duty(&self) -> u16
Get the duty.
The value ranges from 0 for 0% duty, to get_max_duty
for 100% duty, both included.
Source§impl<'d, T: Instance> Pwm<'d, T>
impl<'d, T: Instance> Pwm<'d, T>
Sourcepub fn set_frequency(&mut self, frequency: Hertz)
pub fn set_frequency(&mut self, frequency: 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.
Auto Trait Implementations§
impl<'d, T> Freeze for Pwm<'d, T>where
T: Freeze,
impl<'d, T> RefUnwindSafe for Pwm<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for Pwm<'d, T>where
T: Send,
impl<'d, T> Sync for Pwm<'d, T>where
T: Sync,
impl<'d, T> Unpin for Pwm<'d, T>where
T: Unpin,
impl<'d, T> !UnwindSafe for Pwm<'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