xcore/sc_i2c — pull request #11 by henkmuller (2011-12-07 20:09:52+00:00)
Title: Small version of module_i2c_simple

This version of the repo has a much smaller and easier to understand i2c function. Main properties:
* Source code 116 lines, compiles to 400 bytes of code (reduction of 60%).
* uses functions to abstract actions in rx/tx, reducing code size and improving readability.
* Properly drives the clock in 4 quarters, samples midway, pulls low at start.
* Does not drive scl/sda high, but let external pull-up take care of that.
* Tested on a single board. Output on scope looks good and can read/write to a codec.

This would be a good basis to make an I2C function that is multi-master and that implements clock stretching. The latter should be a trivial addition (when pinseq(1) inserted in 3 places), the former is a bit more work. It will need some more rigorous testing.

I have not look at the slave code.