Espressif ESP32-S2 Programming Manual page 302

Table of Contents

Advertisement

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
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 ringbuffer's bytes
• max_size: Maximum bytes to read
• ticks_to_wait: Maximum waiting ticks
esp_err_t i2c_set_period(i2c_port_t
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
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
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
Disable filter on I2C bus.
Return
• ESP_OK Success
• ESP_ERR_INVALID_ARG Parameter error
Espressif Systems
i2c_num, uint8_t *data, size_t max_size, TickType_t
ticks_to_wait)
i2c_num, int high_period, int low_period)
i2c_num, int *high_period, int *low_period)
i2c_num, uint8_t cyc_num)
i2c_num)
291
Submit Document Feedback
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Table of Contents

Save PDF