pub struct Transfer<Word: SupportedWordSize, I, P, Buffer, Rx: Target, Tx: Target, State> { /* private fields */ }Expand description
A DMA transfer of the SPI peripheral
Since DMA can send and receive at the same time, using two DMA transfers and
two DMA streams, we need this type to represent this operation and wrap the
underlying dma::Transfer instances.
Implementations§
Source§impl<Word, I, P, Buffer, Rx, Tx> Transfer<Word, I, P, Buffer, Rx, Tx, Ready>
impl<Word, I, P, Buffer, Rx, Tx> Transfer<Word, I, P, Buffer, Rx, Tx, Ready>
Sourcepub fn enable_interrupts(
&mut self,
rx_handle: &Handle<Rx::Instance, Enabled>,
tx_handle: &Handle<Tx::Instance, Enabled>,
interrupts: Interrupts,
)
pub fn enable_interrupts( &mut self, rx_handle: &Handle<Rx::Instance, Enabled>, tx_handle: &Handle<Tx::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 streams.
Sourcepub fn start(
self,
rx_handle: &Handle<Rx::Instance, Enabled>,
tx_handle: &Handle<Tx::Instance, Enabled>,
) -> Transfer<Word, I, P, Buffer, Rx, Tx, Started>
pub fn start( self, rx_handle: &Handle<Rx::Instance, Enabled>, tx_handle: &Handle<Tx::Instance, Enabled>, ) -> Transfer<Word, I, P, Buffer, Rx, Tx, 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<Word, I, P, Buffer, Rx, Tx> Transfer<Word, I, P, Buffer, Rx, Tx, Started>
impl<Word, I, P, Buffer, Rx, Tx> Transfer<Word, I, P, Buffer, Rx, Tx, Started>
Sourcepub fn is_active(
&self,
rx_handle: &Handle<Rx::Instance, Enabled>,
tx_handle: &Handle<Tx::Instance, Enabled>,
) -> bool
pub fn is_active( &self, rx_handle: &Handle<Rx::Instance, Enabled>, tx_handle: &Handle<Tx::Instance, Enabled>, ) -> bool
Checks whether the transfer is still ongoing
Sourcepub fn wait(
self,
rx_handle: &Handle<Rx::Instance, Enabled>,
tx_handle: &Handle<Tx::Instance, Enabled>,
) -> WaitResult<Word, I, P, Rx, Tx, Buffer>
pub fn wait( self, rx_handle: &Handle<Rx::Instance, Enabled>, tx_handle: &Handle<Tx::Instance, Enabled>, ) -> WaitResult<Word, I, P, Rx, Tx, Buffer>
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.