New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i2c_burst_write on nrf51 is not a burst write #11612
Comments
Reviewing the code it appears the extended I2C API from ef26bf7 is based on a generalization that does not account for all the ways subordinate devices might use the protocol. An I2C control interface based on request/response operations exposing "registers" of various sizes that are identified by octet (or multi-octet) values is common, but not universal. Fundamentally there are read operations and there are write operations. The relation between them is determined by the subordinate device. The operation identified as The operation identified as Even if it did (and the Nordic driver seems to implicitly add it), a device is under no obligation to respect repeated starts. In the case of the CCS811 a write of 0x05 followed by a repeated-start write of environmental data starting with 0x61 produces an error, because while 0x05 is a valid "register" 0x61 is not.
Things to consider for issue #4040 if this is to be addressed:
|
After further review, the burst and reg read16/write16 functions should be removed. They're not used anywhere in the tree, and they assume that a device that uses 16-bit addressing expects to receive it in little-endian byte order. The burst and reg read/write_addr functions should go too. The only one used is burst_read_addr once in eth_sam_gmac where the implementation could just as easily use This would remove eight unnecessary functions from the API, simplifying it so people have a better chance of figuring out how to use it properly. |
I've checked
Two fail, one succeeds but would fail if the restart flag were added as proposed above, one succeeds but ignores restart. |
@pabigot will put up a PR for proposed API for dealing with this issue. |
This has been resolved within the constraints of Zephyr process: the problems with the API including that |
Based on bus snooping it appears that on nrf51_ble400 an i2c_burst_write produces two bus transactions: a write of the one byte address, followed by a write of the multi-byte value. On a CCS811 this produces an error due to a write to an invalid register (as the multi-byte value did not start with a register).
Packing the register address and data together with
i2c_write
produces the correct behavior.The text was updated successfully, but these errors were encountered: