diff options
| author | Thales <[email protected]> | 2021-07-17 17:28:02 -0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-17 17:28:02 -0300 |
| commit | 40ea8298eedbe2430b647ab969d4a2e627b6ece8 (patch) | |
| tree | 2938b63601e97b8a7f1f787f90d103871ea35543 | |
| parent | f4b8709bac0b6f25d0380b28358cf2fa3a8f8ee2 (diff) | |
| parent | aae0431d3178f44a412a3c94536335c02a57dd06 (diff) | |
Merge pull request #300 from thalesfragoso/clear-dma
stm32: Clear possible set flags after disabling DMA
| -rw-r--r-- | embassy-stm32/src/dma/bdma.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/dma.rs | 7 | ||||
| m--------- | stm32-data | 0 |
3 files changed, 12 insertions, 0 deletions
diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index 4c26a9501..5063ec2e7 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs | |||
| @@ -66,6 +66,11 @@ pub(crate) async unsafe fn do_transfer( | |||
| 66 | w.set_en(false); | 66 | w.set_en(false); |
| 67 | }); | 67 | }); |
| 68 | while ch.cr().read().en() {} | 68 | while ch.cr().read().en() {} |
| 69 | |||
| 70 | // Disabling the DMA mid transfer might cause some flags to be set, clear them all for the | ||
| 71 | // next transfer | ||
| 72 | dma.ifcr() | ||
| 73 | .write(|w| w.set_gif(channel_number as usize, true)); | ||
| 69 | }); | 74 | }); |
| 70 | 75 | ||
| 71 | #[cfg(dmamux)] | 76 | #[cfg(dmamux)] |
diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index 591279ef8..8634de205 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs | |||
| @@ -67,6 +67,13 @@ pub(crate) async unsafe fn do_transfer( | |||
| 67 | w.set_en(false); | 67 | w.set_en(false); |
| 68 | }); | 68 | }); |
| 69 | while ch.cr().read().en() {} | 69 | while ch.cr().read().en() {} |
| 70 | |||
| 71 | // Disabling the DMA mid transfer might cause some flags to be set, clear them all for the | ||
| 72 | // next transfer | ||
| 73 | dma.ifcr(channel_number as usize / 4).write(|w| { | ||
| 74 | w.set_tcif(channel_number as usize % 4, true); | ||
| 75 | w.set_teif(channel_number as usize % 4, true); | ||
| 76 | }); | ||
| 70 | }); | 77 | }); |
| 71 | 78 | ||
| 72 | #[cfg(dmamux)] | 79 | #[cfg(dmamux)] |
diff --git a/stm32-data b/stm32-data | |||
| Subproject 8702a3a3bb83a59515dab2cf9f75952fa6edae8 | Subproject ce2e32b927a3637d975e780274b8e0c985f5d99 | ||
