Struct imxrt_hal::dma::Memcpy[][src]

pub struct Memcpy<E, S, D> { /* fields omitted */ }

A type that can peform memory-to-memory DMA transfers

Methods that start transfers will return immediately. Then, you may query for DMA completion.

A Memcpy accepts either a Linear or a Circular buffer.

Example

use imxrt_hal::dma;

static SOURCE: dma::Buffer<[u8; 32]> = dma::Buffer::new([0; 32]);
static DESTINATION: dma::Buffer<[u8; 64]> = dma::Buffer::new([0; 64]);

let mut peripherals = imxrt_hal::Peripherals::take().unwrap();
let mut dma_channels = peripherals.dma.clock(&mut peripherals.ccm.handle);
let mut dma_channel = dma_channels[7].take().unwrap();
dma_channel.set_interrupt_on_completion(false);

let mut memcpy = dma::Memcpy::new(dma_channel);

let mut source = dma::Linear::new(&SOURCE).unwrap();
let mut destination = dma::Linear::new(&DESTINATION).unwrap();

source.as_mut_elements()[..14].copy_from_slice(&[8; 14]);
source.set_transfer_len(14);
destination.set_transfer_len(12);
// Total 12 elements transferred

// Begin the transfer
memcpy.transfer(source, destination).unwrap();

// Wait for the transfer...
while !memcpy.is_complete() {}

// Transfer complete! It's safe to look at the destination.
// Don't forget to clear the complete signal.
let (source, destination) = memcpy.complete().unwrap().unwrap();

Implementations

impl<E: Element, S, D> Memcpy<E, S, D> where
    S: Source<E>,
    D: Destination<E>, 
[src]

pub fn new(channel: Channel) -> Self[src]

Create a type that can perform memory-to-memory DMA transfers

pub fn take(self) -> Channel[src]

Take the underlying DMA channel, and destroy the Memcpy

pub fn transfer(
    &mut self,
    source: S,
    destination: D
) -> Result<(), (S, D, Error<Void>)>
[src]

Transfer data from the source buffer to the destination buffer

If transfer() returns Ok(()), the transfer is in progress. Use is_complete() to check on the transfer status.

The number of elements transferred is the minimum size of the two buffers.

pub fn is_complete(&self) -> bool[src]

Returns true if the transfer is complete, or false if the transfer is not complete

Once is_complete() returns true, you should finish the transfer by calling complete().

pub fn is_interrupt(&self) -> bool[src]

Returns true if this transfer has generated an interrupt

pub fn clear_interrupt(&mut self)[src]

Clears the interrupt flag on the channel

Users are required to clear the interrupt flag, or the hardware may continue to generate interrupts for the channel. This must be called for completion interrupts and half-transfer interrupts.

pub fn complete(&mut self) -> Option<Result<(S, D), (S, D)>>[src]

Complete the memory-to-memory the DMA transfer

If complete() is called before the transfer is complete, the transfer is canceled. If the transfer is cancelled, the contents of the receive buffer are unspecified. Await is_complete() before calling complete() to avoid early transfer cancellation.

  • None indicates that there’s no scheduled transfer; we have no buffers
  • Some(Ok(..)) indicates that the transfer was complete when complete() was called
  • Some(Err(..)) indicates that the transfer was in progress, but was cancelled

Auto Trait Implementations

impl<E, S, D> Send for Memcpy<E, S, D> where
    D: Send,
    E: Send,
    S: Send

impl<E, S, D> !Sync for Memcpy<E, S, D>

impl<E, S, D> Unpin for Memcpy<E, S, D> where
    D: Unpin,
    E: Unpin,
    S: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.