Support for I2C flags to hold SDA low (Unix) #2160
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
Priority:2
Work that is important, but not critical for the release
Is your feature request related to a problem? Please describe.
I have a Raspberry Pi Compute Module 4 based carrier board that also contains an I2C slave device that needs to be woken up by holding SDA low for at least 75 uS. When the Raspberry Pi's I2C bus runs at 100 kHz, opening a write to 0x00 pulls the SDA low long enough to wake-up the slave. However, this is no longer feasible when the I2C bus runs at 400 kHz; then, the SDA is only pulled low for approximately 25 uS, which is too short.
The problem is that the I2C driver by default stops the transaction when a NAK occurs (which obviously occurs when writing to 0x00, an invalid I2C address). However, Raspberry Pi recently introduced support for the I2C I2C_M_IGNORE_NAK flag (see this commit: raspberrypi/linux@8c4f88c).
Describe the ideal solution
In our implementation, we use the System.Device.Gpio package in combination with the LibGpiodDriver. It would be nice if support for i2c_msg "flags" would be added, so a slave device requiring a low SDA for a longer time than 25 uS to wake up can be woken up nicely.
There are only two alternatives:
See this for more information on the I2C_M_IGNORE_NAK flag: https://www.[kernel.org/doc/Documentation/i2c/i2c-protocol](https://www.kernel.org/doc/Documentation/i2c/i2c-protocol)
In the Discord i2c-discussions thread, @Ellerbach suggested to take a look at the files https://github.com/dotnet/iot/blob/main/src/System.Device.Gpio/System/Device/I2c/UnixI2cBus.cs and https://github.com/dotnet/iot/blob/main/src/System.Device.Gpio/System/Device/I2c/UnixI2cFileTransferBus.cs.
In those files, before the I2C action is executed, the flags are being set.
Perhaps it would be good to introduce an overload function on the Write (and/or Read) functions to add additional flags to an I2C operation. Another idea is to add a method to hold the SDA low for a specified amount of time. A final suggestion would be to expose a property in which the I2C flags can be set.
The text was updated successfully, but these errors were encountered: