pub struct Pwm<const FREQ: u32> { /* private fields */ }
Implementations§
source§impl<const FREQ: u32> Pwm<FREQ>
impl<const FREQ: u32> Pwm<FREQ>
sourcepub fn new(ch: PwmChannel) -> Self
pub fn new(ch: PwmChannel) -> Self
sourcepub fn set_polarity(&self, p: PwmPolarity)
pub fn set_polarity(&self, p: PwmPolarity)
Sets the polarity of the PWM output on the specified channel.
§Arguments
p
- The polarity to set (ActiveHigh
orActiveLow
).
sourcepub fn get_duty(&self) -> u16
pub fn get_duty(&self) -> u16
Retrieves the current duty cycle of the PWM output on the specified channel.
§Returns
The current duty cycle as a u16
.
sourcepub fn get_duty_time(&self) -> TimerDurationU32<FREQ>
pub fn get_duty_time(&self) -> TimerDurationU32<FREQ>
Retrieves the current duty cycle of the PWM output on the specified channel and converts it to a duration.
§Returns
The current duty cycle as a TimerDurationU32
.
sourcepub fn set_duty(&self, duty: u16)
pub fn set_duty(&self, duty: u16)
Sets the duty cycle of the PWM output on the specified channel.
§Arguments
duty
- The duty cycle to set.
sourcepub fn set_duty_time(&self, duty: TimerDurationU32<FREQ>)
pub fn set_duty_time(&self, duty: TimerDurationU32<FREQ>)
Sets the duty cycle of the PWM output on the specified channel from a duration.
§Arguments
duty
- The duty cycle duration.
sourcepub fn get_max_duty(&self) -> u16
pub fn get_max_duty(&self) -> u16
Retrieves the maximum duty cycle value of the PWM output.
§Returns
The maximum duty cycle as a u16
. If 0
is returned, it means the max duty cycle is 2^16
.
sourcepub fn get_period(&self) -> TimerDurationU32<FREQ>
pub fn get_period(&self) -> TimerDurationU32<FREQ>
Retrieves the current period of the PWM output as a duration.
§Returns
The current period as a TimerDurationU32
.
sourcepub fn set_period(&self, period: TimerDurationU32<FREQ>)
pub fn set_period(&self, period: TimerDurationU32<FREQ>)
Sets the PWM frequency for the PWM output from a duration.
§Arguments
period
- The desired period as aTimerDurationU32
.
Trait Implementations§
source§impl<const FREQ: u32> SetDutyCycle for Pwm<FREQ>
impl<const FREQ: u32> SetDutyCycle for Pwm<FREQ>
source§fn max_duty_cycle(&self) -> u16
fn max_duty_cycle(&self) -> u16
source§fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>
duty / max_duty
. Read moresource§fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>
source§fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>
Auto Trait Implementations§
impl<const FREQ: u32> Freeze for Pwm<FREQ>
impl<const FREQ: u32> RefUnwindSafe for Pwm<FREQ>
impl<const FREQ: u32> Send for Pwm<FREQ>
impl<const FREQ: u32> Sync for Pwm<FREQ>
impl<const FREQ: u32> Unpin for Pwm<FREQ>
impl<const FREQ: u32> UnwindSafe for Pwm<FREQ>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)