From 089b6722c6c58a023beccdd8f15695f1df0fe117 Mon Sep 17 00:00:00 2001 From: "r.marple" Date: Wed, 3 Sep 2025 15:53:50 +1000 Subject: [PATCH] Added timer set polarity functions for main and complementary outputs individually --- embassy-stm32/CHANGELOG.md | 1 + embassy-stm32/src/timer/complementary_pwm.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md index c9be259ea..4cc48ed97 100644 --- a/embassy-stm32/CHANGELOG.md +++ b/embassy-stm32/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - fix: Fixed STM32H5 builds requiring time feature - feat: Derive Clone, Copy for QSPI Config - fix: stm32/i2c in master mode (blocking): subsequent transmissions failed after a NACK was received +- feat: stm32/timer: add set_polarity functions for main and complementary outputs in complementary_pwm ## 0.4.0 - 2025-08-26 diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index b291fc155..7d6c2273e 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs @@ -185,6 +185,16 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { self.inner.set_complementary_output_polarity(channel, polarity); } + /// Set the main output polarity for a given channel. + pub fn set_main_polarity(&mut self, channel: Channel, polarity: OutputPolarity) { + self.inner.set_output_polarity(channel, polarity); + } + + /// Set the complementary output polarity for a given channel. + pub fn set_complementary_polarity(&mut self, channel: Channel, polarity: OutputPolarity) { + self.inner.set_complementary_output_polarity(channel, polarity); + } + /// Set the dead time as a proportion of max_duty pub fn set_dead_time(&mut self, value: u16) { let (ckd, value) = compute_dead_time_value(value);