diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-24 20:02:49 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-24 20:02:49 +0000 |
| commit | 539c007b44bb67feee6db7d021887faa14c62e8b (patch) | |
| tree | 47e890fa35bae1c3b2541ddcea58991ddfe964e9 | |
| parent | 32d52c89a9e0961896890f966b2212a856ea911d (diff) | |
| parent | cd9a1d547c3e377bd7c0f6743a27218b38b2f491 (diff) | |
Merge #502
502: Ensure SPI DMA write is completed r=lulf a=lulf
Fix a bug where DMA writes were not fully completed and only a single
byte out of two were written.
Co-authored-by: Ulf Lilleengen <[email protected]>
| -rw-r--r-- | embassy-stm32/src/spi/v2.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/embassy-stm32/src/spi/v2.rs b/embassy-stm32/src/spi/v2.rs index 9b8a74d7b..488e80ef8 100644 --- a/embassy-stm32/src/spi/v2.rs +++ b/embassy-stm32/src/spi/v2.rs | |||
| @@ -17,7 +17,7 @@ use embassy::util::Unborrow; | |||
| 17 | use embassy_hal_common::unborrow; | 17 | use embassy_hal_common::unborrow; |
| 18 | use embassy_traits::spi as traits; | 18 | use embassy_traits::spi as traits; |
| 19 | pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; | 19 | pub use embedded_hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; |
| 20 | use futures::future::join3; | 20 | use futures::future::{join, join3}; |
| 21 | 21 | ||
| 22 | impl WordSize { | 22 | impl WordSize { |
| 23 | fn ds(&self) -> spi::vals::Ds { | 23 | fn ds(&self) -> spi::vals::Ds { |
| @@ -186,7 +186,16 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 186 | }); | 186 | }); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | f.await; | 189 | join(f, Self::wait_for_idle()).await; |
| 190 | |||
| 191 | unsafe { | ||
| 192 | T::regs().cr2().modify(|reg| { | ||
| 193 | reg.set_txdmaen(false); | ||
| 194 | }); | ||
| 195 | T::regs().cr1().modify(|w| { | ||
| 196 | w.set_spe(false); | ||
| 197 | }); | ||
| 198 | } | ||
| 190 | Ok(()) | 199 | Ok(()) |
| 191 | } | 200 | } |
| 192 | 201 | ||
