embassy-stm32

Crates

git

Versions

stm32u5f9zj

Flavors

📣 We want to hear from you! Fill the Rust Embedded 2024 micro-survey.

Struct embassy_stm32::lptim::pwm::Pwm

source ·
pub struct Pwm<'d, T: Instance> { /* private fields */ }
Expand description

PWM driver.

Implementations§

source§

impl<'d, T: Instance> Pwm<'d, T>

source

pub fn new( tim: impl Peripheral<P = T> + 'd, _ch1_pin: Option<PwmPin<'d, T, Ch1>>, _ch2_pin: Option<PwmPin<'d, T, Ch2>>, freq: Hertz, ) -> Self

Create a new PWM driver.

source

pub fn enable(&mut self, channel: Channel)

Enable the given channel.

source

pub fn disable(&mut self, channel: Channel)

Disable the given channel.

source

pub fn is_enabled(&self, channel: Channel) -> bool

Check whether given channel is enabled

source

pub fn set_duty(&mut self, channel: Channel, duty: u16)

Set the duty for a given channel.

The value ranges from 0 for 0% duty, to get_max_duty for 100% duty, both included.

source

pub fn get_duty(&self, channel: Channel) -> u16

Get the duty for a given channel.

The value ranges from 0 for 0% duty, to get_max_duty for 100% duty, both included.

source§

impl<'d, T: Instance> Pwm<'d, T>

source

pub fn set_frequency(&mut self, frequency: Hertz)

Set PWM frequency.

Note: when you call this, the max duty value changes, so you will have to call set_duty on all channels with the duty calculated based on the new max duty.

source

pub fn get_max_duty(&self) -> u16

Get max duty value.

This value depends on the configured frequency and the timer’s clock rate from RCC.

Auto Trait Implementations§

§

impl<'d, T> Freeze for Pwm<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for Pwm<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for Pwm<'d, T>
where T: Send,

§

impl<'d, T> Sync for Pwm<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for Pwm<'d, T>
where T: Unpin,

§

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

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

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.