pub struct SpiDma<'d, Dm>where
Dm: DriverMode,{ /* private fields */ }
unstable
only.Expand description
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
A DMA capable SPI instance.
Using SpiDma
is not recommended unless you wish
to manage buffers yourself. It’s recommended to use
SpiDmaBus
via with_buffers
to get access
to a DMA capable SPI bus that implements the
embedded-hal traits.
let dma_channel = peripherals.DMA_CH0;
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) =
dma_buffers!(32000);
let dma_rx_buf = DmaRxBuf::new(
rx_descriptors,
rx_buffer
)?;
let dma_tx_buf = DmaTxBuf::new(
tx_descriptors,
tx_buffer
)?;
let mut spi = Spi::new(
peripherals.SPI2,
Config::default().with_frequency(Rate::from_khz(100)).
with_mode(Mode::_0) )?
.with_dma(dma_channel)
.with_buffers(dma_rx_buf, dma_tx_buf);
Implementations§
Source§impl<'d> SpiDma<'d, Blocking>
impl<'d> SpiDma<'d, Blocking>
Sourcepub fn into_async(self) -> SpiDma<'d, Async>
pub fn into_async(self) -> SpiDma<'d, Async>
Converts the SPI instance into async mode.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl<'d> SpiDma<'d, Async>
impl<'d> SpiDma<'d, Async>
Sourcepub fn into_blocking(self) -> SpiDma<'d, Blocking>
pub fn into_blocking(self) -> SpiDma<'d, Blocking>
Converts the SPI instance into async mode.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl SpiDma<'_, Blocking>
impl SpiDma<'_, Blocking>
Sourcepub fn listen(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
pub fn listen(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
Listen for the given interrupts
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn unlisten(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
pub fn unlisten(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
Unlisten the given interrupts
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn interrupts(&mut self) -> EnumSet<SpiInterrupt>
pub fn interrupts(&mut self) -> EnumSet<SpiInterrupt>
Gets asserted interrupts
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn clear_interrupts(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
pub fn clear_interrupts(&mut self, interrupts: impl Into<EnumSet<SpiInterrupt>>)
Resets asserted interrupts
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl<'d, Dm> SpiDma<'d, Dm>where
Dm: DriverMode,
impl<'d, Dm> SpiDma<'d, Dm>where
Dm: DriverMode,
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
Change the bus configuration.
§Errors
If frequency passed in config exceeds
80MHz
or is below 70kHz,
ConfigError::UnsupportedFrequency
error will be returned.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn with_buffers(
self,
dma_rx_buf: DmaRxBuf,
dma_tx_buf: DmaTxBuf,
) -> SpiDmaBus<'d, Dm>
pub fn with_buffers( self, dma_rx_buf: DmaRxBuf, dma_tx_buf: DmaTxBuf, ) -> SpiDmaBus<'d, Dm>
Configures the DMA buffers for the SPI instance.
This method sets up both RX and TX buffers for DMA transfers.
It returns an instance of SpiDmaBus
that can be used for SPI
communication.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl<'d, Dm> SpiDma<'d, Dm>where
Dm: DriverMode,
impl<'d, Dm> SpiDma<'d, Dm>where
Dm: DriverMode,
Sourcepub fn write<TX: DmaTxBuffer>(
self,
bytes_to_write: usize,
buffer: TX,
) -> Result<SpiDmaTransfer<'d, Dm, TX>, (Error, Self, TX)>
pub fn write<TX: DmaTxBuffer>( self, bytes_to_write: usize, buffer: TX, ) -> Result<SpiDmaTransfer<'d, Dm, TX>, (Error, Self, TX)>
Perform a DMA write.
This will return a SpiDmaTransfer owning the buffer and the SPI instance. The maximum amount of data to be sent is 32736 bytes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn read<RX: DmaRxBuffer>(
self,
bytes_to_read: usize,
buffer: RX,
) -> Result<SpiDmaTransfer<'d, Dm, RX>, (Error, Self, RX)>
pub fn read<RX: DmaRxBuffer>( self, bytes_to_read: usize, buffer: RX, ) -> Result<SpiDmaTransfer<'d, Dm, RX>, (Error, Self, RX)>
Perform a DMA read.
This will return a SpiDmaTransfer owning the buffer and the SPI instance. The maximum amount of data to be received is 32736 bytes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn transfer<RX: DmaRxBuffer, TX: DmaTxBuffer>(
self,
bytes_to_read: usize,
rx_buffer: RX,
bytes_to_write: usize,
tx_buffer: TX,
) -> Result<SpiDmaTransfer<'d, Dm, (RX, TX)>, (Error, Self, RX, TX)>
pub fn transfer<RX: DmaRxBuffer, TX: DmaTxBuffer>( self, bytes_to_read: usize, rx_buffer: RX, bytes_to_write: usize, tx_buffer: TX, ) -> Result<SpiDmaTransfer<'d, Dm, (RX, TX)>, (Error, Self, RX, TX)>
Perform a DMA transfer
This will return a SpiDmaTransfer owning the buffers and the SPI instance. The maximum amount of data to be sent/received is 32736 bytes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn half_duplex_read<RX: DmaRxBuffer>(
self,
data_mode: DataMode,
cmd: Command,
address: Address,
dummy: u8,
bytes_to_read: usize,
buffer: RX,
) -> Result<SpiDmaTransfer<'d, Dm, RX>, (Error, Self, RX)>
pub fn half_duplex_read<RX: DmaRxBuffer>( self, data_mode: DataMode, cmd: Command, address: Address, dummy: u8, bytes_to_read: usize, buffer: RX, ) -> Result<SpiDmaTransfer<'d, Dm, RX>, (Error, Self, RX)>
Perform a half-duplex read operation using DMA.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn half_duplex_write<TX: DmaTxBuffer>(
self,
data_mode: DataMode,
cmd: Command,
address: Address,
dummy: u8,
bytes_to_write: usize,
buffer: TX,
) -> Result<SpiDmaTransfer<'d, Dm, TX>, (Error, Self, TX)>
pub fn half_duplex_write<TX: DmaTxBuffer>( self, data_mode: DataMode, cmd: Command, address: Address, dummy: u8, bytes_to_write: usize, buffer: TX, ) -> Result<SpiDmaTransfer<'d, Dm, TX>, (Error, Self, TX)>
Perform a half-duplex write operation using DMA.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl<Dm> Debug for SpiDma<'_, Dm>where
Dm: DriverMode,
impl<Dm> Debug for SpiDma<'_, Dm>where
Dm: DriverMode,
Source§impl<'d, Dm> Format for SpiDma<'d, Dm>where
Dm: DriverMode,
PeripheralRef<'d, AnySpi>: Format,
Channel<'d, Dm, PeripheralDmaChannel<AnySpi>>: Format,
PeripheralGuard: Format,
SpiPinGuard: Format,
impl<'d, Dm> Format for SpiDma<'d, Dm>where
Dm: DriverMode,
PeripheralRef<'d, AnySpi>: Format,
Channel<'d, Dm, PeripheralDmaChannel<AnySpi>>: Format,
PeripheralGuard: Format,
SpiPinGuard: Format,
Source§impl InterruptConfigurable for SpiDma<'_, Blocking>
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl InterruptConfigurable for SpiDma<'_, Blocking>
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§fn set_interrupt_handler(&mut self, handler: InterruptHandler)
fn set_interrupt_handler(&mut self, handler: InterruptHandler)
Sets the interrupt handler
Interrupts are not enabled at the peripheral level here.
Source§impl<Dm> SetConfig for SpiDma<'_, Dm>where
Dm: DriverMode,
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl<Dm> SetConfig for SpiDma<'_, Dm>where
Dm: DriverMode,
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config
fails.