On Tuesday, February 10, 2015 07:29:33 AM Werner Zeh wrote:
Hi coreboot community.
Hi back at you.
- Store the offset we need (in this case 20) into a buffer
- Call i2c_write_raw(bus, chip_adr, &buffer, 1);
- Call i2c_read_raw(bus, chip_adr, &buffer,10);
That's actually the way I2C is designed to work, and this sort of API models it more accurately. Linux uses it. libeopencm uses it. spidev uses it.
Here are my personal problems with this kind of interface:
Then provide utility functions to do i2c_reg_(read|write) which wrap i2c_transfer() directly. Construct the complete I2c transaction as an array of i2c_seg and pass that to i2c_transfer().
- Where we earlier had one simple call to i2c_read(), we now have to
fill
one variable with the length we need and call two different functions (i2c_write_raw and i2c_read_raw). 2. Though the read transfer is one logical access to the slave, we have split it into two (without any benefit I can see now) 3. We have added two wrapper layers where we earlier had none!
Not quite so. The i2c read/write of the past actually squashed together several steps, which ended up being more code as you had to fully model every sort of transaction you could think of doing. There's no extra wrapping. The code was just reorganized.
Alex