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 #297 background imageLoading...
Page #297 background image
Chapter 2. API Reference
Functions
esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_buf_len, size_t
slv_tx_buf_len, int intr_alloc_flags)
Install an I2C driver.
Note In master mode, if the cache is likely to be disabled(such as write flash) and the slave is time-sensitive,
ESP_INTR_FLAG_IRAM is suggested to be used. In this case, please use the memory allocated from
internal RAM in i2c read and write function, because we can not access the psram(if psram is enabled)
in interrupt handle function when cache is disabled.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
ESP_FAIL Driver installation error
Parameters
i2c_num: I2C port number
mode: I2C mode (either master or slave)
slv_rx_buf_len: Receiving buffer size. Only slave mode will use this value, it is ignored in
master mode.
slv_tx_buf_len: Sending buffer size. Only slave mode will use this value, it is ignored in
master mode.
intr_alloc_flags: Flags used to allocate the interrupt. One or multiple (ORred)
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
esp_err_t i2c_driver_delete(i2c_port_t i2c_num)
Delete I2C driver.
Note This function does not guarantee thread safety. Please make sure that no thread will continuously hold
semaphores before calling the delete function.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port to delete
esp_err_t i2c_param_config(i2c_port_t i2c_num, const i2c_config_t *i2c_conf)
Configure an I2C bus with the given configuration.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port to configure
i2c_conf: Pointer to the I2C configuration
esp_err_t i2c_reset_tx_fifo(i2c_port_t i2c_num)
reset I2C tx hardware fifo
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number
esp_err_t i2c_reset_rx_fifo(i2c_port_t i2c_num)
reset I2C rx fifo
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number
esp_err_t i2c_isr_register(i2c_port_t i2c_num, void (*fn))void *
, void *arg, int intr_alloc_flags, intr_handle_t *handleRegister an I2C ISR handler.
Espressif Systems 286
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