From 7e981a5376da745b29699573b5c3601c8a6b16e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Quentin?= Date: Mon, 15 Jul 2024 13:06:03 +0200 Subject: [PATCH] Fix reading/writing small buffers (#1760) * Fix reading/writing small buffers * CHANGELOG.md --- esp-hal/CHANGELOG.md | 1 + esp-hal/src/spi/master.rs | 16 +--------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 88c950ec0a9..e66b779c093 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `regi2c_*` functions for `esp32h2` (#1737) - Improved `#[ram(zeroed)]` soundness by adding a `bytemuck::Zeroable` type bound (#1677) - EESP32-S2 / ESP32-S3: Fix UsbDm and UsbDp for Gpio19 and Gpio20 +- Fix reading/writing small buffers via SPI master async dma (#1760) ### Changed diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 8a67b4ada3b..ca7a8c7f218 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -1140,7 +1140,6 @@ pub mod dma { ptr, len, &mut self.channel.tx, - false, )?; } Ok(()) @@ -1196,7 +1195,6 @@ pub mod dma { ptr, len, &mut self.channel.rx, - false, )?; } @@ -1353,7 +1351,6 @@ pub mod dma { ptr, len, &mut self.channel.rx, - false, )?; } Ok(DmaTransferRx::new(self)) @@ -1433,7 +1430,6 @@ pub mod dma { ptr, len, &mut self.channel.tx, - false, )?; } Ok(DmaTransferTx::new(self)) @@ -1556,7 +1552,6 @@ pub mod dma { words.as_mut_ptr(), words.len(), future.rx(), - true, )?; } future.await?; @@ -1573,7 +1568,6 @@ pub mod dma { chunk.as_ptr(), chunk.len(), future.tx(), - true, )?; } future.await?; @@ -2048,7 +2042,7 @@ where ) -> Result<&'w [u8], Error> { for chunk in words.chunks(MAX_DMA_SIZE) { unsafe { - self.start_write_bytes_dma(chain, chunk.as_ptr(), chunk.len(), tx, false)?; + self.start_write_bytes_dma(chain, chunk.as_ptr(), chunk.len(), tx)?; } while !tx.is_done() {} @@ -2065,7 +2059,6 @@ where ptr: *const u8, len: usize, tx: &mut TX, - listen: bool, ) -> Result<(), Error> { let reg_block = self.register_block(); self.configure_datalen(len as u32 * 8); @@ -2085,9 +2078,6 @@ where self.clear_dma_interrupts(); reset_dma_before_usr_cmd(reg_block); - if listen { - tx.listen_eof(); - } reg_block.cmd().modify(|_, w| w.usr().set_bit()); Ok(()) @@ -2100,7 +2090,6 @@ where ptr: *mut u8, len: usize, rx: &mut RX, - listen: bool, ) -> Result<(), Error> { let reg_block = self.register_block(); self.configure_datalen(len as u32 * 8); @@ -2118,9 +2107,6 @@ where self.clear_dma_interrupts(); reset_dma_before_usr_cmd(reg_block); - if listen { - rx.listen_eof(); - } reg_block.cmd().modify(|_, w| w.usr().set_bit()); Ok(())