diff options
| author | Torin Cooper-Bennun <[email protected]> | 2023-11-13 15:13:25 +0000 |
|---|---|---|
| committer | Torin Cooper-Bennun <[email protected]> | 2023-11-13 16:41:09 +0000 |
| commit | 8eff7498238ca8863bfdd4496fcb4246cc2df8eb (patch) | |
| tree | 21642152797deecbd3705ed4035eb2c7f44fffd1 /embassy-stm32/src/dma | |
| parent | 39c737162185adb4f30f18f700da08a55be6b55a (diff) | |
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())
Diffstat (limited to 'embassy-stm32/src/dma')
| -rw-r--r-- | embassy-stm32/src/dma/gpdma.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index b811da1fb..b061415eb 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> { | |||
| 299 | 299 | ||
| 300 | pub fn request_stop(&mut self) { | 300 | pub fn request_stop(&mut self) { |
| 301 | let ch = self.channel.regs().ch(self.channel.num()); | 301 | let ch = self.channel.regs().ch(self.channel.num()); |
| 302 | 302 | ch.cr().modify(|w| { | |
| 303 | // Disable the channel. Keep the IEs enabled so the irqs still fire. | 303 | w.set_susp(true); |
| 304 | ch.cr().write(|w| { | ||
| 305 | w.set_tcie(true); | ||
| 306 | w.set_useie(true); | ||
| 307 | w.set_dteie(true); | ||
| 308 | w.set_suspie(true); | ||
| 309 | }) | 304 | }) |
| 310 | } | 305 | } |
| 311 | 306 | ||
| 312 | pub fn is_running(&mut self) -> bool { | 307 | pub fn is_running(&mut self) -> bool { |
| 313 | let ch = self.channel.regs().ch(self.channel.num()); | 308 | let ch = self.channel.regs().ch(self.channel.num()); |
| 314 | !ch.sr().read().tcf() | 309 | let sr = ch.sr().read(); |
| 310 | !sr.tcf() && !sr.suspf() | ||
| 315 | } | 311 | } |
| 316 | 312 | ||
| 317 | /// Gets the total remaining transfers for the channel | 313 | /// Gets the total remaining transfers for the channel |
