<divclass="textblock"><p>Arduino Hardware I2C for AVR (plain c)</p>
<p>Hardware I2C library for AVR MCUs (lib intended for I2C protocols development in c, for easier ports to other MCUs)</p>
<h2>Library choice</h2>
<ul>
<li>cI2C library implements I2C bus for AVR targets (Uno, Nano, Mega...)<ul>
<li>you may prefer this one when:<ul>
<li>working on AVR targets</li>
<li>interrupts are not needed</li>
</ul>
</li>
</ul>
</li>
<li>WireWrapper implements I2C bus for every platform that includes Wire library<ul>
<li>you would have to use this one when:<ul>
<li>working on non-AVR targets</li>
<li>portability is needed (using Wire library)</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>No refactoring is required when switching between <b>cI2C</b>&<b>WireWrapper</b> libs; Both libs share same Typedefs, Functions & Parameters.</p>
<h2>Notes</h2>
<ul>
<li>cI2C is written in plain c (intentionally)</li>
<li>cI2C does not use any interrupt (yet, but soon will have to)</li>
<li>cI2C is designed to act as bus Master (Slave mode will be considered in future releases)</li>
<li>cI2C is set to work on AVR targets only<ul>
<li>for other targets, you may use <b>WireWrapper</b> instead (will be using Wire)</li>
</ul>
</li>
</ul>
<h2>Usage</h2>
<p>This library is intended to be able to work with multiple slaves connected on the same I2C bus. Thus, the I2C bus and Slaves are defined separately.</p>
<ul>
<li>On one hand, I2C bus has to be initialized with appropriate speed:<ul>
<li>use <code>I2C_init(speed)</code>: speed can be chosen from <code>I2C_SPEED</code> enum for convenience, or passing an integer as parameter</li>
</ul>
</li>
<li>On the other hand, Slave(s) have to be defined and initialized too:<ul>
<li>use <code>I2C_SLAVE</code> typedef to declare slaves structs</li>
<li><code>pSlave</code>: pointer to the slave struct to write to</li>
<li><code>regaddr</code>: start address to write to</li>
<li><code>pData</code>: pointer to the block of datas to write to slave</li>
<li><code>bytes</code>: number of bytes to write to slave</li>
<li>returns <code>true</code> if write is ok, <code>false</code> otherwise</li>
</ul>
</li>
</ul>
<h2>Examples included</h2>
<p>following examples should work with any I2C EEPROM/FRAM with address 0x50 (yet function to get Chip ID are device dependent (and will probably only work on FUJITSU devices))</p><ul>
<li><ahref="examples/ci2c_master_write/ci2c_master_write.ino">ci2c_master_write.ino</a>: Write some bytes to FRAM and compare them with what's read afterwards</li>
<li><ahref="examples/ci2c_master_read/ci2c_master_read.ino">ci2c_master_read.ino</a>: Read some bytes in FRAM</li>
<li><ahref="examples/ci2c_advanced/ci2c_advanced.ino">ci2c_advanced.ino</a>: Redirecting slave write & read functions (to custom functions following typedef)</li>
</ul>
<h2>Documentation</h2>
<p>Doxygen doc can be generated using "Doxyfile".</p>