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

I2sTransfer configuration.

  • MS: Master or Slave
  • DIR: Transmit or Receive
  • STD: I2S standard, eg Philips
  • FMT: Frame Format marker, eg Data16Channel16

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

Implementations§

source§

impl I2sTransferConfig<Slave, Transmit, Philips, Data16Channel16>

source

pub fn new_slave() -> Self

Create a new default slave configuration.

source§

impl I2sTransferConfig<Master, Transmit, Philips, Data16Channel16>

source

pub fn new_master() -> Self

Create a new default master configuration.

source§

impl<MS, DIR, STD, FMT> I2sTransferConfig<MS, DIR, STD, FMT>
where STD: I2sStandard, FMT: DataFormat, (STD, FMT): FrameFormat,

source

pub fn i2s_transfer<I: I2sPeripheral>( self, i2s_peripheral: I ) -> I2sTransfer<I, MS, DIR, STD, FMT>

Create a I2sTransfer object around an I2sPeripheral object.

§Panics

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

source§

impl<MS, DIR, STD, FMT> I2sTransferConfig<MS, DIR, STD, FMT>

source

pub fn transmit(self) -> I2sTransferConfig<MS, Transmit, STD, FMT>

Configure for transmitting data.

source

pub fn receive(self) -> I2sTransferConfig<MS, Receive, STD, FMT>

Configure for receiving data.

source

pub fn standard<NEW_STD>( self, _standard: NEW_STD ) -> I2sTransferConfig<MS, DIR, NEW_STD, FMT>
where NEW_STD: I2sStandard,

Select the I2s standard to use. The parameter is just a marker implementing I2sStandard.

source

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

Select steady state clock polarity

source

pub fn data_format<NEW_FMT>( self, _format: NEW_FMT ) -> I2sTransferConfig<MS, DIR, STD, NEW_FMT>
where NEW_FMT: DataFormat,

Select data format. The parameter is just a marker implementing DataFormat.

source

pub fn to_slave(self) -> I2sTransferConfig<Slave, DIR, STD, FMT>

Convert to a slave configuration.

This deletes Master Only Settings.

source

pub fn to_master(self) -> I2sTransferConfig<Master, DIR, STD, FMT>

Convert to a master configuration.

source§

impl<DIR, STD, FMT> I2sTransferConfig<Master, DIR, STD, FMT>

source

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

Enable/Disable Master Clock.

This changes the effective sampling rate.

This applies to Master mode only.

source

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

Configure audio sample rate of the transfer 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 applies to Master mode only.

§Panics

div must be at least 2, otherwise the method 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 a transfer will panic.

Trait Implementations§

source§

impl<MS: Clone, DIR: Clone, STD: Clone, FMT: Clone> Clone for I2sTransferConfig<MS, DIR, STD, FMT>

source§

fn clone(&self) -> I2sTransferConfig<MS, DIR, STD, FMT>

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, DIR: Debug, STD: Debug, FMT: Debug> Debug for I2sTransferConfig<MS, DIR, STD, FMT>

source§

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

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

impl Default for I2sTransferConfig<Slave, Transmit, Philips, Data16Channel16>

source§

fn default() -> Self

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

source§

impl<MS: Copy, DIR: Copy, STD: Copy, FMT: Copy> Copy for I2sTransferConfig<MS, DIR, STD, FMT>

Auto Trait Implementations§

§

impl<MS, DIR, STD, FMT> Freeze for I2sTransferConfig<MS, DIR, STD, FMT>

§

impl<MS, DIR, STD, FMT> RefUnwindSafe for I2sTransferConfig<MS, DIR, STD, FMT>

§

impl<MS, DIR, STD, FMT> Send for I2sTransferConfig<MS, DIR, STD, FMT>
where DIR: Send, FMT: Send, MS: Send, STD: Send,

§

impl<MS, DIR, STD, FMT> Sync for I2sTransferConfig<MS, DIR, STD, FMT>
where DIR: Sync, FMT: Sync, MS: Sync, STD: Sync,

§

impl<MS, DIR, STD, FMT> Unpin for I2sTransferConfig<MS, DIR, STD, FMT>
where DIR: Unpin, FMT: Unpin, MS: Unpin, STD: Unpin,

§

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