Chapter 2. API Reference
according to the desired frequency. For this, set
see the table below.
Note: A clock is not a valid option, if it doesn' t meet the requested capabilities, i.e. any bit of requested capabilities
(clk_flags) is 0 in the clock's capabilities.
Clock
Clock
MAX freq for SCL
name
fre-
quency
APB
80
4 MHz
clock
MHz
REF_TICK
1
50 KHz
MHz
Explanations for
i2c_config_t::clk_flags
Clock's baud rate will not change while APB clock is changing. 2. I2C_SCLK_SRC_FLAG_LIGHT_SLEEP: It
supports Light-sleep mode, which APB clock cannot do.
Explanations for
i2c_config_t::clk_flags
1. I2C_SCLK_SRC_FLAG_AWARE_DFS: Clock's baud rate will not change while APB clock is changing.
2. I2C_SCLK_SRC_FLAG_LIGHT_SLEEP: It supports Light-sleep mode, which APB clock cannot do.
3. Some flags may not be supported on ESP32-S2, reading technical reference manual before using it.
Note: The clock frequency of SCL in master mode should not be lager than max frequency for SCL mentioned in
the table above.
Install Driver
After the I2C driver is configured, install it by calling the function
with the following parameters:
• Port number, one of the two port numbers from
• Master or slave, selected from
• (Slave only) Size of buffers to allocate for sending and receiving data. As I2C is a master-centric bus, data
can only go from the slave to the master at the master's request. Therefore, the slave will usually have a send
buffer where the slave application writes data. The data remains in the send buffer to be read by the master at
the master's own discretion.
• Flags
for
allocating
esp_hw_support/include/esp_intr_alloc.h)
Communication as Master
devices.
ESP32-S2' s I2C controller operating as master is responsible for establishing communication with I2C slave devices
and sending commands to trigger a slave to action, for example, to take a measurement and send the readings back
to the master.
For better process organization, the driver provides a container, called a"command link", that should be populated
with a sequence of commands and then passed to the I2C controller for execution.
Master Write
The example below shows how to build a command link for an I2C master to send n bytes to a slave.
The following describes how a command link for a "master write"is set up and what comes inside:
1. Create a command link with i2c_cmd_link_create().
Then, populate it with the series of data to be sent to the slave:
Espressif Systems
i2c_config_t::clk_flags
Table 2: Characteristics of ESP32-S2 clock sources
Clock capabilities
/
I2C_SCLK_SRC_FLAG_AWARE_DFS,
I2C_SCLK_SRC_FLAG_LIGHT_SLEEP
are as follows: 1. I2C_SCLK_SRC_FLAG_AWARE_DFS:
are as follows:
i2c_port_t
i2c_mode_t
the
interrupt
After installing the I2C driver, ESP32-S2 is ready to communicate with other I2C
282
Submit Document Feedback
to 0. For clock characteristics,
i2c_driver_install()
(see
ESP_INTR_FLAG_*
values
in
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?