Struct DmaRxBuf

Source
pub struct DmaRxBuf { /* private fields */ }
Available on crate feature 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

Source

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.

Source

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.

Source

pub fn set_burst_config( &mut self, burst: BurstConfig, ) -> Result<(), DmaBufError>

Configures the DMA to use burst transfers to access this buffer.

Source

pub fn split(self) -> (&'static mut [DmaDescriptor], &'static mut [u8])

Consume the buf, returning the descriptors and buffer.

Source

pub fn capacity(&self) -> usize

Returns the size of the underlying buffer

Source

pub fn len(&self) -> usize

Returns the maximum number of bytes that this buf has been configured to receive.

Source

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.

Source

pub fn as_slice(&self) -> &[u8]

Returns the entire underlying buffer as a slice than can be read.

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Returns the entire underlying buffer as a slice than can be written.

Source

pub fn number_of_received_bytes(&self) -> usize

Return the number of bytes that was received by this buf.

Source

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.

Source

pub fn received_data(&self) -> impl Iterator<Item = &[u8]>

Returns the received data as an iterator of slices.

Trait Implementations§

Source§

impl Debug for DmaRxBuf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DmaRxBuffer for DmaRxBuf

Source§

type View = BufView<DmaRxBuf>

A type providing operations that are safe to perform on the buffer whilst the DMA is actively using it.
Source§

fn prepare(&mut self) -> Preparation

Prepares the buffer for an imminent transfer and returns information required to use this buffer. Read more
Source§

fn into_view(self) -> BufView<DmaRxBuf>

This is called before the DMA starts using the buffer.
Source§

fn from_view(view: Self::View) -> Self

This is called after the DMA is done using the buffer.

Auto Trait Implementations§

§

impl Freeze for DmaRxBuf

§

impl RefUnwindSafe for DmaRxBuf

§

impl Send for DmaRxBuf

§

impl !Sync for DmaRxBuf

§

impl Unpin for DmaRxBuf

§

impl !UnwindSafe for DmaRxBuf

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.