Richard-Gemmell / teensy4_i2c

An I2C library for the Teensy 4. Provides slave and master mode.
MIT License
92 stars 19 forks source link

i2c device with 16 bit register addressing #33

Open achrn opened 1 year ago

achrn commented 1 year ago

Hi, thanks for the library. I think this is supposed to be a 'pull request', but unfortunately I don't 'do' github.

I wanted to use the 'simple' functions, but the device I have uses a 16 bit register address space. Therefore, I've added read and write functions for uint16_t reg values. All the changes are within i2c_device.h. In the attached they are all flagged with '\achrn', though if you merge this into the library I don't expect those labels need to remain - it's just a search label to assist review.

My additions assume the 16 bit register address is bigendian.

I've only tested with one device - a ST VL6180X ( a time-of-flight proximity sensor). https://www.st.com/en/imaging-and-photonics-solutions/vl6180x.html It's the only thing I have that has 16 bit register addresses. i2c_device.h.txt

Richard-Gemmell commented 1 year ago

Cool. Thanks for this. I'm in the middle of writing an automated test suite at the moment. I'll add this to my "to do" list and merge it later. That might take a couple of months. :)