Struct imxrt_hal::dma::Peripheral[][src]

pub struct Peripheral<P, E, S, D = S> { /* fields omitted */ }

A DMA-capable peripheral

Peripheral wraps an object that can act as a source and / or destination for a DMA transfer. It provides an interface for scheduling transfers, and for knowing when transfers are complete.

Before constructing a Peripheral, you should configure the Channel as necessary. If you enable interrupts, you’re responsible for registering the interrupt, and for clearing the interrupt. The Peripheral has methods for clearing interrupts due to transfer and receive DMA channels.

See the module-level docs for an example of how to create and use a peripheral.

Implementations

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

pub fn new_receive(source: P, channel: Channel) -> Self[src]

Wraps a peripheral that can act as the source of a DMA transfer

pub fn start_receive(&mut self, buffer: D) -> Result<(), (D, Error<P::Error>)>[src]

Start a DMA transfer that transfers data from the peripheral into the supplied buffer

A complete transfer is signaled by is_receive_complete(), and possibly an interrupt.

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

Returns true if the receive is complete

pub fn receive_complete(&mut self) -> Option<D>[src]

Clears the flag that indicates the DMA transfer is complete, and disable the peripheral.

Users are required to call this to disable the source. Otherwise, the source may continue to generate DMA requests.

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

Indicates if the receive channel has generated an interrupt

pub fn receive_clear_interrupt(&mut self)[src]

Clears the interrupt flag on the receive 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 receive_cancel(&mut self) -> Option<D>[src]

Cancel a receive transfer

pub fn receive_release(self) -> (P, Channel)[src]

Release the peripheral and the channel

Users should ensure that any started transfer has completed. If the Peripheral was constructed with new_bidirectional(), callers should use bidirectional_release(); otherwise, the transfer channel will be dropped when this method returns.

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

Indicates if the DMA controller is actively moving data for this DMA request

It may not be moving data if

  • the transfer is complete, or there is no transfer
  • the transfer is preempted

impl<P, E, S> Peripheral<P, E, S, Circular<E>> where
    P: Source<E>,
    E: Element
[src]

pub fn read_half(&mut self) -> Option<ReadHalf<'_, E>>[src]

Returns the read half of the circular buffer that’s being used as a DMA transfer destination

Returns None if there’s no destination buffer, which may mean that there’s no active transfer.

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

pub fn new_transfer(destination: P, channel: Channel) -> Self[src]

Wraps a peripheral that can act as the destination of a DMA transfer

pub fn start_transfer(&mut self, buffer: S) -> Result<(), (S, Error<P::Error>)>[src]

Start a DMA transfer that transfers data from the supplied buffer to the peripheral

A complete transfer is signaled by is_transfer_complete(), and possibly an interrupt.

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

Returns true if the transfer is complete

pub fn transfer_complete(&mut self) -> Option<S>[src]

Clears the flag that indicates the DMA transfer is complete, and disable the peripheral.

Users are required to call this to disable the source. Otherwise, the source may continue to generate DMA requests.

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

Indicates if the transfer channel has generated an interrupt

pub fn transfer_clear_interrupt(&mut self)[src]

Clears the interrupt flag on the transfer 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 transfer_cancel(&mut self) -> Option<S>[src]

Cancel a transfer that sends data to the peripheral

pub fn transfer_release(self) -> (P, Channel)[src]

Release the peripheral and the channel

Users should ensure that any started transfer has completed. If the Peripheral was constructed with new_bidirectional(), callers should use bidirectional_release(); otherwise, the receiver channel will be dropped when this method returns.

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

Indicates if the DMA controller is actively moving data for this DMA request

It may not be moving data if

  • the transfer is complete, or there is no transfer
  • the transfer is preempted

impl<P, E, D> Peripheral<P, E, Circular<E>, D> where
    P: Destination<E>,
    E: Element
[src]

pub fn write_half(&mut self) -> Option<WriteHalf<'_, E>>[src]

Returns the write half of the circular buffer that’s being used as a DMA transfer source.

Returns None if there’s no source buffer, which may mean that there’s no active transfer.

You may use the WriteHalf to prepare data for another DMA transfer.

impl<P, E, S, D> Peripheral<P, E, S, D> where
    P: Source<E> + Destination<E>,
    E: Element,
    S: Source<E>,
    D: Destination<E>, 
[src]

pub fn new_bidirectional(peripheral: P, tx: Channel, rx: Channel) -> Self[src]

Wraps a peripheral that can act as both the source and destination of a DMA transfer

pub fn bidirectional_release(self) -> (P, (Channel, Channel))[src]

Release the peripheral and both channels (transfer channel, release channel)

Users should ensure that any active transfers are complete before releasing the peripheral.

Auto Trait Implementations

impl<P, E, S, D> Send for Peripheral<P, E, S, D> where
    D: Send,
    E: Send,
    P: Send,
    S: Send

impl<P, E, S, D = S> !Sync for Peripheral<P, E, S, D>

impl<P, E, S, D> Unpin for Peripheral<P, E, S, D> where
    D: Unpin,
    E: Unpin,
    P: 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.