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 more