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>
impl<'d, PWM: PwmPeripheral, const OP: u8> LinkedPins<'d, PWM, OP>
Sourcepub fn set_actions_a(&mut self, value: PwmActions<true>)
pub fn set_actions_a(&mut self, value: PwmActions<true>)
Configure what actions should be taken on timing events
Sourcepub fn set_actions_b(&mut self, value: PwmActions<false>)
pub fn set_actions_b(&mut self, value: PwmActions<false>)
Configure what actions should be taken on timing events
Sourcepub fn set_update_method_a(&mut self, update_method: PwmUpdateMethod)
pub fn set_update_method_a(&mut self, update_method: PwmUpdateMethod)
Set how a new timestamp syncs with the timer
Sourcepub fn set_update_method_b(&mut self, update_method: PwmUpdateMethod)
pub fn set_update_method_b(&mut self, update_method: PwmUpdateMethod)
Set how a new timestamp syncs with the timer
Sourcepub fn set_timestamp_a(&mut self, value: u16)
pub fn set_timestamp_a(&mut self, value: u16)
Write a new timestamp.
The written value will take effect according to the set
PwmUpdateMethod
.
Sourcepub fn set_timestamp_b(&mut self, value: u16)
pub fn set_timestamp_b(&mut self, value: u16)
Write a new timestamp.
The written value will take effect according to the set
PwmUpdateMethod
.
Sourcepub fn set_deadtime_cfg(&mut self, config: DeadTimeCfg)
pub fn set_deadtime_cfg(&mut self, config: DeadTimeCfg)
Configure the deadtime generator
Sourcepub fn set_rising_edge_deadtime(&mut self, dead_time: u16)
pub fn set_rising_edge_deadtime(&mut self, dead_time: u16)
Set the deadtime generator rising edge delay
Sourcepub fn set_falling_edge_deadtime(&mut self, dead_time: u16)
pub fn set_falling_edge_deadtime(&mut self, dead_time: u16)
Set the deadtime generator falling edge delay