Skip to main content

DmaTxStreamBuf

Struct DmaTxStreamBuf 

Source
pub struct DmaTxStreamBuf { /* private fields */ }
Available on crate feature 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) -> NULL
  • A(empty) -> B(full) -> C(full) -> D(full) -> NULL
  • A(empty) -> B(empty) -> C(full) -> D(full) -> NULL
  • A(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) -> NULL
  • B(empty) -> C(empty) -> D(full) -> A(full) -> NULL
  • C(empty) -> D(full) -> A(full) -> B(full) -> NULL
  • D(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

Source

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.

Source

pub fn split( self, ) -> (DmaAlignedMut<'static, [DmaDescriptor]>, DmaAlignedMut<'static, [u8]>)

Consume the buf, returning the descriptors and buffer.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for DmaTxStreamBuf

Source§

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

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

impl DmaTxBuffer for DmaTxStreamBuf

Source§

type View = DmaTxStreamBufView

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

type Final = DmaTxStreamBuf

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) -> Self::View

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 !Sync for DmaTxStreamBuf

§

impl !UnwindSafe for DmaTxStreamBuf

§

impl Freeze for DmaTxStreamBuf

§

impl RefUnwindSafe for DmaTxStreamBuf

§

impl Send for DmaTxStreamBuf

§

impl Unpin for DmaTxStreamBuf

§

impl UnsafeUnpin for DmaTxStreamBuf

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.