Struct esp_idf_svc::hal::i2s::config::StdSlotConfig
source · pub struct StdSlotConfig { /* private fields */ }
Expand description
Standard mode channel slot configuration.
To create a slot configuration, use StdSlotConfig::philips_slot_default
, StdSlotConfig::pcm_slot_default
, or
StdSlotConfig::msb_slot_default
, then customize it as needed.
§Note
The slot_mode
and slot_mask
cause the data to be interpreted in different ways, as noted below.
WS is the “word select” signal, sometimes called LRCLK (left/right clock).
§Transmit
Assuming the buffered data contains the following samples (where a sample may be 1, 2, 3, or 4 bytes, depending
on data_bit_width
):
d[0] | d[1] | d[2] | d[3] | d[4] | d[5] | d[6] | d[7] |
---|---|---|---|---|---|---|---|
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
The actual data on the line will be:
slot_mode | slot_mask | Transmitted Data | |||||||
---|---|---|---|---|---|---|---|---|---|
WS Low | WS High | WS Low | WS High | WS Low | WS High | WS Low | WS High | ||
Mono | Left | 11 | 0 | 12 | 0 | 13 | 0 | 14 | 0 |
Right | 0 | 11 | 0 | 12 | 0 | 13 | 0 | 14 | |
Both | 11 | 11 | 12 | 12 | 13 | 13 | 14 | 14 | |
Stereo | Left | 11 | 0 | 13 | 0 | 15 | 0 | 17 | 0 |
Right | 0 | 12 | 0 | 14 | 0 | 16 | 0 | 18 | |
Both | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
§Receive
Assuming the received data contains the following samples (where a sample may be 8, 16, 24, or 32 bits, depending on data_bit_width
):
WS Low | WS High | WS Low | WS High | WS Low | WS High | WS Low | WS High | |
---|---|---|---|---|---|---|---|---|
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | … |
The actual data in the buffer will be (1-4 bytes, depending on data_bit_width
):
slot_mode | slot_mask | Buffer Contents | |||||||
---|---|---|---|---|---|---|---|---|---|
d[0] | d[1] | d[2] | d[3] | d[4] | d[5] | d[6] | d[7] | ||
Mono | Left | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 |
Right | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | |
Both | Unspecified behavior | ||||||||
Stereo | Any | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
For details, refer to the ESP-IDF Programming Guide details for your specific microcontroller:
- ESP32: STD Tx Mode / STD Rx Mode.
- ESP32-S2: STD Tx Mode / STD Rx Mode
- ESP32-S3: STD Tx Mode / STD Rx Mode
- ESP32-C3: STD Tx Mode / STD Rx Mode.
- ESP32-C6: STD Tx Mode / STD Rx Mode.
- ESP32-H2: STD Tx Mode / STD Rx Mode.
Implementations§
source§impl StdSlotConfig
impl StdSlotConfig
sourcepub fn data_bit_width(self, data_bit_width: DataBitWidth) -> StdSlotConfig
pub fn data_bit_width(self, data_bit_width: DataBitWidth) -> StdSlotConfig
Update the data bit width on this standard slot configuration.
sourcepub fn slot_bit_width(self, slot_bit_width: SlotBitWidth) -> StdSlotConfig
pub fn slot_bit_width(self, slot_bit_width: SlotBitWidth) -> StdSlotConfig
Update the slot bit width on this standard slot configuration.
sourcepub fn slot_mode_mask(
self,
slot_mode: SlotMode,
slot_mask: StdSlotMask,
) -> StdSlotConfig
pub fn slot_mode_mask( self, slot_mode: SlotMode, slot_mask: StdSlotMask, ) -> StdSlotConfig
Update the slot mode and mask on this standard slot configuration.
sourcepub fn ws_width(self, ws_width: u32) -> StdSlotConfig
pub fn ws_width(self, ws_width: u32) -> StdSlotConfig
Update the word select signal width on this standard slot configuration.
sourcepub fn ws_polarity(self, ws_polarity: bool) -> StdSlotConfig
pub fn ws_polarity(self, ws_polarity: bool) -> StdSlotConfig
Update the word select signal polarity on this standard slot configuration.
sourcepub fn bit_shift(self, bit_shift: bool) -> StdSlotConfig
pub fn bit_shift(self, bit_shift: bool) -> StdSlotConfig
Update the bit shift flag on this standard slot configuration.
sourcepub fn left_align(self, left_align: bool) -> StdSlotConfig
pub fn left_align(self, left_align: bool) -> StdSlotConfig
Update the left-alignment flag on this standard slot configuration.
sourcepub fn big_endian(self, big_endian: bool) -> StdSlotConfig
pub fn big_endian(self, big_endian: bool) -> StdSlotConfig
Update the big-endian flag on this standard slot configuration.
sourcepub fn bit_order_lsb(self, bit_order_lsb: bool) -> StdSlotConfig
pub fn bit_order_lsb(self, bit_order_lsb: bool) -> StdSlotConfig
Update the LSB-first flag on this standard slot configuration.
sourcepub fn philips_slot_default(
bits_per_sample: DataBitWidth,
slot_mode: SlotMode,
) -> StdSlotConfig
pub fn philips_slot_default( bits_per_sample: DataBitWidth, slot_mode: SlotMode, ) -> StdSlotConfig
Configure in Philips format in 2 slots.
sourcepub fn pcm_slot_default(
bits_per_sample: DataBitWidth,
slot_mode: SlotMode,
) -> StdSlotConfig
pub fn pcm_slot_default( bits_per_sample: DataBitWidth, slot_mode: SlotMode, ) -> StdSlotConfig
Configure in PCM (short) format in 2 slots.
sourcepub fn msb_slot_default(
bits_per_sample: DataBitWidth,
slot_mode: SlotMode,
) -> StdSlotConfig
pub fn msb_slot_default( bits_per_sample: DataBitWidth, slot_mode: SlotMode, ) -> StdSlotConfig
Configure in MSB format in 2 slots.
Trait Implementations§
source§impl Clone for StdSlotConfig
impl Clone for StdSlotConfig
source§fn clone(&self) -> StdSlotConfig
fn clone(&self) -> StdSlotConfig
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StdSlotConfig
impl Debug for StdSlotConfig
source§impl PartialEq for StdSlotConfig
impl PartialEq for StdSlotConfig
source§fn eq(&self, other: &StdSlotConfig) -> bool
fn eq(&self, other: &StdSlotConfig) -> bool
self
and other
values to be equal, and is used
by ==
.impl Copy for StdSlotConfig
impl Eq for StdSlotConfig
impl StructuralPartialEq for StdSlotConfig
Auto Trait Implementations§
impl Freeze for StdSlotConfig
impl RefUnwindSafe for StdSlotConfig
impl Send for StdSlotConfig
impl Sync for StdSlotConfig
impl Unpin for StdSlotConfig
impl UnwindSafe for StdSlotConfig
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
)