pub struct Sai<'d, T: Instance, W: Word> { /* private fields */ }
Expand description
SAI sub-block driver.
Implementations§
Source§impl<'d, T: Instance, W: Word> Sai<'d, T, W>
impl<'d, T: Instance, W: Word> Sai<'d, T, W>
Sourcepub fn new_asynchronous_with_mclk<S: SubBlockInstance>(
peri: SubBlock<'d, T, S>,
sck: impl Peripheral<P = impl SckPin<T, S>> + 'd,
sd: impl Peripheral<P = impl SdPin<T, S>> + 'd,
fs: impl Peripheral<P = impl FsPin<T, S>> + 'd,
mclk: impl Peripheral<P = impl MclkPin<T, S>> + 'd,
dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd,
dma_buf: &'d mut [W],
config: Config,
) -> Self
pub fn new_asynchronous_with_mclk<S: SubBlockInstance>( peri: SubBlock<'d, T, S>, sck: impl Peripheral<P = impl SckPin<T, S>> + 'd, sd: impl Peripheral<P = impl SdPin<T, S>> + 'd, fs: impl Peripheral<P = impl FsPin<T, S>> + 'd, mclk: impl Peripheral<P = impl MclkPin<T, S>> + 'd, dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd, dma_buf: &'d mut [W], config: Config, ) -> Self
Create a new SAI driver in asynchronous mode with MCLK.
You can obtain the SubBlock
with split_subblocks
.
Sourcepub fn new_asynchronous<S: SubBlockInstance>(
peri: SubBlock<'d, T, S>,
sck: impl Peripheral<P = impl SckPin<T, S>> + 'd,
sd: impl Peripheral<P = impl SdPin<T, S>> + 'd,
fs: impl Peripheral<P = impl FsPin<T, S>> + 'd,
dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd,
dma_buf: &'d mut [W],
config: Config,
) -> Self
pub fn new_asynchronous<S: SubBlockInstance>( peri: SubBlock<'d, T, S>, sck: impl Peripheral<P = impl SckPin<T, S>> + 'd, sd: impl Peripheral<P = impl SdPin<T, S>> + 'd, fs: impl Peripheral<P = impl FsPin<T, S>> + 'd, dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd, dma_buf: &'d mut [W], config: Config, ) -> Self
Create a new SAI driver in asynchronous mode without MCLK.
You can obtain the SubBlock
with split_subblocks
.
Sourcepub fn new_synchronous<S: SubBlockInstance>(
peri: SubBlock<'d, T, S>,
sd: impl Peripheral<P = impl SdPin<T, S>> + 'd,
dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd,
dma_buf: &'d mut [W],
config: Config,
) -> Self
pub fn new_synchronous<S: SubBlockInstance>( peri: SubBlock<'d, T, S>, sd: impl Peripheral<P = impl SdPin<T, S>> + 'd, dma: impl Peripheral<P = impl Channel + Dma<T, S>> + 'd, dma_buf: &'d mut [W], config: Config, ) -> Self
Create a new SAI driver in synchronous mode.
You can obtain the SubBlock
with split_subblocks
.
Sourcepub fn start(&mut self) -> Result<(), Error>
pub fn start(&mut self) -> Result<(), Error>
Start the SAI driver.
Only receivers can be started. Transmitters are started on the first writing operation.
Sourcepub fn is_muted(&self) -> Result<bool, Error>
pub fn is_muted(&self) -> Result<bool, Error>
Determine the mute state of the receiver.
Clears the mute state flag in the status register.
Sourcepub async fn wait_write_error(&mut self) -> Result<(), Error>
pub async fn wait_write_error(&mut self) -> Result<(), Error>
Wait until any SAI write error occurs.
One useful application for this is stopping playback as soon as the SAI experiences an overrun of the ring buffer. Then, instead of letting the SAI peripheral play the last written buffer over and over again, SAI can be muted or dropped instead.
Sourcepub async fn write(&mut self, data: &[W]) -> Result<(), Error>
pub async fn write(&mut self, data: &[W]) -> Result<(), Error>
Write data to the SAI ringbuffer.
The first write starts the DMA after filling the ring buffer with the provided data. This ensures that the DMA does not run before data is available in the ring buffer.
This appends the data to the buffer and returns immediately. The data will be transmitted in the background.
If there’s no space in the buffer, this waits until there is.