Espressif ESP32-S2 Programming Manual page 309

Table of Contents

Advertisement

Chapter 2. API Reference
.ws_io_num
=
5,
.data_out_num
=
.data_in_num
=
I2S_PIN_NO_CHANGE
};
i2s_set_pin(i2s_num, &pin_config);
Running I2S Communication
• Prepare the data for sending
• Call the function
i2s_write()
The function will write the data to the DMA Tx buffer, and then the data will be transmitted automatically.
i2s_write(I2S_NUM, samples_data, ((bits+8)/16)*SAMPLE_PER_CYCLE*4, &i2s_bytes_
write, 100);
To retrieve received data, use the function i2s_read(). It will retrieve the data from the DMA Rx buffer, once
the data is received by the I2S controller.
i2s_read(I2S_NUM, data_recv, ((bits+8)/16)*SAMPLE_PER_CYCLE*4,
100);
You can temporarily stop the I2S driver by calling the function i2s_stop(), which will disable the I2S Tx/Rx
units until the function
i2s_start()
start up automatically eliminating the need to call i2s_start().
Deleting the Driver
If the established communication is no longer required, the driver can be removed to free
allocated resources by calling i2s_driver_uninstall().
Application Example
A code example for the I2S driver can be found in the directory peripherals/i2s.
In addition, there is a short configuration examples for the I2S driver.
I2S configuration
Example for general usage.
#include
"driver/i2s.h"
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
};
static const
i2s_pin_config_t pin_config
.bck_io_num
=
4,
Espressif Systems
18,
To perform a transmission:
and pass the data buffer address and data length to it
is called. If the function :cpp:func`i2s_driver_install` is used, the driver will
=
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
Submit Document Feedback
// Interrupt level 1, default 0
=
{
298
(continued from previous page)
&i2s_bytes_read,␣
(continues on next page)
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF