pub struct DmaChannel<'a> { /* private fields */ }Expand description
DMA channel driver.
Implementations§
Source§impl<'a> DmaChannel<'a>
impl<'a> DmaChannel<'a>
Source§impl DmaChannel<'_>
impl DmaChannel<'_>
Sourcepub fn reborrow(&mut self) -> DmaChannel<'_>
pub fn reborrow(&mut self) -> DmaChannel<'_>
Reborrow the DmaChannel with a shorter lifetime.
Sourcepub fn mem_to_mem<W: Word>(
&mut self,
src: &[W],
dst: &mut [W],
options: TransferOptions,
) -> Result<Transfer<'_>, InvalidParameters>
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 bufferdst- 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.
Sourcepub fn memset<W: Word>(
&mut self,
pattern: &W,
dst: &mut [W],
options: TransferOptions,
) -> Result<Transfer<'_>, InvalidParameters>
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 filloptions- 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 0xDEADBEEFSourcepub unsafe fn write_to_peripheral<W: Word>(
&mut self,
buf: &[W],
peri_addr: *mut W,
options: TransferOptions,
) -> Result<Transfer<'_>, InvalidParameters>
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 fromperi_addr- Peripheral register addressoptions- Transfer configuration options
§Safety
- The buffer must remain valid for the duration of the transfer.
- The peripheral address must be valid for writes.
Sourcepub unsafe fn read_from_peripheral<W: Word>(
&mut self,
peri_addr: *const W,
buf: &mut [W],
options: TransferOptions,
) -> Result<Transfer<'_>, InvalidParameters>
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 addressbuf- Destination buffer to read intooptions- Transfer configuration options
§Safety
- The buffer must remain valid for the duration of the transfer.
- The peripheral address must be valid for reads.
Sourcepub fn transferred_bytes(&self) -> usize
pub fn transferred_bytes(&self) -> usize
Produce the number of bytes transferred at the time of calling this function.