Struct stm32f4xx_hal::dma::Transfer [−][src]
pub struct Transfer<STREAM, PERIPHERAL, DIRECTION, BUF, const CHANNEL: u8> where
STREAM: Stream,
PERIPHERAL: PeriAddress, { /* fields omitted */ }
Expand description
DMA Transfer.
Implementations
impl<STREAM, PERIPHERAL, BUF, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, MemoryToPeripheral, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, MemoryToPeripheral, CHANNEL>,
BUF: StaticReadBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
impl<STREAM, PERIPHERAL, BUF, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, MemoryToPeripheral, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, MemoryToPeripheral, CHANNEL>,
BUF: StaticReadBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
pub fn init_memory_to_peripheral(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: Option<BUF>,
config: DmaConfig
) -> Self
pub fn init_memory_to_peripheral(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: Option<BUF>,
config: DmaConfig
) -> Self
Configures the DMA stream to the correct channel for the peripheral, configures source and
destination and applies supplied configuration. If double buffering is enabled, the
number of transfers will be the minimum length of memory
and double_buf
.
Panics
- When double buffering is enabled but the
double_buf
argument isNone
.
Changes the buffer and restarts or continues a double buffer transfer. This must be called
immediately after a transfer complete event if using double buffering, otherwise you might
lose data. Returns the old buffer together with its CurrentBuffer
. If an error occurs,
this method will return the new buffer with the error.
This method will clear the transfer complete flag on entry, it will also clear it again if
an overrun occurs during its execution. Moreover, if an overrun occurs, the stream will be
disabled and the transfer error flag will be set. This method can be called before the end
of an ongoing transfer only if not using double buffering, in that case, the current
transfer will be canceled and a new one will be started. A NotReady
error will be returned
if this method is called before the end of a transfer while double buffering.
pub unsafe fn next_transfer_with<F, T>(
&mut self,
f: F
) -> Result<T, DMAError<()>> where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
pub unsafe fn next_transfer_with<F, T>(
&mut self,
f: F
) -> Result<T, DMAError<()>> where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
Changes the buffer and restarts or continues a double buffer transfer. This must be called
immediately after a transfer complete event if using double buffering, otherwise you might
lose data. The closure must return (BUF, T)
where BUF
is the new buffer to be used. This
method can be called before the end of an ongoing transfer only if not using double
buffering, in that case, the current transfer will be canceled and a new one will be
started. A NotReady
error will be returned if this method is called before the end of a
transfer while double buffering and the closure won’t be executed.
Panics
This method will panic when double buffering if one or both of the following conditions happen:
- The new buffer’s length is smaller than the one used in the
init
method. - The closure
f
takes too long to return and a buffer overrun occurs.
Safety
Memory corruption might occur in the previous buffer, the one passed to the closure, if an overrun occurs in double buffering mode.
impl<STREAM, PERIPHERAL, BUF, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, PeripheralToMemory, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, PeripheralToMemory, CHANNEL>,
BUF: StaticWriteBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
impl<STREAM, PERIPHERAL, BUF, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, PeripheralToMemory, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, PeripheralToMemory, CHANNEL>,
BUF: StaticWriteBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
pub fn init_peripheral_to_memory(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: Option<BUF>,
config: DmaConfig
) -> Self
pub fn init_peripheral_to_memory(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: Option<BUF>,
config: DmaConfig
) -> Self
Configures the DMA stream to the correct channel for the peripheral, configures source and
destination and applies supplied configuration. If double buffering is enabled, the
number of transfers will be the minimum length of memory
and double_buf
.
Panics
- When double buffering is enabled but the
double_buf
argument isNone
.
Changes the buffer and restarts or continues a double buffer transfer. This must be called
immediately after a transfer complete event if using double buffering, otherwise you might
lose data. Returns the old buffer together with its CurrentBuffer
. If an error occurs,
this method will return the new buffer with the error.
This method will clear the transfer complete flag on entry, it will also clear it again if
an overrun occurs during its execution. Moreover, if an overrun occurs, the stream will be
disabled and the transfer error flag will be set. This method can be called before the end
of an ongoing transfer only if not using double buffering, in that case, the current
transfer will be canceled and a new one will be started. A NotReady
error will be returned
if this method is called before the end of a transfer while double buffering.
pub unsafe fn next_transfer_with<F, T>(
&mut self,
f: F
) -> Result<T, DMAError<()>> where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
pub unsafe fn next_transfer_with<F, T>(
&mut self,
f: F
) -> Result<T, DMAError<()>> where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
Changes the buffer and restarts or continues a double buffer transfer. This must be called
immediately after a transfer complete event if using double buffering, otherwise you might
lose data. The closure must return (BUF, T)
where BUF
is the new buffer to be used. This
method can be called before the end of an ongoing transfer only if not using double
buffering, in that case, the current transfer will be canceled and a new one will be
started. A NotReady
error will be returned if this method is called before the end of a
transfer while double buffering and the closure won’t be executed.
Panics
This method will panic when double buffering if one or both of the following conditions happen:
- The new buffer’s length is smaller than the one used in the
init
method. - The closure
f
takes too long to return and a buffer overrun occurs.
Safety
Memory corruption might occur in the previous buffer, the one passed to the closure, if an overrun occurs in double buffering mode.
impl<STREAM, PERIPHERAL, BUF, S, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, MemoryToMemory<S>, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, MemoryToMemory<S>, CHANNEL>,
MemoryToMemory<S>: PeriAddress,
BUF: StaticWriteBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
impl<STREAM, PERIPHERAL, BUF, S, const CHANNEL: u8> Transfer<STREAM, PERIPHERAL, MemoryToMemory<S>, BUF, CHANNEL> where
STREAM: Stream,
ChannelX<CHANNEL>: Channel,
PERIPHERAL: PeriAddress + DMASet<STREAM, MemoryToMemory<S>, CHANNEL>,
MemoryToMemory<S>: PeriAddress,
BUF: StaticWriteBuffer<Word = <PERIPHERAL as PeriAddress>::MemSize>,
pub fn init_memory_to_memory(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: BUF,
config: DmaConfig
) -> Self
pub fn init_memory_to_memory(
stream: STREAM,
peripheral: PERIPHERAL,
buf: BUF,
double_buf: BUF,
config: DmaConfig
) -> Self
Configures the DMA stream to the correct channel for the peripheral, configures source and
destination and applies supplied configuration. In a memory to memory transfer,
the double_buf
argument is the source of the data. If double buffering is enabled, the
number of transfers will be the minimum length of memory
and double_buf
.
Panics
- When the FIFO is disabled or double buffering is enabled in
DmaConfig
while initializing a memory to memory transfer.
Changes the buffer and restarts.Returns the old buffer together with its CurrentBuffer
. If
an error occurs, this method will return the new buffer with the error.
This method will clear the transfer complete flag on entry. This method can be called before the end of an ongoing transfer, in that case, the current transfer will be canceled and a new one will be started.
pub fn next_transfer_with<F, T>(&mut self, f: F) -> T where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
pub fn next_transfer_with<F, T>(&mut self, f: F) -> T where
F: FnOnce(BUF, CurrentBuffer) -> (BUF, T),
Changes the buffer and restarts a transfer. This must be called
The closure must return (BUF, T)
where BUF
is the new buffer to be used. This
method can be called before the end of an ongoing transfer,
in that case, the current transfer will be canceled and a new one will be
started.
Starts the transfer, the closure will be executed right after enabling the stream.
Pauses the dma stream, the closure will be executed right before disabling the stream.
Please use release instead
Stops the stream and returns the underlying resources.
Clear all interrupts for the DMA stream.
Clear transfer complete interrupt (tcif) for the DMA stream.
Clear half transfer interrupt (htif) for the DMA stream.
Clear transfer error interrupt (teif) for the DMA stream.
Clear direct mode error interrupt (dmeif) for the DMA stream.
Clear fifo error interrupt (feif) for the DMA stream.
Get the underlying stream of the transfer.
Safety
This implementation relies on several configurations points in order to be sound, this method can void that. The use of this method is completely discouraged, only use it if you know the internals of this API in its entirety.