Description
The I2C 'repeated start' handling code for ESP32 fails to drive the ESP-IDF correctly, which leads to very inefficient blocking use of the bus when when register/memory reads are performed (of course, this is only of concern if high I2C performance on a busy bus is required).
For example, see the large dead time between register setup and eventual read in the trace below.
This is caused by an elegant, but in the end insufficient, read_mem
function in extmod/machine_i2c.c
.
By modifying read_mem
to use an updated machine_hw_i2c_transfer
in ports/esp32/machine_i2c.c
, the problem is resolved:
This also makes read_mem
consistent with write_mem
.
This has been tested with 1MHz bus operation using a wide variety of sensors and addressing modes; happy to raise a PR if there is interest (ie if it is ever likely to be merged)