diff options
| author | Richard Dodd <[email protected]> | 2021-05-05 19:18:57 +0100 |
|---|---|---|
| committer | Richard Dodd <[email protected]> | 2021-05-05 19:18:57 +0100 |
| commit | 212e83aa221c1838e7da7617d08110580c53bfd2 (patch) | |
| tree | db24ccf0de3149dfac9af26928af65a1e3c1fcfe | |
| parent | 9de12a0a7a3dc3bb95a3bdc09817ead8e8130269 (diff) | |
Make changes to `Write` as well as `Transfer`
| -rw-r--r-- | embassy-nrf/src/spim.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 3b5f7a070..3370e1243 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -280,7 +280,6 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spim<'d, T> { | |||
| 280 | compiler_fence(Ordering::SeqCst); | 280 | compiler_fence(Ordering::SeqCst); |
| 281 | 281 | ||
| 282 | let r = T::regs(); | 282 | let r = T::regs(); |
| 283 | let s = T::state(); | ||
| 284 | 283 | ||
| 285 | // Set up the DMA write. | 284 | // Set up the DMA write. |
| 286 | r.txd | 285 | r.txd |
| @@ -298,23 +297,20 @@ impl<'d, T: Instance> embedded_hal::blocking::spi::Write<u8> for Spim<'d, T> { | |||
| 298 | .maxcnt | 297 | .maxcnt |
| 299 | .write(|w| unsafe { w.maxcnt().bits(recv.len() as _) }); | 298 | .write(|w| unsafe { w.maxcnt().bits(recv.len() as _) }); |
| 300 | 299 | ||
| 301 | // Reset and enable the event | 300 | // Disable the end event since we are busy-polling. |
| 302 | r.events_end.reset(); | 301 | r.events_end.reset(); |
| 303 | r.intenset.write(|w| w.end().set()); | ||
| 304 | 302 | ||
| 305 | // Start SPI transaction. | 303 | // Start SPI transaction. |
| 306 | r.tasks_start.write(|w| unsafe { w.bits(1) }); | 304 | r.tasks_start.write(|w| unsafe { w.bits(1) }); |
| 307 | 305 | ||
| 306 | // Wait for 'end' event. | ||
| 307 | while r.events_end.read().bits() == 0 {} | ||
| 308 | |||
| 308 | // Conservative compiler fence to prevent optimizations that do not | 309 | // Conservative compiler fence to prevent optimizations that do not |
| 309 | // take in to account actions by DMA. The fence has been placed here, | 310 | // take in to account actions by DMA. The fence has been placed here, |
| 310 | // after all possible DMA actions have completed. | 311 | // after all possible DMA actions have completed. |
| 311 | compiler_fence(Ordering::SeqCst); | 312 | compiler_fence(Ordering::SeqCst); |
| 312 | 313 | ||
| 313 | // Wait for 'end' event. | ||
| 314 | while r.events_end.read().bits() == 0 { | ||
| 315 | continue; | ||
| 316 | } | ||
| 317 | |||
| 318 | Ok(()) | 314 | Ok(()) |
| 319 | } | 315 | } |
| 320 | } | 316 | } |
