Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading/writing small buffers #1760

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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