embassy-rp

Crates

git

Versions

rp235xb

Flavors

embassy_rp::pwm

Trait SetDutyCycle

Source
pub trait SetDutyCycle: ErrorType {
    // Required methods
    fn max_duty_cycle(&self) -> u16;
    fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>;

    // Provided methods
    fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error> { ... }
    fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error> { ... }
    fn set_duty_cycle_fraction(
        &mut self,
        num: u16,
        denom: u16,
    ) -> Result<(), Self::Error> { ... }
    fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error> { ... }
}
Expand description

Single PWM channel / pin.

Required Methods§

Source

fn max_duty_cycle(&self) -> u16

Get the maximum duty cycle value.

This value corresponds to a 100% duty cycle.

Source

fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>

Set the duty cycle to duty / max_duty.

The caller is responsible for ensuring that the duty cycle value is less than or equal to the maximum duty cycle value, as reported by max_duty_cycle.

Provided Methods§

Source

fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 0%, or always inactive.

Source

fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 100%, or always active.

Source

fn set_duty_cycle_fraction( &mut self, num: u16, denom: u16, ) -> Result<(), Self::Error>

Set the duty cycle to num / denom.

The caller is responsible for ensuring that num is less than or equal to denom, and that denom is not zero.

Source

fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error>

Set the duty cycle to percent / 100

The caller is responsible for ensuring that percent is less than or equal to 100.

Implementations on Foreign Types§

Source§

impl<T> SetDutyCycle for &mut T
where T: SetDutyCycle + ?Sized,

Implementors§

Source§

impl<'d> SetDutyCycle for Pwm<'d>

Source§

impl<'d> SetDutyCycle for PwmOutput<'d>