pub struct DmaRxStreamBuf { /* private fields */ }unstable only.Expand description
DMA Streaming Receive Buffer.
This is a contiguous buffer linked together by DMA descriptors, and the buffer is evenly distributed between each descriptor provided.
It is used for continuously streaming data from a peripheral’s FIFO.
It maintains a sliding window of descriptors that progresses when DmaRxStreamBufView::consume is called.
The list starts out like so A (empty) -> B (empty) -> C (empty) -> D (empty) -> NULL.
As the DMA writes to the buffers the list progresses like so:
A (empty) -> B (empty) -> C (empty) -> D (empty) -> NULLA (full) -> B (empty) -> C (empty) -> D (empty) -> NULLA (full) -> B (full) -> C (empty) -> D (empty) -> NULLA (full) -> B (full) -> C (full) -> D (empty) -> NULL
As DmaRxStreamBufView::consume is called, the list (approximately) progresses like so:
A (full) -> B (full) -> C (full) -> D (empty) -> NULLB (full) -> C (full) -> D (empty) -> A (empty) -> NULLC (full) -> D (empty) -> A (empty) -> B (empty) -> NULLD (empty) -> A (empty) -> B (empty) -> C (empty) -> NULL
If all the descriptors fill up, the DmaRxInterrupt::DescriptorEmpty interrupt fires and the DMA stops writing. The transfer must then be resumed or restarted.
This buffer does not indicate when this condition occurs. Check with the driver to see if the DMA has stopped.
When constructing this buffer, tune the ratio between the chunk size and buffer size appropriately. Smaller chunk sizes mean data is received more frequently, but the DMA interrupts (DmaRxInterrupt::Done) also fire more frequently when they are used.
See DmaRxStreamBufView for APIs available while a transfer is in progress.
Implementations§
Source§impl DmaRxStreamBuf
impl DmaRxStreamBuf
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 DmaRxStreamBuf 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]>)
Consumes the buf, returning the descriptors and buffer.