Module esp32h2_hal::i2s
source · Expand description
§I2S Master
§Overview
The I2S Master peripheral driver provides support for the I2S (Inter-IC Sound) Master functionality on ESP chips. It enables audio data transmission and reception with external audio devices, such as DACs (Digital-to-Analog Converters) and ADCs (Analog-to-Digital Converters) through the I2S interface. Also this module supports different data formats, including varying data and channel widths, different standards, such as the Philips standard and configurable pin mappings for I2S clock (BCLK), word select (WS), and data input/output (DOUT/DIN).
The driver uses DMA (Direct Memory Access) for efficient data transfer and
supports various configurations, such as different data formats, standards
(e.g., Philips) and pin configurations. It relies on other peripheral
modules, such as
- GPIO
- DMA
- system
(to configure and enable the I2S peripheral)
§Examples
§initialization
let i2s = I2s::new(
peripherals.I2S0,
Standard::Philips,
DataFormat::Data16Channel16,
44100u32.Hz(),
dma_channel.configure(
false,
&mut tx_descriptors,
&mut rx_descriptors,
DmaPriority::Priority0,
),
&clocks,
)
.with_mclk(io.pins.gpio4);
§Reading
let i2s_rx = i2s.i2s_rx.
.with_bclk(io.pins.gpio1)
.with_ws(io.pins.gpio2)
.with_dout(io.pins.gpio5)
.build();
// Creating DMA buffer
static mut BUFFER: [u8; 4092 * 4] = [0u8; 4092 * 4];
let buffer: &'static mut [u8; 4092 * 4] = unsafe { &mut BUFFER };
let mut transfer = i2s_rx.read_dma_circular(buffer).unwrap();
println!("Started transfer");
loop {
let avail = transfer.available();
if avail > 0 {
let mut rcv = [0u8; 5000];
transfer.pop(&mut rcv[..avail]).unwrap();
println!("Received {:x?}...", &rcv[..30]);
}
}
Structs§
- Instance of the I2S peripheral driver
- An in-progress DMA read transfer.
- I2S RX channel
- I2S TX channel
- An in-progress DMA write transfer.
Enums§
- Supported data formats
- I2S Error
- Supported standards.
Traits§
- Blocking I2S Read
- Initiate a DMA rx transfer
- Blocking I2s Write
- Initiate a DMA tx transfer