Embassy
embassy-stm32

Crates

git

Versions

stm32h755xi-cm4

Flavors

Struct embassy_stm32::sai::Sai

source ·
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>

source

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.

source

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.

source

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.

source

pub fn start(&mut self)

Start the SAI driver.

source

pub fn reset()

Reset SAI operation.

source

pub fn flush(&mut self)

Flush.

source

pub fn set_mute(&mut self, value: bool)

Enable or disable mute.

source

pub async fn write(&mut self, data: &[W]) -> Result<(), Error>

Write data to the SAI ringbuffer.

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.

source

pub async fn read(&mut self, data: &mut [W]) -> Result<(), Error>

Read data from the SAI 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.

Trait Implementations§

source§

impl<'d, T: Instance, W: Word> Drop for Sai<'d, T, W>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d, T, W> Freeze for Sai<'d, T, W>
where T: Freeze,

§

impl<'d, T, W> RefUnwindSafe for Sai<'d, T, W>

§

impl<'d, T, W> Send for Sai<'d, T, W>
where T: Send, W: Send,

§

impl<'d, T, W> Sync for Sai<'d, T, W>
where T: Sync, W: Sync,

§

impl<'d, T, W> Unpin for Sai<'d, T, W>
where T: Unpin,

§

impl<'d, T, W> !UnwindSafe for Sai<'d, T, W>

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.