pub struct DmaTxStreamBuf { /* private fields */ }unstable only.Expand description
DMA Streaming Transmit Buffer.
This is symmetric implementation to DmaRxStreamBuf, used for continuously streaming data to a peripheral’s FIFO.
The list starts out like so A(full) -> B(full) -> C(full) -> D(full) -> NULL.
As the DMA writes to FIFO, the list progresses like so:
A(full) -> B(full) -> C(full) -> D(full) -> NULLA(empty) -> B(full) -> C(full) -> D(full) -> NULLA(empty) -> B(empty) -> C(full) -> D(full) -> NULLA(empty) -> B(empty) -> C(empty) -> D(full) -> NULL
As you call DmaTxStreamBufView::push the list (approximately) progresses like so:
A(empty) -> B(empty) -> C(empty) -> D(full) -> NULLB(empty) -> C(empty) -> D(full) -> A(full) -> NULLC(empty) -> D(full) -> A(full) -> B(full) -> NULLD(full) -> A(full) -> B(full) -> C(full) -> NULL
If all the descriptors run out, the DmaTxInterrupt::TotalEof interrupt will fire and DMA will stop writing, at which point it is up to you to resume/restart the transfer.
Implementations§
Source§impl DmaTxStreamBuf
impl DmaTxStreamBuf
Sourcepub fn new(
descriptors: DmaAlignedMut<'static, [DmaDescriptor]>,
buffer: DmaAlignedMut<'static, [u8]>,
) -> Result<Self, DmaBufError>
pub fn new( descriptors: DmaAlignedMut<'static, [DmaDescriptor]>, buffer: DmaAlignedMut<'static, [u8]>, ) -> Result<Self, DmaBufError>
Creates a new DmaTxStreamBuf evenly distributing the buffer between the provided descriptors.
Sourcepub fn split(
self,
) -> (DmaAlignedMut<'static, [DmaDescriptor]>, DmaAlignedMut<'static, [u8]>)
pub fn split( self, ) -> (DmaAlignedMut<'static, [DmaDescriptor]>, DmaAlignedMut<'static, [u8]>)
Consume the buf, returning the descriptors and buffer.
Sourcepub fn push(&mut self, data: &[u8]) -> usize
pub fn push(&mut self, data: &[u8]) -> usize
Push the buffer with the given data before DMA transfer starts.
It’s expected to pre-fill at least enough data to fill the first two descriptors’ buffers. The more data is pre-filled, the more head-room is left to push more data.
Sourcepub fn push_with(&mut self, f: impl FnOnce(&mut [u8]) -> usize) -> usize
pub fn push_with(&mut self, f: impl FnOnce(&mut [u8]) -> usize) -> usize
Push the buffer with the given data before DMA transfer starts.
It’s expected to pre-fill at least enough data to fill the first two descriptors’ buffers. The more data is pre-filled, the more head-room is left to push more data.
Returns the number of bytes filled.