Struct stm32_hal2::sai::Sai
source · [−]pub struct Sai<R> {
pub regs: R,
/* private fields */
}
Expand description
Represents the Serial Audio Interface (SAI) peripheral, used for digital audio input and output.
Fields
regs: R
Implementations
sourceimpl<R> Sai<R>where
R: Deref<Target = RegisterBlock> + RccPeriph,
impl<R> Sai<R>where
R: Deref<Target = RegisterBlock> + RccPeriph,
sourcepub fn new(
regs: R,
config_a: SaiConfig,
config_b: SaiConfig,
clocks: &Clocks
) -> Self
pub fn new(
regs: R,
config_a: SaiConfig,
config_b: SaiConfig,
clocks: &Clocks
) -> Self
Initialize a SAI peripheral, including enabling and resetting its RCC peripheral clock.
sourcepub fn enable(&mut self, channel: SaiChannel)
pub fn enable(&mut self, channel: SaiChannel)
Enable an audio subblock (channel).
sourcepub fn disable(&mut self, channel: SaiChannel)
pub fn disable(&mut self, channel: SaiChannel)
Disable an audio subblock (channel). See H743 RM, section 51.4.15. The SAI audio block can be disabled at any moment by clearing SAIEN bit in the SAI_xCR1 register. All the already started frames are automatically completed before the SAI is stops working. SAIEN bit remains High until the SAI is completely switched-off at the end of the current audio frame transfer. If an audio block in the SAI operates synchronously with the other one, the one which is the master must be disabled first.
sourcepub fn read(&self, channel: SaiChannel) -> i32
pub fn read(&self, channel: SaiChannel) -> i32
Read a word of data.
sourcepub fn write(&mut self, channel: SaiChannel, left_word: i32, right_word: i32)
pub fn write(&mut self, channel: SaiChannel, left_word: i32, right_word: i32)
Send 2 words of data to a single channel: Left and right channel, in that order. A write to the SR register loads the FIFO provided the FIFO is not full.
sourcepub unsafe fn write_dma<D>(
&mut self,
buf: &[i32],
sai_channel: SaiChannel,
dma_channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
)where
D: Deref<Target = RegisterBlock>,
pub unsafe fn write_dma<D>(
&mut self,
buf: &[i32],
sai_channel: SaiChannel,
dma_channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
)where
D: Deref<Target = RegisterBlock>,
Send data over SAI with DMA. H743 RM, section 51.4.16: SAI DMA Interface. To free the CPU and to optimize bus bandwidth, each SAI audio block has an independent DMA interface to read/write from/to the SAI_xDR register (to access the internal FIFO). There is one DMA channel per audio subblock supporting basic DMA request/acknowledge protocol. Before configuring the SAI block, the SAI DMA channel must be disabled.
sourcepub unsafe fn read_dma<D>(
&mut self,
buf: &mut [i32],
sai_channel: SaiChannel,
dma_channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
)where
D: Deref<Target = RegisterBlock>,
pub unsafe fn read_dma<D>(
&mut self,
buf: &mut [i32],
sai_channel: SaiChannel,
dma_channel: DmaChannel,
channel_cfg: ChannelCfg,
dma: &mut Dma<D>
)where
D: Deref<Target = RegisterBlock>,
Read data from SAI with DMA. H743 RM, section 51.4.16: SAI DMA Interface. To free the CPU and to optimize bus bandwidth, each SAI audio block has an independent DMA interface to read/write from/to the SAI_xDR register (to access the internal FIFO). There is one DMA channel per audio subblock supporting basic DMA request/acknowledge protocol.
sourcepub fn enable_interrupt(
&mut self,
interrupt_type: SaiInterrupt,
channel: SaiChannel
)
pub fn enable_interrupt(
&mut self,
interrupt_type: SaiInterrupt,
channel: SaiChannel
)
Enable a specific type of interrupt. See L4 RM, Table 220: “SAI interrupt sources”.
sourcepub fn clear_interrupt(
&mut self,
interrupt_type: SaiInterrupt,
channel: SaiChannel
)
pub fn clear_interrupt(
&mut self,
interrupt_type: SaiInterrupt,
channel: SaiChannel
)
Clears the interrupt pending flag for a specific type of interrupt.