aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer/mod.rs
diff options
context:
space:
mode:
authoreZio Pan <[email protected]>2023-12-28 16:23:47 +0800
committereZio Pan <[email protected]>2023-12-28 20:09:12 +0800
commit8c2a6df03b852233ef6c774896cbb00c2a15040f (patch)
treec8bd878540fafbf589055a91993b8e3b01661a09 /embassy-stm32/src/timer/mod.rs
parenteebfee189a592427423d3a3ad22132d59926a0e8 (diff)
implement PWM waveform generating with DMA
Diffstat (limited to 'embassy-stm32/src/timer/mod.rs')
-rw-r--r--embassy-stm32/src/timer/mod.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs
index 74120adad..05a0564a3 100644
--- a/embassy-stm32/src/timer/mod.rs
+++ b/embassy-stm32/src/timer/mod.rs
@@ -91,7 +91,12 @@ pub(crate) mod sealed {
91 91
92 /// Enable/disable the update interrupt. 92 /// Enable/disable the update interrupt.
93 fn enable_update_interrupt(&mut self, enable: bool) { 93 fn enable_update_interrupt(&mut self, enable: bool) {
94 Self::regs().dier().write(|r| r.set_uie(enable)); 94 Self::regs().dier().modify(|r| r.set_uie(enable));
95 }
96
97 /// Enable/disable the update dma.
98 fn enable_update_dma(&mut self, enable: bool) {
99 Self::regs().dier().modify(|r| r.set_ude(enable));
95 } 100 }
96 101
97 /// Enable/disable autoreload preload. 102 /// Enable/disable autoreload preload.
@@ -288,6 +293,14 @@ pub(crate) mod sealed {
288 fn get_compare_value(&self, channel: Channel) -> u16 { 293 fn get_compare_value(&self, channel: Channel) -> u16 {
289 Self::regs_gp16().ccr(channel.index()).read().ccr() 294 Self::regs_gp16().ccr(channel.index()).read().ccr()
290 } 295 }
296
297 /// Set output compare preload.
298 fn set_output_compare_preload(&mut self, channel: Channel, preload: bool) {
299 let channel_index = channel.index();
300 Self::regs_gp16()
301 .ccmr_output(channel_index / 2)
302 .modify(|w| w.set_ocpe(channel_index % 2, preload));
303 }
291 } 304 }
292 305
293 /// Capture/Compare 16-bit timer instance with complementary pin support. 306 /// Capture/Compare 16-bit timer instance with complementary pin support.
@@ -676,3 +689,6 @@ foreach_interrupt! {
676 } 689 }
677 }; 690 };
678} 691}
692
693// Update Event trigger DMA for every timer
694dma_trait!(UpDma, Basic16bitInstance);