EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #293 background imageLoading...
Page #293 background image
Chapter 2. API Reference
according to the desired frequency. For this, set i2c_config_t::clk_flags to 0. For clock characteristics,
see the table below.
Note: A clock is not a valid option, if it doesnt meet the requested capabilities, i.e. any bit of requested capabilities
(clk_flags) is 0 in the clocks capabilities.
Table 2: Characteristics of ESP32-S2 clock sources
Clock
name
Clock
fre-
quency
MAX freq for SCL Clock capabilities
APB
clock
80
MHz
4 MHz /
REF_TICK1
MHz
50 KHz I2C_SCLK_SRC_FLAG_AWARE_DFS,
I2C_SCLK_SRC_FLAG_LIGHT_SLEEP
Explanations for i2c_config_t::clk_flags are as follows: 1. I2C_SCLK_SRC_FLAG_AWARE_DFS:
Clocks 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 are as follows:
1. I2C_SCLK_SRC_FLAG_AWARE_DFS: Clocks 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 i2c_driver_install()
with the following parameters:
Port number, one of the two port numbers from i2c_port_t
Master or slave, selected from i2c_mode_t
(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 masters 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 masters own discretion.
Flags for allocating the interrupt (see ESP_INTR_FLAG_* values in
esp_hw_support/include/esp_intr_alloc.h)
Communication as Master After installing the I2C driver, ESP32-S2 is ready to communicate with other I2C
devices.
ESP32-S2s 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 acommand 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 writeis 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 282
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish