The LCD I2C code that Anthony was good enough to share was a great starting point for my I2C master driver. It was VERY helpful to have a working example. I think I added some value and took the code to the next level. New features:
- Replace the "byte shifting complete" timing loop with a loop waiting on the hardware indication (the user no longer needs to adjust the timing loop for local CPU clock speed, except for the IBFD value which I haven't had time to figure out, math-wise, it works, I kept going)
- Same with stop condition asserted (don't start another transfer until last one is really stopped, now transfers are closely spaced without timing risk)
- Multi-byte write allowed to a reg number (allows efficient filter table loading into a codec for example)
i2c.h and i2c_vybrid.c form the core package. vybrid_i2c.h are the I2C peripheral register defines. adc3101.c is an example using this new code.
Just trying to give back to the community. Maybe I can save someone else some code development time. I've done a good amount of testing and have verified the low-level operation on a logic analyzer.
Enjoy, Chris