Struct Transfer

Source
pub struct Transfer<T: Target, B, State> { /* private fields */ }
Expand description

Represents an ongoing DMA transfer

Peripheral APIs that support DMA have methods like write_all and read_all, which return instances of this struct.

Implementations§

Source§

impl<T, B> Transfer<T, B, Ready>
where T: Target, B: 'static,

Source

pub fn enable_interrupts( &mut self, handle: &Handle<T::Instance, Enabled>, interrupts: Interrupts, )

Enables the given interrupts for this DMA transfer

These interrupts are only enabled for this transfer. The settings doesn’t affect other transfers, nor subsequent transfers using the same DMA stream.

Source

pub fn start( self, handle: &Handle<T::Instance, Enabled>, ) -> Transfer<T, B, Started>

Start the DMA transfer

Consumes this instance of Transfer and returns another instance with its type state set to indicate the transfer has been started.

Source§

impl<T, B> Transfer<T, B, Started>
where T: Target,

Source

pub fn is_active(&self, handle: &Handle<T::Instance, Enabled>) -> bool

Checks whether the transfer is still ongoing

Source

pub fn cancel(&self, handle: &Handle<T::Instance, Enabled>)

Try to cancel an in process transfer. Check is_active to verify cancellation

Source

pub fn wait( self, handle: &Handle<T::Instance, Enabled>, ) -> Result<TransferResources<T, B>, (TransferResources<T, B>, Error)>

Waits for the transfer to end

This method will block if the transfer is still ongoing. If you want this method to return immediately, first check whether the transfer is still ongoing by calling is_active.

An ongoing transfer needs exlusive access to some resources, namely the data buffer, the DMA stream, and the peripheral. Those have been moved into the Transfer instance to prevent concurrent access to them. This method returns those resources, so they can be used again.

Auto Trait Implementations§

§

impl<T, B, State> Freeze for Transfer<T, B, State>
where State: Freeze, <T as Target>::Stream: Freeze, T: Freeze, B: Freeze,

§

impl<T, B, State> RefUnwindSafe for Transfer<T, B, State>

§

impl<T, B, State> Send for Transfer<T, B, State>
where State: Send, <T as Target>::Stream: Send, T: Send, B: Send,

§

impl<T, B, State> Sync for Transfer<T, B, State>
where State: Sync, <T as Target>::Stream: Sync, T: Sync, B: Sync,

§

impl<T, B, State> Unpin for Transfer<T, B, State>
where State: Unpin, <T as Target>::Stream: Unpin, T: Unpin, B: Unpin,

§

impl<T, B, State> UnwindSafe for Transfer<T, B, State>
where State: UnwindSafe, <T as Target>::Stream: UnwindSafe, T: UnwindSafe, B: UnwindSafe,

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.