Pwm

Struct Pwm 

Source
pub struct Pwm<const FREQ: u32> { /* private fields */ }

Implementations§

Source§

impl<const FREQ: u32> Pwm<FREQ>

Source

pub fn new(ch: PwmChannel) -> Self

Creates a new PWM instance with the specified channel.

§Arguments
  • ch - The PWM channel to initialize.
§Returns

A new Pwm instance configured for the given channel and frequency.

Source

pub fn enable(&self)

Enables the PWM output on the specified channel.

Source

pub fn disable(&self)

Disables the PWM output on the specified channel.

Source

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 or ActiveLow).
Source

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.

Source

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.

Source

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.
Source

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.
Source

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.

Source

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.

Source

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 a TimerDurationU32.

Trait Implementations§

Source§

impl<const FREQ: u32> Clone for Pwm<FREQ>

Source§

fn clone(&self) -> Pwm<FREQ>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const FREQ: u32> Debug for Pwm<FREQ>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const FREQ: u32> Drop for Pwm<FREQ>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<const FREQ: u32> ErrorType for Pwm<FREQ>

Source§

type Error = Infallible

Error type
Source§

impl<const FREQ: u32> SetDutyCycle for Pwm<FREQ>

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<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> 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 = 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.