Couple things to look at for improving the I2C interface.
- Check if we receive an NACK right after the address. Then pass the error upstream. Right now we pretty much assume successful transmission if the i2c peripheral is not blocked.
- For
write_read calls use an auto restart. Currently it is just a shortcut for calling write and read high level commands individually.
- Clean up interrupts.
enable enables all the required interrupts rather that selectively choosing the ones that are needed. Would make the code more fault tolerant with undefined behavior.
- Disable peripheral after transaction for power savings.
Couple things to look at for improving the I2C interface.
write_readcalls use an auto restart. Currently it is just a shortcut for callingwriteandreadhigh level commands individually.enableenables all the required interrupts rather that selectively choosing the ones that are needed. Would make the code more fault tolerant with undefined behavior.