pub struct I2S<'d, W: Word> { /* private fields */ }Expand description
I2S driver.
Implementations§
Source§impl<'d, W: Word> I2S<'d, W>
impl<'d, W: Word> I2S<'d, W>
Sourcepub fn new_txonly<T: Instance, D1: TxDma<T>>(
peri: Peri<'d, T>,
sd: Peri<'d, impl MosiPin<T>>,
ws: Peri<'d, impl WsPin<T>>,
ck: Peri<'d, impl CkPin<T>>,
mck: Peri<'d, impl MckPin<T>>,
txdma: Peri<'d, D1>,
txdma_buf: &'d mut [W],
_irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd,
config: Config,
) -> Self
pub fn new_txonly<T: Instance, D1: TxDma<T>>( peri: Peri<'d, T>, sd: Peri<'d, impl MosiPin<T>>, ws: Peri<'d, impl WsPin<T>>, ck: Peri<'d, impl CkPin<T>>, mck: Peri<'d, impl MckPin<T>>, txdma: Peri<'d, D1>, txdma_buf: &'d mut [W], _irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd, config: Config, ) -> Self
Create a transmitter driver.
Sourcepub fn new_txonly_nomck<T: Instance, D1: TxDma<T>>(
peri: Peri<'d, T>,
sd: Peri<'d, impl MosiPin<T>>,
ws: Peri<'d, impl WsPin<T>>,
ck: Peri<'d, impl CkPin<T>>,
txdma: Peri<'d, D1>,
txdma_buf: &'d mut [W],
_irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd,
config: Config,
) -> Self
pub fn new_txonly_nomck<T: Instance, D1: TxDma<T>>( peri: Peri<'d, T>, sd: Peri<'d, impl MosiPin<T>>, ws: Peri<'d, impl WsPin<T>>, ck: Peri<'d, impl CkPin<T>>, txdma: Peri<'d, D1>, txdma_buf: &'d mut [W], _irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd, config: Config, ) -> Self
Create a transmitter driver without a master clock pin.
Sourcepub fn new_rxonly<T: Instance, D1: RxDma<T>>(
peri: Peri<'d, T>,
sd: Peri<'d, impl MisoPin<T>>,
ws: Peri<'d, impl WsPin<T>>,
ck: Peri<'d, impl CkPin<T>>,
mck: Peri<'d, impl MckPin<T>>,
rxdma: Peri<'d, D1>,
rxdma_buf: &'d mut [W],
_irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd,
config: Config,
) -> Self
pub fn new_rxonly<T: Instance, D1: RxDma<T>>( peri: Peri<'d, T>, sd: Peri<'d, impl MisoPin<T>>, ws: Peri<'d, impl WsPin<T>>, ck: Peri<'d, impl CkPin<T>>, mck: Peri<'d, impl MckPin<T>>, rxdma: Peri<'d, D1>, rxdma_buf: &'d mut [W], _irq: impl Binding<D1::Interrupt, InterruptHandler<D1>> + 'd, config: Config, ) -> Self
Create a receiver driver.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Reset the ring buffer to its initial state. Can be used to recover from overrun.
NOTE: This only clears the DMA buffer and is not synchronized to WS/LR clock, so the order of channels may or may not be swapped after this. A full restart is required to ensure buffer contents and I2S transmissions are in sync.
Sourcepub fn split<'s>(
&'s mut self,
) -> Result<(Reader<'s, 'd, W>, Writer<'s, 'd, W>), Error>
pub fn split<'s>( &'s mut self, ) -> Result<(Reader<'s, 'd, W>, Writer<'s, 'd, W>), Error>
Split the driver into a Reader/Writer pair. Useful for splitting the reader/writer functionality across tasks or for calling the read/write methods in parallel.
Sourcepub async fn read(&mut self, data: &mut [W]) -> Result<(), Error>
pub async fn read(&mut self, data: &mut [W]) -> Result<(), Error>
Read data from the I2S ringbuffer. SAI is always receiving data in the background. This function pops already-received data from the buffer. If there’s less than data.len() data in the buffer, this waits until there is.