We have C/C++ I2C code running on the Raspberry Pi that works well with the LTC4015 operating at I2C device address 0x68. We can read and write many LTC4015 register values to configure the LTC4015 and monitor battery charging and discharging.
Now we are exploring SMBALERT. We can enable SMBALERT via I2C for a couple of experimental alerts EN_CC_CV_CHARGE_ALERT and EN_CHARGER_SUSPENDED_ALERT, and the SMBALERT pin on the LTC4015 DC2039A dev board is asserted low as we would expect.
We could use some guidance to better understand the SMBALERT ARA (Alert Response Address) and how to clear SMBALERT.
Should the host (Raspberry Pi running Linux) try to read or write I2C device address 0x19 to clear SMBALERT? The LTC4015 datasheet and other web references seem to indicate that the LTC4015 and other SMBALERT compliant devices sharing the SMBALERT line should all respond to that ARA.
But on the Raspberry Pi, with SMBALERT asserted, the i2cset and i2cget commands fail when attempting to write or read I2C device address 0x19, as shown:
user@rpi:~$ sudo i2cset -y 1 0x19 0 Error: Write failed
user@rpi:~$ sudo strace i2cset -y 1 0x19 0 <snip> openat(AT_FDCWD, "/dev/i2c-1", O_RDWR) = 3 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x5, 0), 0xbeab5614) = 0 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x3, 0), 0x19) = 0 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x20, 0), 0xbeab55b0) = -1 EREMOTEIO (Remote I/O error) write(2, "Error: Write failed\n", 20Error: Write failed ) = 20 close(3) = 0 exit_group(1) = ? +++ exited with 1 +++
user@rpi:~$ sudo strace i2cget -y 1 0x19 <snip> openat(AT_FDCWD, "/dev/i2c-1", O_RDWR) = 3 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x5, 0), 0xbe99f634) = 0 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x3, 0), 0x19) = 0 ioctl(3, _IOC(_IOC_NONE, 0x7, 0x20, 0), 0xbe99f5c8) = -1 EREMOTEIO (Remote I/O error) close(3) = 0 write(2, "Error: Read failed\n", 19Error: Read failed ) = 19 exit_group(2) = ? +++ exited with 2 +++
We would appreciate any guidance how to clear SMBALERT via I2C, particularly if you know how to invoke that on the Raspberry Pi (or other Linux) using the i2cset and i2cget utilities.
Can you take a scope plot of the communication and compare it against this:
This is a general SMBus protocol, not unique to LTC4015.
If you share your scope plot, I'll take a look too. Thanks!
Here are a couple of scope pics for attempts to read the SMBALERT ARA I2C address 0x19 using Linux i2cget as shown in my original post.
If I am interpreting those correctly, it looks like the ACK/NACK from the LTC4015 is NACK. And I see web references that Linux I2C will respond with EREMOTEIO (as seen in strace output in my original post) when the I2C device does not respond with ACK, so that would correlate.
FWIW, when using Linux i2cget to read from I2C address 0x68 (the LTC4015 normal I2C device address), the ACK/NACK is set (low) to ACK. So the LTC4015 is responding to device address 0x68, but not to SMBALERT ARA address 0x19.
Thanks for taking a look.
You need to right-shift that ARA by one bit. Here's a table from the official SMBus spec (binary, so a little clearer):
0x19 is the full byte including the R/W bit. I think that should fix it for you.
That works (right-shifting 0x19 to 0x0c clears SMBALERT):
user@rpi:~$ sudo i2cget -y 1 0x0c 0xd1
Thanks very much for your help.