Skip to content

Commit

Permalink
Fix reading/writing small buffers (#1760)
Browse files Browse the repository at this point in the history
* Fix reading/writing small buffers

* CHANGELOG.md
  • Loading branch information
bjoernQ committed Jul 15, 2024
1 parent 45c8107 commit 7e981a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 1 addition & 15 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ pub mod dma {
ptr,
len,
&mut self.channel.tx,
false,
)?;
}
Ok(())
Expand Down Expand Up @@ -1196,7 +1195,6 @@ pub mod dma {
ptr,
len,
&mut self.channel.rx,
false,
)?;
}

Expand Down Expand Up @@ -1353,7 +1351,6 @@ pub mod dma {
ptr,
len,
&mut self.channel.rx,
false,
)?;
}
Ok(DmaTransferRx::new(self))
Expand Down Expand Up @@ -1433,7 +1430,6 @@ pub mod dma {
ptr,
len,
&mut self.channel.tx,
false,
)?;
}
Ok(DmaTransferTx::new(self))
Expand Down Expand Up @@ -1556,7 +1552,6 @@ pub mod dma {
words.as_mut_ptr(),
words.len(),
future.rx(),
true,
)?;
}
future.await?;
Expand All @@ -1573,7 +1568,6 @@ pub mod dma {
chunk.as_ptr(),
chunk.len(),
future.tx(),
true,
)?;
}
future.await?;
Expand Down Expand Up @@ -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() {}
Expand All @@ -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);
Expand All @@ -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(())
Expand All @@ -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);
Expand All @@ -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(())
Expand Down

0 comments on commit 7e981a5

Please sign in to comment.