Struct DmaTxBuf

Source
pub struct DmaTxBuf { /* private fields */ }
Available on crate feature unstable only.
Expand description

DMA transmit buffer

This is a contiguous buffer linked together by DMA descriptors of length 4095 at most. It can only be used for transmitting data to a peripheral’s FIFO. See DmaRxBuf for receiving data.

Implementations§

Source§

impl DmaTxBuf

Source

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

Creates a new DmaTxBuf 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 4095 bytes worth of buffer.

Both the descriptors and buffer must be in DMA-capable memory. Only DRAM is supported for descriptors.

Source

pub fn new_with_config( descriptors: &'static mut [DmaDescriptor], buffer: &'static mut [u8], config: impl Into<BurstConfig>, ) -> Result<Self, DmaBufError>

Creates a new DmaTxBuf 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 4095 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

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

Source

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

Reset the descriptors to only transmit len amount of bytes from this buf.

The number of bytes in data must be less than or equal to the buffer size.

Source

pub fn fill(&mut self, data: &[u8])

Fills the TX buffer with the bytes provided in data and reset the descriptors to only cover the filled section.

The number of bytes in data must be less than or equal to the buffer size.

Source

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

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

Source

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

Returns the buf as a slice than can be read.

Trait Implementations§

Source§

impl Debug for DmaTxBuf

Source§

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

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

impl DmaTxBuffer for DmaTxBuf

Source§

type View = BufView<DmaTxBuf>

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<DmaTxBuf>

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 Format for DmaTxBuf
where DescriptorSet<'static>: Format, &'static mut [u8]: Format, BurstConfig: Format,

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

§

impl Freeze for DmaTxBuf

§

impl RefUnwindSafe for DmaTxBuf

§

impl Send for DmaTxBuf

§

impl !Sync for DmaTxBuf

§

impl Unpin for DmaTxBuf

§

impl !UnwindSafe for DmaTxBuf

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.

§

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.