Skip to content

Commit

Permalink
Simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 30, 2024
1 parent 14e0d1d commit 9a8b091
Show file tree
Hide file tree
Showing 2 changed files with 520 additions and 618 deletions.
30 changes: 0 additions & 30 deletions esp-hal/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,36 +2086,6 @@ pub unsafe trait DmaTxBuffer {
fn length(&self) -> usize;
}

pub(crate) struct DmaBufferRef<'a, B> {
buffer: &'a mut B,
}

impl<'a, B> DmaBufferRef<'a, B> {
pub(crate) fn new(buffer: &'a mut B) -> Self {
Self { buffer }
}
}

impl<B: DmaTxBuffer> DmaTxBuffer for DmaBufferRef<'_, B> {
fn prepare(&mut self) -> Preparation {
self.buffer.prepare()
}

fn length(&self) -> usize {
self.buffer.length()
}
}

impl<B: DmaRxBuffer> DmaRxBuffer for DmaBufferRef<'_, B> {
fn prepare(&mut self) -> Preparation {
self.buffer.prepare()
}

fn length(&self) -> usize {
self.buffer.length()
}
}

/// [DmaRxBuffer] is a DMA descriptor + memory combo that can be used for
/// receiving data from a peripheral's FIFO to a DMA channel.
///
Expand Down
Loading

0 comments on commit 9a8b091

Please sign in to comment.