pub struct SpiSlaveRing<'d, T: Instance, W: Word> { /* private fields */ }Expand description
SPI slave with RX and TX on circular DMA (see the module docs).
Implementations§
Source§impl<'d, T: Instance, W: Word> SpiSlaveRing<'d, T, W>
impl<'d, T: Instance, W: Word> SpiSlaveRing<'d, T, W>
Sourcepub fn new<const REMAP: u8>(
peri: Peri<'d, T>,
sck: Peri<'d, impl SckPin<T, REMAP>>,
mosi: Peri<'d, impl MosiPin<T, REMAP>>,
miso: Peri<'d, impl MisoPin<T, REMAP>>,
nss: Peri<'d, impl CsPin<T, REMAP>>,
rx_dma: Peri<'d, impl RxDma<T>>,
tx_dma: Peri<'d, impl TxDma<T>>,
rx_buf: &'d mut [W],
tx_buf: &'d mut [W],
config: SlaveConfig,
) -> Self
pub fn new<const REMAP: u8>( peri: Peri<'d, T>, sck: Peri<'d, impl SckPin<T, REMAP>>, mosi: Peri<'d, impl MosiPin<T, REMAP>>, miso: Peri<'d, impl MisoPin<T, REMAP>>, nss: Peri<'d, impl CsPin<T, REMAP>>, rx_dma: Peri<'d, impl RxDma<T>>, tx_dma: Peri<'d, impl TxDma<T>>, rx_buf: &'d mut [W], tx_buf: &'d mut [W], config: SlaveConfig, ) -> Self
rx_buf and tx_buf are the same length; each pass uses 2 x half_len words of
them (all of them by default). Nothing runs until start.
Sourcepub fn set_half_len(&mut self, words: usize)
pub fn set_half_len(&mut self, words: usize)
Sourcepub fn start(&mut self) -> Result<(), SlaveError>
pub fn start(&mut self) -> Result<(), SlaveError>
Set up SPI and both DMA channels and enable the slave in a pause between bursts (NSS high). TX starts with whatever is in the TX buffer.
Sourcepub fn restart(&mut self) -> Result<(), SlaveError>
pub fn restart(&mut self) -> Result<(), SlaveError>
After a slip or an error: stop, reset the peripheral (clears the shift register, the data register and OVR) and start again in a pause.
Sourcepub async fn next_half(&mut self) -> Result<Half, SlaveError>
pub async fn next_half(&mut self) -> Result<Half, SlaveError>
Wait for the next completed RX half.
Sourcepub fn rx_half(&self, index: usize) -> &[W]
pub fn rx_half(&self, index: usize) -> &[W]
Received words of half index (complete once next_half
returned it, until the DMA comes back to it one pass later).
Sourcepub fn tx_half_mut(&mut self, index: usize) -> &mut [W]
pub fn tx_half_mut(&mut self, index: usize) -> &mut [W]
TX half index, free to refill after next_half returned it.
Sourcepub fn half_mut(&mut self, index: usize) -> (&[W], &mut [W])
pub fn half_mut(&mut self, index: usize) -> (&[W], &mut [W])
rx_half and tx_half_mut of the same half,
together.