Skip to content

Commit

Permalink
Properly reset descriptors in DmaRxStreamBuf::prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Jan 4, 2025
1 parent 713cd49 commit 4d8b9ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `spi::master::Spi::{into_async, into_blocking}` are now correctly available on the typed driver, to. (#2674)
- It is no longer possible to safely conjure `GpioPin` instances (#2688)
- UART: Public API follows `C-WORD_ORDER` Rust API standard (`VerbObject` order) (#2851)
- `DmaRxStreamBuf` now correctly resets the descriptors the next time it's used (#2890)

### Removed

Expand Down
14 changes: 6 additions & 8 deletions esp-hal/src/dma/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,13 +1137,6 @@ impl DmaRxStreamBuf {
return Err(DmaBufError::InsufficientDescriptors);
}

// Link up all the descriptors (but not in a circle).
let mut next = null_mut();
for desc in descriptors.iter_mut().rev() {
desc.next = next;
next = desc;
}

let mut chunks = buffer.chunks_exact_mut(chunk_size);
for (desc, chunk) in descriptors.iter_mut().zip(chunks.by_ref()) {
desc.buffer = chunk.as_mut_ptr();
Expand Down Expand Up @@ -1176,7 +1169,12 @@ unsafe impl DmaRxBuffer for DmaRxStreamBuf {
type View = DmaRxStreamBufView;

fn prepare(&mut self) -> Preparation {
for desc in self.descriptors.iter_mut() {
// Link up all the descriptors (but not in a circle).
let mut next = null_mut();
for desc in self.descriptors.iter_mut().rev() {
desc.next = next;
next = desc;

desc.reset_for_rx();
}
Preparation {
Expand Down

0 comments on commit 4d8b9ef

Please sign in to comment.