EasyManua.ls Logo

Espressif ESP32-S2 - Page 302

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
i2c_num: I2C port number
data: Bytes to write into internal buffer
size: Size, in bytes, of data buffer
ticks_to_wait: Maximum ticks to wait.
int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t *data, size_t max_size, TickType_t
ticks_to_wait)
Read bytes from I2C internal buffer. When the I2C bus receives data, the ISR will copy them from the hardware
RX FIFO to the internal ringbuffer. Calling this function will then copy bytes from the internal ringbuffer to
the data user buffer.
Note This function shall only be called in I2C slave mode.
Return
ESP_FAIL(-1) Parameter error
Others(>=0) The number of data bytes read from I2C slave buffer.
Parameters
i2c_num: I2C port number
data: Buffer to fill with ringbuffers bytes
max_size: Maximum bytes to read
ticks_to_wait: Maximum waiting ticks
esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period)
Set I2C master clock period.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number
high_period: Clock cycle number during SCL is high level, high_period is a 14 bit value
low_period: Clock cycle number during SCL is low level, low_period is a 14 bit value
esp_err_t i2c_get_period(i2c_port_t i2c_num, int *high_period, int *low_period)
Get I2C master clock period.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number
high_period: pointer to get clock cycle number during SCL is high level, will get a 14 bit value
low_period: pointer to get clock cycle number during SCL is low level, will get a 14 bit value
esp_err_t i2c_filter_enable(i2c_port_t i2c_num, uint8_t cyc_num)
Enable hardware filter on I2C bus Sometimes the I2C bus is disturbed by high frequency noise(about 20ns),
or the rising edge of the SCL clock is very slow, these may cause the master state machine to break. Enable
hardware filter can filter out high frequency interference and make the master more stable.
Note Enable filter will slow down the SCL clock.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
i2c_num: I2C port number to filter
cyc_num: the APB cycles need to be filtered (0<= cyc_num <=7). When the period of a pulse is
less than cyc_num * APB_cycle, the I2C controller will ignore this pulse.
esp_err_t i2c_filter_disable(i2c_port_t i2c_num)
Disable filter on I2C bus.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Espressif Systems 291
Submit Document Feedback
Release v4.4

Table of Contents