embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

DmaChannel

Struct DmaChannel 

Source
pub struct DmaChannel<'a> { /* private fields */ }
Expand description

DMA channel driver.

Implementations§

Source§

impl<'a> DmaChannel<'a>

Source

pub fn new<C: Channel>(channel: Peri<'a, C>) -> Self

Wrap a DMA channel token (takes ownership of the Peri wrapper).

Note: DMA is initialized during hal::init() via dma::init().

Source§

impl DmaChannel<'_>

Source

pub fn reborrow(&mut self) -> DmaChannel<'_>

Reborrow the DmaChannel with a shorter lifetime.

Source

pub fn mem_to_mem<W: Word>( &mut self, src: &[W], dst: &mut [W], options: TransferOptions, ) -> Result<Transfer<'_>, InvalidParameters>

Perform a memory-to-memory DMA transfer (simplified API).

This is a type-safe wrapper that uses the Word trait to determine the correct transfer width automatically. Uses the global eDMA TCD register accessor internally.

§Arguments
  • src - Source buffer
  • dst - Destination buffer (must be at least as large as src)
  • options - Transfer configuration options
§Safety

The source and destination buffers must remain valid for the duration of the transfer.

Source

pub fn memset<W: Word>( &mut self, pattern: &W, dst: &mut [W], options: TransferOptions, ) -> Result<Transfer<'_>, InvalidParameters>

Fill a memory buffer with a pattern value (memset).

This performs a DMA transfer where the source address remains fixed (pattern value) while the destination address increments through the buffer. It’s useful for quickly filling large memory regions with a constant value.

§Arguments
  • pattern - Reference to the pattern value (will be read repeatedly)
  • dst - Destination buffer to fill
  • options - Transfer configuration options
§Example
use embassy_mcxa::dma::{DmaChannel, TransferOptions};

let dma_ch = DmaChannel::new(p.DMA_CH0);
let pattern: u32 = 0xDEADBEEF;
let mut buffer = [0u32; 256];

unsafe {
    dma_ch.memset(&pattern, &mut buffer, TransferOptions::default()).await;
}
// buffer is now filled with 0xDEADBEEF
Source

pub unsafe fn write_to_peripheral<W: Word>( &mut self, buf: &[W], peri_addr: *mut W, options: TransferOptions, ) -> Result<Transfer<'_>, InvalidParameters>

Write data from memory to a peripheral register.

The destination address remains fixed (peripheral register) while the source address increments through the buffer.

§Arguments
  • buf - Source buffer to write from
  • peri_addr - Peripheral register address
  • options - Transfer configuration options
§Safety
  • The buffer must remain valid for the duration of the transfer.
  • The peripheral address must be valid for writes.
Source

pub unsafe fn read_from_peripheral<W: Word>( &mut self, peri_addr: *const W, buf: &mut [W], options: TransferOptions, ) -> Result<Transfer<'_>, InvalidParameters>

Read data from a peripheral register to memory.

The source address remains fixed (peripheral register) while the destination address increments through the buffer.

§Arguments
  • peri_addr - Peripheral register address
  • buf - Destination buffer to read into
  • options - Transfer configuration options
§Safety
  • The buffer must remain valid for the duration of the transfer.
  • The peripheral address must be valid for reads.
Source

pub fn transferred_bytes(&self) -> usize

Produce the number of bytes transferred at the time of calling this function.

Auto Trait Implementations§

§

impl<'a> Freeze for DmaChannel<'a>

§

impl<'a> RefUnwindSafe for DmaChannel<'a>

§

impl<'a> Send for DmaChannel<'a>

§

impl<'a> Sync for DmaChannel<'a>

§

impl<'a> Unpin for DmaChannel<'a>

§

impl<'a> !UnwindSafe for DmaChannel<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.