diff options
| author | xoviat <[email protected]> | 2025-12-03 09:36:58 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-12-03 09:36:58 -0600 |
| commit | 077e59a192ca4cb096a9ef939d06ebefebbac42d (patch) | |
| tree | d77ac51522f10bd3b10e49cf76880d17a1808ddc /embassy-stm32/src/timer/complementary_pwm.rs | |
| parent | 424522b0975b449bc62854c271b196cd9ed192d7 (diff) | |
timer: restore waveform method
Diffstat (limited to 'embassy-stm32/src/timer/complementary_pwm.rs')
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 24 |
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 | ||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | 4 | ||
| 5 | pub use stm32_metapac::timer::vals::{Ckd, Mms2, Ossi, Ossr}; | ||
| 6 | |||
| 7 | use super::low_level::{CountingMode, OutputPolarity, Timer}; | 5 | use super::low_level::{CountingMode, OutputPolarity, Timer}; |
| 8 | use super::simple_pwm::PwmPin; | 6 | use super::simple_pwm::PwmPin; |
| 9 | use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin}; | 7 | use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin}; |
| 10 | use crate::Peri; | 8 | use crate::Peri; |
| 11 | use crate::dma::word::Word; | 9 | use crate::dma::word::Word; |
| 12 | use crate::gpio::{AnyPin, OutputType}; | 10 | use crate::gpio::{AnyPin, OutputType}; |
| 11 | pub use crate::pac::timer::vals::{Ccds, Ckd, Mms2, Ossi, Ossr}; | ||
| 13 | use crate::time::Hertz; | 12 | use crate::time::Hertz; |
| 14 | use crate::timer::TimerChannel; | 13 | use crate::timer::TimerChannel; |
| 15 | use crate::timer::low_level::OutputCompareMode; | 14 | use 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, |
