fix(i2c_slave): filter out fake request for esp32

Closes https://github.com/espressif/esp-idf/issues/18268
This commit is contained in:
Chen Chen
2026-02-25 11:55:29 +08:00
parent c8dde73db5
commit eea66f2d58
4 changed files with 25 additions and 1 deletions
@@ -36,6 +36,12 @@ Typically, an I2C slave device has a 7-bit address or 10-bit address. {IDF_TARGE
Keep in mind that the higher the frequency, the smaller the pull-up resistor should be (but not less than 1 kΩ). Indeed, large resistors will decline the current, which will increase the clock switching time and reduce the frequency. A range of 2 kΩ to 5 kΩ is recommended, but adjustments may also be necessary depending on their current draw requirements.
.. only:: esp32
.. note::
The ESP32 I2C controller does not support clock stretching when operating as a slave. Therefore, in addition to driver configuration, the application layer should pay attention to speed matching and synchronization between master and slave devices: if the master processes too fast while the slave responds slowly, communication errors or data loss may occur. It is recommended to use application-layer data verification, GPIO signal synchronization, or other methods to achieve data synchronization between master and slave. Please confirm whether the ESP32 slave mode meets your project requirements according to your use case before use.
I2C Clock Configuration
-----------------------
@@ -36,6 +36,12 @@ I2C 是一种串行同步半双工通信协议,总线上可以同时挂载多
请注意,SCL 的频率越高,上拉电阻应该越小(但不能小于 1 kΩ)。较大的电阻会降低电流,增加时钟切换时间并降低频率。通常推荐 2 kΩ 到 5 kΩ 左右的电阻,也可根据电流需求进行一定调整。
.. only:: esp32
.. note::
ESP32 的 I2C 控制器作为从机时不支持时钟拉伸(clock stretching)。因此除驱动配置外,应用层还需关注主从设备之间的速度匹配与同步:若主机处理速度过快、从机处理较慢,可能导致通信异常或数据丢失。建议使用应用层数据校验、gpio 信号同步等方式实现主从之间数据同步。使用前请根据使用场景确认 ESP32 的从机模式是否满足您的项目需求。
I2C 时钟配置
------------