diff options
| author | Til Blechschmidt <[email protected]> | 2022-02-23 23:38:18 +0100 |
|---|---|---|
| committer | Til Blechschmidt <[email protected]> | 2022-02-23 23:38:18 +0100 |
| commit | 62407da29b5d1867f50f30c796cc1ecfc7dc77c1 (patch) | |
| tree | 11c73ca54844892a1697b47fab8cb12b0200345e /embassy-nrf/src/spim.rs | |
| parent | 6dc58645d22ebebf6abe8d4d07bcc3001cac91c6 (diff) | |
Fix EasyDMA slice copying not actually copying data
Diffstat (limited to 'embassy-nrf/src/spim.rs')
| -rw-r--r-- | embassy-nrf/src/spim.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 5895558e6..3e793f393 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -8,6 +8,7 @@ use embassy::util::Unborrow; | |||
| 8 | use embassy_hal_common::unborrow; | 8 | use embassy_hal_common::unborrow; |
| 9 | use futures::future::poll_fn; | 9 | use futures::future::poll_fn; |
| 10 | 10 | ||
| 11 | use crate::chip::FORCE_COPY_BUFFER_SIZE; | ||
| 11 | use crate::gpio::sealed::Pin as _; | 12 | use crate::gpio::sealed::Pin as _; |
| 12 | use crate::gpio::{self, AnyPin}; | 13 | use crate::gpio::{self, AnyPin}; |
| 13 | use crate::gpio::{Pin as GpioPin, PselBits}; | 14 | use crate::gpio::{Pin as GpioPin, PselBits}; |
| @@ -273,8 +274,9 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 273 | Ok(_) => Ok(()), | 274 | Ok(_) => Ok(()), |
| 274 | Err(Error::DMABufferNotInDataMemory) => { | 275 | Err(Error::DMABufferNotInDataMemory) => { |
| 275 | trace!("Copying SPIM tx buffer into RAM for DMA"); | 276 | trace!("Copying SPIM tx buffer into RAM for DMA"); |
| 276 | let tx_copied = tx.clone(); | 277 | let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE]; |
| 277 | self.blocking_inner_from_ram(rx, tx_copied) | 278 | tx_buf[..tx.len()].copy_from_slice(tx); |
| 279 | self.blocking_inner_from_ram(rx, &tx_buf[..tx.len()]) | ||
| 278 | } | 280 | } |
| 279 | Err(error) => Err(error), | 281 | Err(error) => Err(error), |
| 280 | } | 282 | } |
| @@ -304,8 +306,9 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 304 | Ok(_) => Ok(()), | 306 | Ok(_) => Ok(()), |
| 305 | Err(Error::DMABufferNotInDataMemory) => { | 307 | Err(Error::DMABufferNotInDataMemory) => { |
| 306 | trace!("Copying SPIM tx buffer into RAM for DMA"); | 308 | trace!("Copying SPIM tx buffer into RAM for DMA"); |
| 307 | let tx_copied = tx.clone(); | 309 | let mut tx_buf = [0u8; FORCE_COPY_BUFFER_SIZE]; |
| 308 | self.async_inner_from_ram(rx, tx_copied).await | 310 | tx_buf[..tx.len()].copy_from_slice(tx); |
| 311 | self.async_inner_from_ram(rx, &tx_buf[..tx.len()]).await | ||
| 309 | } | 312 | } |
| 310 | Err(error) => Err(error), | 313 | Err(error) => Err(error), |
| 311 | } | 314 | } |
