DmaRxTxBuf

Struct DmaRxTxBuf 

Source
pub struct DmaRxTxBuf { /* private fields */ }
Expand description

DMA transmit and receive buffer.

This is a (single) contiguous buffer linked together by two sets of DMA descriptors of length 4092 each. It can be used for simultaneously transmitting to and receiving from a peripheral’s FIFO. These are typically full-duplex transfers.

Implementations§

Source§

impl DmaRxTxBuf

Source

pub fn new( rx_descriptors: &'static mut [DmaDescriptor], tx_descriptors: &'static mut [DmaDescriptor], buffer: &'static mut [u8], ) -> Result<Self, DmaBufError>

Creates a new DmaRxTxBuf 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 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 [DmaDescriptor], &'static mut [u8])

Consume the buf, returning the rx descriptors, tx descriptors and buffer.

Source

pub fn capacity(&self) -> usize

Return the size of the underlying buffer.

Source

pub fn len(&self) -> usize

Return the number of bytes that would be transmitted by this buf.

Source

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

Returns the entire buf as a slice than can be read.

Source

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

Returns the entire buf as a slice than can be written.

Source

pub fn set_length(&mut self, len: usize)

Reset the descriptors to only transmit/receive len amount of bytes with this buf.

len must be less than or equal to the buffer size.

Trait Implementations§

Source§

impl Debug for DmaRxTxBuf

Available on crate feature unstable only.
Source§

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

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

impl DmaRxBuffer for DmaRxTxBuf

Available on crate feature unstable only.
Source§

type View = BufView<DmaRxTxBuf>

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

type Final = DmaRxTxBuf

The type returned to the user when a transfer finishes. Read more
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<DmaRxTxBuf>

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.
Source§

impl DmaTxBuffer for DmaRxTxBuf

Available on crate feature unstable only.
Source§

type View = BufView<DmaRxTxBuf>

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

type Final = DmaRxTxBuf

The type returned to the user when a transfer finishes. Read more
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<DmaRxTxBuf>

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 DmaRxTxBuf

§

impl RefUnwindSafe for DmaRxTxBuf

§

impl Send for DmaRxTxBuf

§

impl !Sync for DmaRxTxBuf

§

impl Unpin for DmaRxTxBuf

§

impl !UnwindSafe for DmaRxTxBuf

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.