aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Oppenlander <[email protected]>2023-02-23 10:09:09 +1100
committerPatrick Oppenlander <[email protected]>2023-02-23 10:12:48 +1100
commit4e884ee2d2f0c3f4a46f1bc539a12e9fdce173e2 (patch)
treeab38d041af74a8a75e7b6db715207da5943ca3fb
parentd159a6c62d09155261c14edec69dc9dd9e662a92 (diff)
stm32/dma: fix spurious transfer complete interrupts
DMA interrupts must be acknowledged by writing to the DMA_{L,H}IFCR register. Writing to the CR register is unnecessary as the channel (EN bit) is disabled by hardware on completion of the transfer.
-rw-r--r--embassy-stm32/src/dma/dma.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs
index fec60f708..8966214ec 100644
--- a/embassy-stm32/src/dma/dma.rs
+++ b/embassy-stm32/src/dma/dma.rs
@@ -411,12 +411,8 @@ mod low_level_api {
411 } 411 }
412 412
413 if isr.tcif(channel_num % 4) && cr.read().tcie() { 413 if isr.tcif(channel_num % 4) && cr.read().tcie() {
414 if cr.read().dbm() == vals::Dbm::DISABLED { 414 /* acknowledge transfer complete interrupt */
415 cr.write(|_| ()); // Disable channel with the default value. 415 dma.ifcr(channel_num / 4).write(|w| w.set_tcif(channel_num % 4, true));
416 } else {
417 // for double buffered mode, clear TCIF flag but do not stop the transfer
418 dma.ifcr(channel_num / 4).write(|w| w.set_tcif(channel_num % 4, true));
419 }
420 STATE.channels[state_index].waker.wake(); 416 STATE.channels[state_index].waker.wake();
421 } 417 }
422 } 418 }