Struct esp_idf_svc::hal::i2s::config::TdmSlotConfig
source · pub struct TdmSlotConfig { /* private fields */ }
Expand description
TDM mode slot configuration.
To create a slot configuration, use TdmSlotConfig::philips_slot_default
,
TdmSlotConfig::pcm_short_slot_default
, TdmSlotConfig::pcm_long_slot_default
, or
TdmSlotConfig::msb_slot_default
, then customize it as needed.
In TDM mode, WS (word select, sometimes called LRCLK or left/right clock) becomes a frame synchronization signal that signals the first slot of a frame. The two sides of the TDM link must agree on the number of channels, data bit width, and frame synchronization pattern; this cannot be determined by examining the signal itself.
The Philips default pulls the WS line low one BCK period before the first data bit of the first slot is sent and holds it low for 50% of the frame.
MSB (most-significant bit) mode is similar to Philips mode, except the WS line is pulled low at the same time the first data bit of the first slot is sent. It is held low for 50% of the frame.
PCM (pulse-code modulation) short mode pulls the WS line high one BCK period before the first data bit of the first slot is sent, keeps it high for one BCK, then pulls it low for the remainder of the frame. PCM long mode pulls the WS line high one BCK period before the first data bit of the first slot is sent, keeps it high until just before the last data bit of the first slot is sent, then pulls it low for the remainder of the frame.
Diagrams from ESP-IDF Programming Guide; rendered by Wavedrom.
Implementations§
source§impl TdmSlotConfig
impl TdmSlotConfig
sourcepub fn data_bit_width(self, data_bit_width: DataBitWidth) -> TdmSlotConfig
pub fn data_bit_width(self, data_bit_width: DataBitWidth) -> TdmSlotConfig
Update the data bit width on this TDM slot configuration.
sourcepub fn slot_bit_width(self, slot_bit_width: SlotBitWidth) -> TdmSlotConfig
pub fn slot_bit_width(self, slot_bit_width: SlotBitWidth) -> TdmSlotConfig
Update the slot bit width on this TDM slot configuration.
This is normally set to SlotBitWidth::Auto
to match [data_bit_width][TdmSlotConfig::data_bit_width()]
.
sourcepub fn slot_mask(self, slot_mask: TdmSlotMask) -> TdmSlotConfig
pub fn slot_mask(self, slot_mask: TdmSlotMask) -> TdmSlotConfig
Update the slot mask on this TDM slot configuration.
sourcepub fn ws_width(self, ws_width: u32) -> TdmSlotConfig
pub fn ws_width(self, ws_width: u32) -> TdmSlotConfig
Update the word select signal width on this TDM slot configuration.
This sets the number of bits to keep the word select signal active at the start of each frame. If this is
set to 0 (TDM_AUTO_WS_WIDTH
), the word select signal will be kept active for half of the frame.
sourcepub fn ws_polarity(self, ws_polarity: bool) -> TdmSlotConfig
pub fn ws_polarity(self, ws_polarity: bool) -> TdmSlotConfig
Update the word select signal polarity on this TDM slot configuration.
Setting this to true
will make the word select (WS) signal active high at the start (PCM modes).
Setting this to false
will make the WS signal active low at the start (Philips and MSB modes).
sourcepub fn bit_shift(self, bit_shift: bool) -> TdmSlotConfig
pub fn bit_shift(self, bit_shift: bool) -> TdmSlotConfig
Update the bit shift flag on this TDM slot configuration.
Setting this to true
will activate the word select (WS) signal lone BCK period before the first data bit
of the first slot is sent (Philips and PCM modes). Setting this to false
will activate the WS
signal at the same time the first data bit of the first slot is sent (MSB mode).
sourcepub fn left_align(self, left_align: bool) -> TdmSlotConfig
pub fn left_align(self, left_align: bool) -> TdmSlotConfig
Update the left-alignment flag on this TDM slot configuration.
This only has an effect when [slot_bit_width][TdmSlotMask::slot_bit_width()]
is greater than
[data_bit_width][TdmSlotMask::data_bit_width()]
. Setting this to true
will left-align the data in the slot and
fill the right-most bits (usually the least-significant bits) with zeros. Setting this to false
will right-align the
data in the slot and fill the left-most bits (usually the most-significant bits) with zeros.
sourcepub fn big_endian(self, big_endian: bool) -> TdmSlotConfig
pub fn big_endian(self, big_endian: bool) -> TdmSlotConfig
Update the big-endian flag on this TDM slot configuration.
This affects the interpretation of the data when [data_bit_width][TdmSlotMask::data_bit_width()]
is
greater than 8. Setting this to
true
will interpret the data as big-endian. Setting this to false
will interpret the data as
little-endian (the default, and the native endian-ness of all ESP32 microcontrollers).
sourcepub fn bit_order_lsb(self, bit_order_lsb: bool) -> TdmSlotConfig
pub fn bit_order_lsb(self, bit_order_lsb: bool) -> TdmSlotConfig
Update the LSB-first flag on this TDM slot configuration.
Setting this to true
will transmit data LSB-first (no known modes do this). Setting this to false
will transmit data MSB-first (the default for all known modes).
sourcepub fn skip_mask(self, skip_mask: bool) -> TdmSlotConfig
pub fn skip_mask(self, skip_mask: bool) -> TdmSlotConfig
Update the skip mask flag on this TDM slot configuration.
Setting this to true
will ignore [slot_mask][TdmSlotMask::slot_mask()]
and transmit all slots. Setting this to false
will
respect the slot mask.
sourcepub fn total_slots(self, total_slots: u32) -> TdmSlotConfig
pub fn total_slots(self, total_slots: u32) -> TdmSlotConfig
Update the total number of slots on this TDM slot configuration.
Setting this to 0 (TDM_AUTO_SLOT_NUM
) will automatically set the total number of slots to the
the number of active slots in [slot_mask][TdmSlotMask::slot_mask()]
.
sourcepub fn philips_slot_default(
bits_per_sample: DataBitWidth,
slot_mask: TdmSlotMask,
) -> TdmSlotConfig
pub fn philips_slot_default( bits_per_sample: DataBitWidth, slot_mask: TdmSlotMask, ) -> TdmSlotConfig
Configure in Philips format with the active slots enabled by the specified mask.
sourcepub fn msb_slot_default(
bits_per_sample: DataBitWidth,
slot_mask: TdmSlotMask,
) -> TdmSlotConfig
pub fn msb_slot_default( bits_per_sample: DataBitWidth, slot_mask: TdmSlotMask, ) -> TdmSlotConfig
Configure in MSB format with the active slots enabled by the specified mask.
sourcepub fn pcm_short_slot_default(
bits_per_sample: DataBitWidth,
slot_mask: TdmSlotMask,
) -> TdmSlotConfig
pub fn pcm_short_slot_default( bits_per_sample: DataBitWidth, slot_mask: TdmSlotMask, ) -> TdmSlotConfig
Configure in PCM (short) format with the active slots enabled by the specified mask.
sourcepub fn pcm_long_slot_default(
bits_per_sample: DataBitWidth,
slot_mask: TdmSlotMask,
) -> TdmSlotConfig
pub fn pcm_long_slot_default( bits_per_sample: DataBitWidth, slot_mask: TdmSlotMask, ) -> TdmSlotConfig
Configure in PCM (long) format with the active slots enabled by the specified mask.
Trait Implementations§
source§impl Clone for TdmSlotConfig
impl Clone for TdmSlotConfig
source§fn clone(&self) -> TdmSlotConfig
fn clone(&self) -> TdmSlotConfig
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TdmSlotConfig
impl Debug for TdmSlotConfig
source§impl PartialEq for TdmSlotConfig
impl PartialEq for TdmSlotConfig
source§fn eq(&self, other: &TdmSlotConfig) -> bool
fn eq(&self, other: &TdmSlotConfig) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for TdmSlotConfig
impl Eq for TdmSlotConfig
impl StructuralPartialEq for TdmSlotConfig
Auto Trait Implementations§
impl Freeze for TdmSlotConfig
impl RefUnwindSafe for TdmSlotConfig
impl Send for TdmSlotConfig
impl Sync for TdmSlotConfig
impl Unpin for TdmSlotConfig
impl UnwindSafe for TdmSlotConfig
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)