EasyManua.ls Logo

Espressif ESP32-S2 - Page 298

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
Loading...
Chapter 2. API Reference
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number to attach handler to
fn: ISR handler function
arg: Parameter for the ISR handler
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.
handle: Handle return from esp_intr_alloc.
esp_err_t i2c_isr_free(intr_handle_t handle)
Delete and free I2C ISR handle.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
handle: Handle of isr to delete.
esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num, bool sda_pullup_en, bool
scl_pullup_en, i2c_mode_t mode)
Configure GPIO pins for I2C SCK and SDA signals.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number
sda_io_num: GPIO number for I2C SDA signal
scl_io_num: GPIO number for I2C SCL signal
sda_pullup_en: Enable the internal pullup for SDA pin
scl_pullup_en: Enable the internal pullup for SCL pin
mode: I2C mode
esp_err_t i2c_master_write_to_device(i2c_port_t i2c_num, uint8_t device_address, const
uint8_t *write_buer, size_t write_size, TickType_t
ticks_to_wait)
Perform a write to a device connected to a particular I2C port. This function is a wrapper to
i2c_master_start(), i2c_master_write(), i2c_master_read(), etc It shall only be
called in I2C master mode.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
ESP_FAIL Sending command error, slave hasnt ACK the transfer.
ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
Parameters
i2c_num: I2C port number to perform the transfer on
device_address: I2C devices 7-bit address
write_buffer: Bytes to send on the bus
write_size: Size, in bytes, of the write buffer
ticks_to_wait: Maximum ticks to wait before issuing a timeout.
esp_err_t i2c_master_read_from_device(i2c_port_t i2c_num, uint8_t device_address,
uint8_t *read_buer, size_t read_size, TickType_t
ticks_to_wait)
Perform a read to a device connected to a particular I2C port. This function is a wrapper to
i2c_master_start(), i2c_master_write(), i2c_master_read(), etc It shall only be
called in I2C master mode.
Return
Espressif Systems 287
Submit Document Feedback
Release v4.4

Table of Contents