pub struct DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD> { /* private fields */ }
Expand description

Dual I2S driver configuration. This can be used as a dual I2S driver builder.

  • MS: Master or Slave. It applies to the “main” part only since the extension is always slave
  • MAIN_DIR and EXT_DIR : Communication direction of the main and extension parts; can be Transmit or Receive.
  • STD: I2S standard, eg Philips

Note: because of its typestate, methods of this type don’t modify a config object. They return a new object instead.

Implementations§

source§

impl DualI2sDriverConfig<Slave, Transmit, Transmit, Philips>

source

pub fn new_slave() -> Self

Create a new default slave configuration.

source§

impl DualI2sDriverConfig<Master, Transmit, Transmit, Philips>

source

pub fn new_master() -> Self

Create a new default master configuration.

source§

impl<MS, MAIN_DIR, EXT_DIR, STD> DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

source

pub fn dual_i2s_driver<I: DualI2sPeripheral>( self, dual_i2s_peripheral: I ) -> DualI2sDriver<I, MS, MAIN_DIR, EXT_DIR, STD>

Instantiate the driver by wrapping the given I2sPeripheral.

§Panics

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

source§

impl<MS, MAIN_DIR, EXT_DIR, STD> DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

source

pub fn direction<NEW_MAIN_DIR, NEW_EXT_DIR>( self, _main: NEW_MAIN_DIR, _ext: NEW_EXT_DIR ) -> DualI2sDriverConfig<MS, NEW_MAIN_DIR, NEW_EXT_DIR, STD>
where NEW_MAIN_DIR: Direction, NEW_EXT_DIR: Direction,

Configure direction (Transmit or Receive) of main and extension part

source

pub fn standard<NEW_STD>( self, _standard: NEW_STD ) -> DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, NEW_STD>
where NEW_STD: I2sStandard,

Select the I2s standard to use

source

pub fn clock_polarity(self, polarity: ClockPolarity) -> Self

Select steady state clock polarity

source

pub fn data_format(self, format: DataFormat) -> Self

Select data format

source

pub fn to_slave(self) -> DualI2sDriverConfig<Slave, MAIN_DIR, EXT_DIR, STD>

Convert to a slave configuration. This deletes Master Only Settings.

source

pub fn to_master(self) -> DualI2sDriverConfig<Master, MAIN_DIR, EXT_DIR, STD>

Convert to a master configuration.

source§

impl<MAIN_DIR, EXT_DIR, STD> DualI2sDriverConfig<Master, MAIN_DIR, EXT_DIR, STD>

source

pub fn master_clock(self, enable: bool) -> Self

Enable/Disable Master Clock generation.

This changes the effective sampling rate.

This can be only set and only has meaning for Master mode.

source

pub fn prescaler(self, odd: bool, div: u8) -> Self

Configure the audio frequency by setting the prescaler with an odd factor and a divider.

The effective sampling frequency is:

  • i2s_clock / [256 * ((2 * div) + odd)] when master clock is enabled
  • i2s_clock / [(channel_length * 2) * ((2 * div) + odd)] when master clock is disabled

i2s_clock is I2S clock source frequency, and channel_length is width in bits of the channel (see DataFormat)

This setting only has meaning and can be only set for master.

§Panics

div must be at least 2, otherwise this function panics.

source

pub fn request_frequency(self, freq: u32) -> Self

Request an audio sampling frequency.

The effective audio sampling frequency may be different.

source

pub fn require_frequency(self, freq: u32) -> Self

Require exactly this audio sampling frequency.

If the required frequency can not bet set, instantiating the driver will panic.

Trait Implementations§

source§

impl<MS: Clone, MAIN_DIR: Clone, EXT_DIR: Clone, STD: Clone> Clone for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

source§

fn clone(&self) -> DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<MS: Debug, MAIN_DIR: Debug, EXT_DIR: Debug, STD: Debug> Debug for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DualI2sDriverConfig<Slave, Transmit, Transmit, Philips>

source§

fn default() -> Self

Create a default configuration. This corresponds to a default slave configuration.

source§

impl<MS: Copy, MAIN_DIR: Copy, EXT_DIR: Copy, STD: Copy> Copy for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

Auto Trait Implementations§

§

impl<MS, MAIN_DIR, EXT_DIR, STD> Freeze for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>

§

impl<MS, MAIN_DIR, EXT_DIR, STD> RefUnwindSafe for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>
where EXT_DIR: RefUnwindSafe, MAIN_DIR: RefUnwindSafe, MS: RefUnwindSafe, STD: RefUnwindSafe,

§

impl<MS, MAIN_DIR, EXT_DIR, STD> Send for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>
where EXT_DIR: Send, MAIN_DIR: Send, MS: Send, STD: Send,

§

impl<MS, MAIN_DIR, EXT_DIR, STD> Sync for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>
where EXT_DIR: Sync, MAIN_DIR: Sync, MS: Sync, STD: Sync,

§

impl<MS, MAIN_DIR, EXT_DIR, STD> Unpin for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>
where EXT_DIR: Unpin, MAIN_DIR: Unpin, MS: Unpin, STD: Unpin,

§

impl<MS, MAIN_DIR, EXT_DIR, STD> UnwindSafe for DualI2sDriverConfig<MS, MAIN_DIR, EXT_DIR, STD>
where EXT_DIR: UnwindSafe, MAIN_DIR: 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.