aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer/complementary_pwm.rs
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-12-03 09:36:58 -0600
committerxoviat <[email protected]>2025-12-03 09:36:58 -0600
commit077e59a192ca4cb096a9ef939d06ebefebbac42d (patch)
treed77ac51522f10bd3b10e49cf76880d17a1808ddc /embassy-stm32/src/timer/complementary_pwm.rs
parent424522b0975b449bc62854c271b196cd9ed192d7 (diff)
timer: restore waveform method
Diffstat (limited to 'embassy-stm32/src/timer/complementary_pwm.rs')
-rw-r--r--embassy-stm32/src/timer/complementary_pwm.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs
index 6ca13820a..4f2ac4079 100644
--- a/embassy-stm32/src/timer/complementary_pwm.rs
+++ b/embassy-stm32/src/timer/complementary_pwm.rs
@@ -2,14 +2,13 @@
2 2
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4 4
5pub use stm32_metapac::timer::vals::{Ckd, Mms2, Ossi, Ossr};
6
7use super::low_level::{CountingMode, OutputPolarity, Timer}; 5use super::low_level::{CountingMode, OutputPolarity, Timer};
8use super::simple_pwm::PwmPin; 6use super::simple_pwm::PwmPin;
9use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin}; 7use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin};
10use crate::Peri; 8use crate::Peri;
11use crate::dma::word::Word; 9use crate::dma::word::Word;
12use crate::gpio::{AnyPin, OutputType}; 10use crate::gpio::{AnyPin, OutputType};
11pub use crate::pac::timer::vals::{Ccds, Ckd, Mms2, Ossi, Ossr};
13use crate::time::Hertz; 12use crate::time::Hertz;
14use crate::timer::TimerChannel; 13use crate::timer::TimerChannel;
15use crate::timer::low_level::OutputCompareMode; 14use crate::timer::low_level::OutputCompareMode;
@@ -220,6 +219,27 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
220 /// Generate a sequence of PWM waveform 219 /// Generate a sequence of PWM waveform
221 /// 220 ///
222 /// Note: 221 /// Note:
222 /// You will need to provide corresponding `TIMx_UP` DMA channel to use this method.
223 /// Also be aware that embassy timers use one of timers internally. It is possible to
224 /// switch this timer by using `time-driver-timX` feature.
225 pub async fn waveform<C: TimerChannel, W: Word + Into<T::Word>>(
226 &mut self,
227 dma: Peri<'_, impl super::Dma<T, C>>,
228 channel: Channel,
229 duty: &[W],
230 ) {
231 self.inner.enable_channel(channel, true);
232 self.inner.enable_channel(C::CHANNEL, true);
233 self.inner.clamp_compare_value::<W>(channel);
234 self.inner.set_cc_dma_selection(Ccds::ON_UPDATE);
235 self.inner.set_cc_dma_enable_state(C::CHANNEL, true);
236 self.inner.setup_channel_update_dma(dma, channel, duty).await;
237 self.inner.set_cc_dma_enable_state(C::CHANNEL, false);
238 }
239
240 /// Generate a sequence of PWM waveform
241 ///
242 /// Note:
223 /// you will need to provide corresponding TIMx_UP DMA channel to use this method. 243 /// you will need to provide corresponding TIMx_UP DMA channel to use this method.
224 pub async fn waveform_up<W: Word + Into<T::Word>>( 244 pub async fn waveform_up<W: Word + Into<T::Word>>(
225 &mut self, 245 &mut self,