Struct stm32_i2s_v12x::transfer::I2sTransferConfig
source · pub struct I2sTransferConfig<MS, DIR, STD, FMT> { /* private fields */ }
Expand description
I2sTransfer
configuration.
MS
:Master
orSlave
DIR
:Transmit
orReceive
STD
: I2S standard, egPhilips
FMT
: Frame Format marker, egData16Channel16
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<Master, Transmit, Philips, Data16Channel16>
impl I2sTransferConfig<Master, Transmit, Philips, Data16Channel16>
sourcepub fn new_master() -> Self
pub fn new_master() -> Self
Create a new default master configuration.
source§impl<MS, DIR, STD, FMT> I2sTransferConfig<MS, DIR, STD, FMT>
impl<MS, DIR, STD, FMT> I2sTransferConfig<MS, DIR, STD, FMT>
sourcepub fn i2s_transfer<I: I2sPeripheral>(
self,
i2s_peripheral: I
) -> I2sTransfer<I, MS, DIR, STD, FMT>
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>
impl<MS, DIR, STD, FMT> I2sTransferConfig<MS, DIR, STD, FMT>
sourcepub fn transmit(self) -> I2sTransferConfig<MS, Transmit, STD, FMT>
pub fn transmit(self) -> I2sTransferConfig<MS, Transmit, STD, FMT>
Configure for transmitting data.
sourcepub fn receive(self) -> I2sTransferConfig<MS, Receive, STD, FMT>
pub fn receive(self) -> I2sTransferConfig<MS, Receive, STD, FMT>
Configure for receiving data.
sourcepub fn standard<NEW_STD>(
self,
_standard: NEW_STD
) -> I2sTransferConfig<MS, DIR, NEW_STD, FMT>where
NEW_STD: I2sStandard,
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
.
sourcepub fn clock_polarity(self, polarity: ClockPolarity) -> Self
pub fn clock_polarity(self, polarity: ClockPolarity) -> Self
Select steady state clock polarity
sourcepub fn data_format<NEW_FMT>(
self,
_format: NEW_FMT
) -> I2sTransferConfig<MS, DIR, STD, NEW_FMT>where
NEW_FMT: DataFormat,
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
.
sourcepub fn to_slave(self) -> I2sTransferConfig<Slave, DIR, STD, FMT>
pub fn to_slave(self) -> I2sTransferConfig<Slave, DIR, STD, FMT>
Convert to a slave configuration.
This deletes Master Only Settings.
sourcepub fn to_master(self) -> I2sTransferConfig<Master, DIR, STD, FMT>
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>
impl<DIR, STD, FMT> I2sTransferConfig<Master, DIR, STD, FMT>
sourcepub fn master_clock(self, enable: bool) -> Self
pub fn master_clock(self, enable: bool) -> Self
Enable/Disable Master Clock.
This changes the effective sampling rate.
This applies to Master mode only.
sourcepub fn prescaler(self, odd: bool, div: u8) -> Self
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 enabledi2s_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.
sourcepub fn request_frequency(self, freq: u32) -> Self
pub fn request_frequency(self, freq: u32) -> Self
Request an audio sampling frequency. The effective audio sampling frequency may be different.
sourcepub fn require_frequency(self, freq: u32) -> Self
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>
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>
fn clone(&self) -> I2sTransferConfig<MS, DIR, STD, FMT>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more