Skip to main content

ComplementaryPwm

Struct ComplementaryPwm 

Source
pub struct ComplementaryPwm<'d, T: AdvancedInstance> { /* private fields */ }
Expand description

PWM driver with support for standard and complementary outputs.

Implementations§

Source§

impl<'d, T: AdvancedInstance> ComplementaryPwm<'d, T>

Source

pub fn new( tim: Peri<'d, T>, _ch1: Option<PwmPin<'d, T, Ch1>>, _ch1n: Option<ComplementaryPwmPin<'d, T, Ch1>>, _ch2: Option<PwmPin<'d, T, Ch2>>, _ch2n: Option<ComplementaryPwmPin<'d, T, Ch2>>, _ch3: Option<PwmPin<'d, T, Ch3>>, _ch3n: Option<ComplementaryPwmPin<'d, T, Ch3>>, _ch4: Option<PwmPin<'d, T, Ch4>>, freq: Hertz, counting_mode: CountingMode, ) -> Self

Create a new complementary 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 set_frequency(&mut self, freq: 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.

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 set_polarity(&mut self, channel: Channel, polarity: OutputPolarity)

Set the output polarity for a given channel.

Source

pub fn set_dead_time(&mut self, value: u16)

Set dead time in timer input clock ticks, rounded down to a supported value.

Values above the hardware maximum are clamped to 4032 ticks.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<'d, T> UnsafeUnpin for ComplementaryPwm<'d, T>
where T: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.