Chapter 2. API Reference
For more information, see ESP32-S2 Technical Reference Manual > I2S Controller (I2S) > LCD Mode [PDF].
Note: For high accuracy clock applications, use the APLL_CLK clock source, which has the frequency range of 16
~ 128 MHz. You can enable the APLL_CLK clock source by setting i2s_config_t::use_apll to TRUE.
If i2s_config_t::use_apll = TRUE and i2s_config_t::fixed_mclk > 0, then the master clock
output frequency for I2S will be equal to the value of i2s_config_t::fixed_mclk, which means that the
mclk frequency is provided by the user, instead of being calculated by the driver.
The clock rate of the word select line, which is called audio left-right clock rate (LRCK) here, is al-
ways the divisor of the master clock output frequency and for which the following is always true: 0 <
MCLK/LRCK/channels/bits_per_sample < 64.
Functional Overview
Installing the Driver
Install the I2S driver by calling the function :cpp:func`i2s_driver_install` and passing the
following arguments:
• Port number
• The structure
i2s_config_t
• Event queue size and handle
Once :cpp:func`i2s_driver_install` returns ESP_OK, it means I2S has started.
Configuration example:
static const
int
i2s_num
i2s_config_t i2s_config
.mode
=
I2S_MODE_MASTER
.sample_rate
=
44100,
.bits_per_sample
.channel_format
.communication_format
.tx_desc_auto_clear
.dma_buf_count
=
.dma_buf_len
=
64,
.use_apll
=
false,
.intr_alloc_flags
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
Setting Communication Pins
routed. For this, call the function :cpp:func`i2s_set_pin` and pass the following arguments to it:
• Port number
• The structure
i2s_pin_config_t
MCK, BCK, WS, DATA out, and DATA in signals. If you want to keep a currently allocated pin number for
a specific signal, or if this signal is unused, then pass the macro I2S_PIN_NO_CHANGE. See the example
below.
Note: MCK only takes effect in I2S_MODE_MASTER mode.
static const
i2s_pin_config_t pin_config
.mck_io_num
=
0,
.bck_io_num
=
4,
Espressif Systems
with defined communication parameters
=
0;
// i2s port number
=
{
|
I2S_MODE_TX,
=
I2S_BITS_PER_SAMPLE_16BIT,
=
I2S_CHANNEL_FMT_RIGHT_LEFT,
=
I2S_COMM_FORMAT_STAND_I2S
=
false,
8,
=
ESP_INTR_FLAG_LEVEL1
Once the driver is installed, configure physical GPIO pins to which signals will be
defining the GPIO pin numbers to which the driver should route the
Submit Document Feedback
// Interrupt level 1, default 0
=
{
297
(continues on next page)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?