0

I can successfully access a BME680 device through I²C. i2cdetect 1 shows the device and I found out that two APIs seem to be perfectly usable -- I wonder which one I should prefer.

I open() the device, ioctl() to the corresponding address and then can use either the most generic write() or the SMBus special i2c_smbus_write_i2c_block_data() to write data to the required address. For read the proper combination of write()+read() works as smoothly as i2c_smbus_read_i2c_block_data().

Since I am not quite the kernel coder and intend to walk this road only as far as really required, I wonder which approach I should prefer. I could roll a dice -- or make a reasonable decision.

Could anybody point out which is the intended approach?

2

The SMBus i2c_smbus_read_i2c_block_data() command just does an I2C write as does your open, ioctl and write.

It really doesn't matter which you use, it's really a matter of personal taste.

Whichever you use I would put a comment in the code saying that the other may be used instead (in case the code is ported to a different environment where only the other works).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.