pub struct I2sDriver<I, MS, DIR, STD> { /* private fields */ }
Expand description

Driver of a SPI peripheral in I2S mode.

This is meant for advanced usage, for example using interrupt or DMA.

Implementations§

source§

impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>
where I: I2sPeripheral,

Constructors and Destructors

source

pub fn new(i2s_peripheral: I, config: I2sDriverConfig<MS, DIR, STD>) -> Self

Instantiate an i2s driver from an I2sPeripheral object and a configuration.

§Panics

This method panics if an exact frequency is required by the configuration and that frequency cannot be set.

source

pub fn release(self) -> I

Destroy the driver, release and reset the owned i2s device.

source

pub fn reconfigure<NEW_MS, NEW_DIR, NEW_STD>( self, config: I2sDriverConfig<NEW_MS, NEW_DIR, NEW_STD> ) -> I2sDriver<I, NEW_MS, NEW_DIR, NEW_STD>

Consume the driver and create a new one with the given configuration.

source§

impl<I, MS, DIR, STD> I2sDriver<I, MS, DIR, STD>
where I: I2sPeripheral,

Methods available in any mode

source

pub fn enable(&mut self)

Enable the I2S peripheral.

source

pub fn disable(&mut self)

Immediately Disable the I2S peripheral.

Generated clocks aren’t reset, so a call to reset_clocks may be required in master mode.

It’s up to the caller to not disable the peripheral in the middle of a frame.

source

pub fn ws_is_high(&self) -> bool

👎Deprecated since 0.4.0: may removed in future, use ws_pin().is_high() instead

Return true if the level on the WS line is high.

source

pub fn ws_is_low(&self) -> bool

👎Deprecated since 0.4.0: may removed in future, use ws_pin().is_low() instead

Return true if the level on the WS line is low.

source

pub fn ws_pin(&self) -> &I::WsPin

Get a reference to the WS pin.

source

pub fn ws_pin_mut(&mut self) -> &mut I::WsPin

Get a mutable reference to the WS pin.

source

pub fn data_register_address(&self) -> u32

Get the address of the data register for DMA setup.

source

pub fn status(&mut self) -> Status<MS, DIR, STD>

Get the content of the status register. This operation may change the register value.

When reading the status register, the hardware may reset some error flags. The way each flag can be modified is documented on each Status flag getter.

source§

impl<I, DIR, STD> I2sDriver<I, Master, DIR, STD>
where I: I2sPeripheral,

Master-only methods

source

pub fn reset_clocks(&mut self)

Reset clocks generated by the peripheral, and clear status and data registers.

This allows immediately starting a new frame when an error occurs or before re-enabling the driver.

source

pub fn sample_rate(&self) -> u32

Get the actual sample rate imposed by the driver.

This allows client code to check deviation from the requested frequency.

source§

impl<I, MS, STD> I2sDriver<I, MS, Transmit, STD>
where I: I2sPeripheral,

Transmit-only methods

source

pub fn write_data_register(&mut self, value: u16)

Write a raw half word to the Tx buffer and delete the TXE flag in status register.

It’s up to the caller to write the content when the data register is empty.

source

pub fn set_tx_interrupt(&mut self, enabled: bool)

When set to true, an interrupt is generated each time the Tx buffer is empty.

source

pub fn set_tx_dma(&mut self, enabled: bool)

When set to true, a DMA request is generated each time the Tx buffer is empty.

source§

impl<I, MS, STD> I2sDriver<I, MS, Receive, STD>
where I: I2sPeripheral,

Receive-only methods

source

pub fn read_data_register(&mut self) -> u16

Read a raw value from the Rx buffer and delete the RXNE flag in status register.

source

pub fn set_rx_interrupt(&mut self, enabled: bool)

When set to true, an interrupt is generated each time the Rx buffer contains a new data.

source

pub fn set_rx_dma(&mut self, enabled: bool)

When set to true, a DMA request is generated each time the Rx buffer contains a new data.

source§

impl<I, STD> I2sDriver<I, Master, Receive, STD>
where I: I2sPeripheral,

Error interrupt, Master Receive Mode.

source

pub fn set_error_interrupt(&mut self, enabled: bool)

When set to true, an interrupt is generated each time an error occurs.

This is not available for Master Transmit because no error can occur in this mode.

source§

impl<I, DIR, STD> I2sDriver<I, Slave, DIR, STD>
where I: I2sPeripheral,

Error interrupt, Slave Mode.

source

pub fn set_error_interrupt(&mut self, enabled: bool)

When set to true, an interrupt is generated each time an error occurs.

This is not available for Master Transmit because no error can occur in this mode.

Auto Trait Implementations§

§

impl<I, MS, DIR, STD> Freeze for I2sDriver<I, MS, DIR, STD>
where I: Freeze,

§

impl<I, MS, DIR, STD> RefUnwindSafe for I2sDriver<I, MS, DIR, STD>

§

impl<I, MS, DIR, STD> Send for I2sDriver<I, MS, DIR, STD>
where DIR: Send, I: Send, MS: Send, STD: Send,

§

impl<I, MS, DIR, STD> Sync for I2sDriver<I, MS, DIR, STD>
where DIR: Sync, I: Sync, MS: Sync, STD: Sync,

§

impl<I, MS, DIR, STD> Unpin for I2sDriver<I, MS, DIR, STD>
where DIR: Unpin, I: Unpin, MS: Unpin, STD: Unpin,

§

impl<I, MS, DIR, STD> UnwindSafe for I2sDriver<I, MS, DIR, STD>
where DIR: UnwindSafe, I: UnwindSafe, MS: UnwindSafe, STD: 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.