embassy-rp

Crates

git

Versions

rp235xb

Flavors

embassy_rp::pwm

Struct Pwm

Source
pub struct Pwm<'d> { /* private fields */ }
Expand description

PWM driver.

Implementations§

Source§

impl<'d> Pwm<'d>

Source

pub fn new_free<T: Slice>( slice: impl Peripheral<P = T> + 'd, config: Config, ) -> Self

Create PWM driver without any configured pins.

Source

pub fn new_output_a<T: Slice>( slice: impl Peripheral<P = T> + 'd, a: impl Peripheral<P = impl ChannelAPin<T>> + 'd, config: Config, ) -> Self

Create PWM driver with a single ‘a’ pin as output.

Source

pub fn new_output_b<T: Slice>( slice: impl Peripheral<P = T> + 'd, b: impl Peripheral<P = impl ChannelBPin<T>> + 'd, config: Config, ) -> Self

Create PWM driver with a single ‘b’ pin as output.

Source

pub fn new_output_ab<T: Slice>( slice: impl Peripheral<P = T> + 'd, a: impl Peripheral<P = impl ChannelAPin<T>> + 'd, b: impl Peripheral<P = impl ChannelBPin<T>> + 'd, config: Config, ) -> Self

Create PWM driver with a ‘a’ and ‘b’ pins as output.

Source

pub fn new_input<T: Slice>( slice: impl Peripheral<P = T> + 'd, b: impl Peripheral<P = impl ChannelBPin<T>> + 'd, b_pull: Pull, mode: InputMode, config: Config, ) -> Self

Create PWM driver with a single ‘b’ as input pin.

Source

pub fn new_output_input<T: Slice>( slice: impl Peripheral<P = T> + 'd, a: impl Peripheral<P = impl ChannelAPin<T>> + 'd, b: impl Peripheral<P = impl ChannelBPin<T>> + 'd, b_pull: Pull, mode: InputMode, config: Config, ) -> Self

Create PWM driver with a ‘a’ and ‘b’ pins in the desired input mode.

Source

pub fn set_config(&mut self, config: &Config)

Set the PWM config.

Source

pub fn phase_advance(&mut self)

Advances a slice’s output phase by one count while it is running by inserting a pulse into the clock enable. The counter will not count faster than once per cycle.

Source

pub fn phase_retard(&mut self)

Retards a slice’s output phase by one count while it is running by deleting a pulse from the clock enable. The counter will not count backward when clock enable is permanently low.

Source

pub fn counter(&self) -> u16

Read PWM counter.

Source

pub fn set_counter(&self, ctr: u16)

Write PWM counter.

Source

pub fn wait_for_wrap(&mut self)

Wait for channel interrupt.

Source

pub fn wrapped(&mut self) -> bool

Check if interrupt for channel is set.

Source

pub fn clear_wrapped(&mut self)

Clear interrupt flag.

Source

pub fn split(self) -> (Option<PwmOutput<'d>>, Option<PwmOutput<'d>>)

Splits the PWM driver into separate PwmOutput instances for channels A and B.

Source

pub fn split_by_ref(&mut self) -> (Option<PwmOutput<'_>>, Option<PwmOutput<'_>>)

Splits the PWM driver by reference to allow for separate duty cycle control of each channel (A and B) without taking ownership of the PWM instance.

Trait Implementations§

Source§

impl<'d> Drop for Pwm<'d>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'d> ErrorType for Pwm<'d>

Source§

type Error = PwmError

Error type
Source§

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

Source§

fn max_duty_cycle(&self) -> u16

Get the maximum duty cycle value. Read more
Source§

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

Set the duty cycle to duty / max_duty. Read more
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. Read more
Source§

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

Set the duty cycle to percent / 100 Read more

Auto Trait Implementations§

§

impl<'d> Freeze for Pwm<'d>

§

impl<'d> RefUnwindSafe for Pwm<'d>

§

impl<'d> Send for Pwm<'d>

§

impl<'d> Sync for Pwm<'d>

§

impl<'d> Unpin for Pwm<'d>

§

impl<'d> !UnwindSafe for Pwm<'d>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.