embassy-rp

Crates

git

Versions

rp2040

Flavors

Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config { pub invert_a: bool, pub invert_b: bool, pub phase_correct: bool, pub enable: bool, pub divider_x16: u16, pub compare_a: u16, pub compare_b: u16, pub top: u16, }
Expand description

The configuration of a PWM slice. Note the period in clock cycles of a slice can be computed as: (top + 1) * (phase_correct ? 1 : 2) * divider

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§invert_a: bool

Inverts the PWM output signal on channel A.

§invert_b: bool

Inverts the PWM output signal on channel B.

§phase_correct: bool

Enables phase-correct mode for PWM operation. In phase-correct mode, the PWM signal is generated in such a way that the pulse is always centered regardless of the duty cycle. The output frequency is halved when phase-correct mode is enabled.

§enable: bool

Enables the PWM slice, allowing it to generate an output.

§divider_x16: u16

A fractional clock divider, as a fixed-point number with 8 integer bits and 4 fractional bits (the divider multiplied by 16). For example, 16 divides by 1, 40 divides by 2.5, and the maximum 0xFFF divides by 255.9375. It allows precise control over the PWM output frequency by gating the PWM counter increment. A higher value will result in a slower output frequency.

§compare_a: u16

The output on channel A goes high when compare_a is higher than the counter. A compare of 0 will produce an always low output, while a compare of top + 1 will produce an always high output.

§compare_b: u16

The output on channel B goes high when compare_b is higher than the counter. A compare of 0 will produce an always low output, while a compare of top + 1 will produce an always high output.

§top: u16

The point at which the counter wraps, representing the maximum possible period. The counter will either wrap to 0 or reverse depending on the setting of phase_correct.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Format for Config

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.