Skip to content

Commit

Permalink
Simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 27, 2024
1 parent d375aad commit 89bad7f
Show file tree
Hide file tree
Showing 2 changed files with 525 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 @@ -1977,36 +1977,6 @@ pub 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 89bad7f

Please sign in to comment.