pub struct DmaRxBuf { /* private fields */ }
unstable
only.Expand description
DMA receive buffer
This is a contiguous buffer linked together by DMA descriptors of length 4092. It can only be used for receiving data from a peripheral’s FIFO. See DmaTxBuf for transmitting data.
Implementations§
Source§impl DmaRxBuf
impl DmaRxBuf
Sourcepub fn new(
descriptors: &'static mut [DmaDescriptor],
buffer: &'static mut [u8],
) -> Result<Self, DmaBufError>
pub fn new( descriptors: &'static mut [DmaDescriptor], buffer: &'static mut [u8], ) -> Result<Self, DmaBufError>
Creates a new DmaRxBuf from some descriptors and a buffer.
There must be enough descriptors for the provided buffer. Each descriptor can handle 4092 bytes worth of buffer.
Both the descriptors and buffer must be in DMA-capable memory. Only DRAM is supported.
Sourcepub fn new_with_config(
descriptors: &'static mut [DmaDescriptor],
buffer: &'static mut [u8],
config: impl Into<BurstConfig>,
) -> Result<Self, DmaBufError>
pub fn new_with_config( descriptors: &'static mut [DmaDescriptor], buffer: &'static mut [u8], config: impl Into<BurstConfig>, ) -> Result<Self, DmaBufError>
Creates a new DmaRxBuf from some descriptors and a buffer.
There must be enough descriptors for the provided buffer. Depending on alignment requirements, each descriptor can handle at most 4092 bytes worth of buffer.
Both the descriptors and buffer must be in DMA-capable memory. Only DRAM is supported for descriptors.
Sourcepub fn set_burst_config(
&mut self,
burst: BurstConfig,
) -> Result<(), DmaBufError>
pub fn set_burst_config( &mut self, burst: BurstConfig, ) -> Result<(), DmaBufError>
Configures the DMA to use burst transfers to access this buffer.
Sourcepub fn split(self) -> (&'static mut [DmaDescriptor], &'static mut [u8])
pub fn split(self) -> (&'static mut [DmaDescriptor], &'static mut [u8])
Consume the buf, returning the descriptors and buffer.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the maximum number of bytes that this buf has been configured to receive.
Sourcepub fn set_length(&mut self, len: usize)
pub fn set_length(&mut self, len: usize)
Reset the descriptors to only receive len
amount of bytes into this
buf.
The number of bytes in data must be less than or equal to the buffer size.
Sourcepub fn as_slice(&self) -> &[u8]
pub fn as_slice(&self) -> &[u8]
Returns the entire underlying buffer as a slice than can be read.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8]
pub fn as_mut_slice(&mut self) -> &mut [u8]
Returns the entire underlying buffer as a slice than can be written.
Sourcepub fn number_of_received_bytes(&self) -> usize
pub fn number_of_received_bytes(&self) -> usize
Return the number of bytes that was received by this buf.
Sourcepub fn read_received_data(&self, buf: &mut [u8]) -> usize
pub fn read_received_data(&self, buf: &mut [u8]) -> usize
Reads the received data into the provided buf
.
If buf.len()
is less than the amount of received data then only the
first buf.len()
bytes of received data is written into buf
.
Returns the number of bytes in written to buf
.
Sourcepub fn received_data(&self) -> impl Iterator<Item = &[u8]>
pub fn received_data(&self) -> impl Iterator<Item = &[u8]>
Returns the received data as an iterator of slices.