Struct LinkedPins

Source
pub struct LinkedPins<'d, PWM, const OP: u8> { /* private fields */ }
Available on crate feature unstable only.
Expand description

Two pins driven by the same timer and operator

Useful for complementary or mirrored signals with or without configured deadtime.

§H-Bridge example

// active high complementary using PWMA input
let bridge_active = DeadTimeCfg::new_ahc();
// use PWMB as input for both outputs
let bridge_off = DeadTimeCfg::new_bypass().set_output_swap(PWMStream::PWMA,
true);
let clock_cfg = PeripheralClockConfig::with_frequency(Rate::from_mhz(32))?;
let mut mcpwm = McPwm::new(peripherals.MCPWM0, clock_cfg);

let mut pins = mcpwm.operator0.with_linked_pins(
    peripherals.GPIO0,
    PwmPinConfig::UP_DOWN_ACTIVE_HIGH, // use PWMA as our main input
    peripherals.GPIO1,
    PwmPinConfig::EMPTY, // keep PWMB "low"
    bridge_off,
);

pins.set_falling_edge_deadtime(5);
pins.set_rising_edge_deadtime(5);
// pin_a: ________________________________________
// pin_b: ________________________________________
pins.set_timestamp_a(40); // 40% duty cycle if period configured to 100
pins.set_deadtime_cfg(bridge_active);
// pin_a: _______-------_____________-------______
// pin_b: ------_________-----------_________-----

Implementations§

Source§

impl<'d, PWM: PwmPeripheral, const OP: u8> LinkedPins<'d, PWM, OP>

Source

pub fn set_actions_a(&mut self, value: PwmActions<true>)

Configure what actions should be taken on timing events

Source

pub fn set_actions_b(&mut self, value: PwmActions<false>)

Configure what actions should be taken on timing events

Source

pub fn set_update_method_a(&mut self, update_method: PwmUpdateMethod)

Set how a new timestamp syncs with the timer

Source

pub fn set_update_method_b(&mut self, update_method: PwmUpdateMethod)

Set how a new timestamp syncs with the timer

Source

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

Write a new timestamp. The written value will take effect according to the set PwmUpdateMethod.

Source

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

Write a new timestamp. The written value will take effect according to the set PwmUpdateMethod.

Source

pub fn set_deadtime_cfg(&mut self, config: DeadTimeCfg)

Configure the deadtime generator

Source

pub fn set_rising_edge_deadtime(&mut self, dead_time: u16)

Set the deadtime generator rising edge delay

Source

pub fn set_falling_edge_deadtime(&mut self, dead_time: u16)

Set the deadtime generator falling edge delay

Auto Trait Implementations§

§

impl<'d, PWM, const OP: u8> Freeze for LinkedPins<'d, PWM, OP>

§

impl<'d, PWM, const OP: u8> RefUnwindSafe for LinkedPins<'d, PWM, OP>
where PWM: RefUnwindSafe,

§

impl<'d, PWM, const OP: u8> Send for LinkedPins<'d, PWM, OP>
where PWM: Send,

§

impl<'d, PWM, const OP: u8> Sync for LinkedPins<'d, PWM, OP>
where PWM: Sync,

§

impl<'d, PWM, const OP: u8> Unpin for LinkedPins<'d, PWM, OP>
where PWM: Unpin,

§

impl<'d, PWM, const OP: u8> !UnwindSafe for LinkedPins<'d, PWM, OP>

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.