[En-Nut-Discussion] Missing possibility in the I2CBUS API
harald.kipp at egnite.de
Tue Feb 19 13:06:42 CET 2013
On 19.02.2013 12:29, Uwe Bonnes wrote:
> while most devices allow to read multiple I2C registers with some
> auto-increment scheme, Maxim for it's MAX44009 ambient light sensor decided
> to require another sequence:
> Start- Chip Address/Write - Write Register number - repeated start -
> Chip Address/Read - Read register content- Start- Chip Address/Write - Write
> Register next number - repeated start - Chip Address/Read - Read register
> content - Stop.
> This means multiple transactions without STOP during the sequence of
There is even more: PMBus allows to change the slave address after a
repeated start (see chapter 9 of the I2C specs.).
I assume, that not all I2C master hardware is able to support this,
neither the Maxim nor the PMBus scheme.
> The i2cbus API implemented in dev/i2cbus.c so long doesn't allow such a
> sequence, to my understanding. Should we extend the API?
For the Maxim, we could argue: "Well, use two separate transactions in
that case." But for the PMBus we are busted in any case.
I do not have the right idea now, but we better change the API soon,
before running into similar backward compatibility issues as before.
I remember a different approach I saw somewhere else, where a list of
transactions was passed to the driver. May be that is more difficult to
use, but would more closely reflect the design of the I2C bus. E.g.
list.sla = 0x22;
list.txlen = 1;
list.txbuf = ®_num;
list.rxlen = 0;
list.rxbuf = NULL;
list.sla = 0x22;
list.txlen = 0;
list.txbuf = NULL;
list.rxlen = 1;
list.rxbuf = ®_val;
list[n].sla = 0x55;
NutI2cBusTransact(bus, list, list_len)
If the hardware is able to do this in one transaction, it can be done.
Otherwise the driver must use several start-stop transactions to execute
More information about the En-Nut-Discussion