I am curious why SINGLE_THREADED_SECTION() is used throughout TwoWire, the class for I2C Wire. This seems to be one of the few places where SINGLE_THREADED_SECTION() is used in the system firmware.
Could someone explain why TwoWire needs SINGLE_THREADED_SECTION()?
I have written an I2C library, I2cMaster, that allows large I2C transfers and I also disabled scheduling in this class for I2C transfers.
I am would prefer to not disable scheduling since a 250 byte transfer at 100kHz could take about 25 ms.
I have written I2cMaster so delays should be OK for devices that allow SCL clock stretching.
I happen to have several of the MCP23017 I/O Expander chips mentioned this issue.
I will experiment to see what I can find.
Edit:
After a lot of experiments, I now think the problem is not task switching but a bug in not waiting for the stop condition to complete correctly in endTransmission().
SINGLE_THREADED_SECTION() insures a bit of delay between back-to-back endTransmission()/requestFrom() calls.