From 8eff7498238ca8863bfdd4496fcb4246cc2df8eb Mon Sep 17 00:00:00 2001 From: Torin Cooper-Bennun Date: Mon, 13 Nov 2023 15:13:25 +0000 Subject: [PATCH] stm32/gpdma: fix drop() to use RM's method for aborting transfer see e.g. STM32H503 RM section 15.4.4... 1. Write 1 into GPDMA_CxCR.SUSP 2. Poll GPDMA_CxSR.SUSPF until it is 1 3. Write 1 into GPDMA_CxCR.RESET (occurs upon next init, in new_inner()) --- embassy-stm32/src/dma/gpdma.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index b811da1f..b061415e 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs @@ -299,19 +299,15 @@ impl<'a, C: Channel> Transfer<'a, C> { pub fn request_stop(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); - - // Disable the channel. Keep the IEs enabled so the irqs still fire. - ch.cr().write(|w| { - w.set_tcie(true); - w.set_useie(true); - w.set_dteie(true); - w.set_suspie(true); + ch.cr().modify(|w| { + w.set_susp(true); }) } pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().ch(self.channel.num()); - !ch.sr().read().tcf() + let sr = ch.sr().read(); + !sr.tcf() && !sr.suspf() } /// Gets the total remaining transfers for the channel