Struct embedded_c_sdk_bind_hal::pwm::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> 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>

§

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> 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>,

§

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>,

§

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.