1
0
mirror of https://github.com/SMFSW/cI2C synced 2024-11-25 19:24:22 +01:00
cI2C/html/md__r_e_a_d_m_e.html
2018-05-03 22:21:29 +00:00

169 lines
7.5 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>cI2C=Arduino Hardware I2C for AVR (in plain c): cI2C [![Build Status](https://travis-ci.org/SMFSW/cI2C.svg?branch=master)](https://travis-ci.org/SMFSW/cI2C)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">cI2C=Arduino Hardware I2C for AVR (in plain c)
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">cI2C [![Build Status](<a href="https://travis-ci.org/SMFSW/cI2C.svg?branch=master">https://travis-ci.org/SMFSW/cI2C.svg?branch=master</a>)](<a href="https://travis-ci.org/SMFSW/cI2C">https://travis-ci.org/SMFSW/cI2C</a>) </div> </div>
</div><!--header-->
<div class="contents">
<div class="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> &amp; <b>WireWrapper</b> libs; Both libs share same Typedefs, Functions &amp; 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>use <code>I2C_slave_init(pSlave, addr, regsize)</code><ul>
<li><code>pSlave</code>: pointer to the slave struct to initialize</li>
<li><code>addr</code>: slave I2C address (don't shift addr, lib takes care of that)</li>
<li><code>regsize</code>: width of internal slave registers (to be chosen from <code>I2C_INT_SIZE</code>)</li>
</ul>
</li>
<li>in case you need to use custom R/W procedures for a particular slave:<ul>
<li>use <code>I2C_slave_set_rw_func(pSlave, pFunc, rw)</code><ul>
<li><code>pSlave</code>: pointer to the slave declaration to initialize</li>
<li><code>pFunc</code>: pointer to the Read or Write bypass function</li>
<li><code>rw</code>: can be chosen from <code>I2C_RW</code> enum (wr=0, rd=1)</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>After all inits are done, the lib can basically be used this way:</p><ul>
<li><code>I2C_read(pSlave, regaddr, pData, bytes)</code><ul>
<li><code>pSlave</code>: pointer to the slave struct to read from</li>
<li><code>regaddr</code>: start address to read from</li>
<li><code>pData</code>: pointer to the place where datas read will be stored</li>
<li><code>bytes</code>: number of bytes to read from slave</li>
<li>returns <code>true</code> if read is ok, <code>false</code> otherwise</li>
</ul>
</li>
<li><code>I2C_write(pSlave, regaddr, pData, bytes)</code><ul>
<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><a href="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><a href="examples/ci2c_master_read/ci2c_master_read.ino">ci2c_master_read.ino</a>: Read some bytes in FRAM</li>
<li><a href="examples/ci2c_advanced/ci2c_advanced.ino">ci2c_advanced.ino</a>: Redirecting slave write &amp; read functions (to custom functions following typedef)</li>
</ul>
<h2>Documentation</h2>
<p>Doxygen doc can be generated using "Doxyfile".</p>
<p>See <a href="https://smfsw.github.io/cI2C/">generated documentation</a></p>
<h2>Release Notes</h2>
<p>See <a class="el" href="md__release_notes.html">release notes</a></p>
<h2>See also</h2>
<p><b>cI2C</b></p><ul>
<li><a href="https://github.com/SMFSW/cI2C">cI2C github</a> - C implementation of this library</li>
</ul>
<p><b>WireWrapper</b></p><ul>
<li><a href="https://github.com/SMFSW/WireWrapper">WireWrapper github</a> - Cpp implementation using Wire Wrapper </li>
</ul>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>