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§

source§

impl<R> Sai<R>
where R: Deref<Target = RegisterBlock> + RccPeriph,

source

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.

source

pub fn enable(&mut self, channel: SaiChannel)

Enable an audio subblock (channel).

source

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.

source

pub fn read(&self, channel: SaiChannel) -> i32

Read a word of data.

source

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.

source

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.

source

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.

source

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”.

source

pub fn clear_interrupt( &mut self, interrupt_type: SaiInterrupt, channel: SaiChannel )

Clears the interrupt pending flag for a specific type of interrupt.

source

pub fn read_status(&self) -> (u32, u32)

Print the (raw) contents of the (A and B) status registers.

Auto Trait Implementations§

§

impl<R> Freeze for Sai<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Sai<R>
where R: RefUnwindSafe,

§

impl<R> Send for Sai<R>
where R: Send,

§

impl<R> Sync for Sai<R>
where R: Sync,

§

impl<R> Unpin for Sai<R>
where R: Unpin,

§

impl<R> UnwindSafe for Sai<R>
where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.