manual__i2cmaster.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.9.1"/>
  7. <title>AVR-GCC Libraries: I2C Master library</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  15. <div id="titlearea">
  16. <table cellspacing="0" cellpadding="0">
  17. <tbody>
  18. <tr style="height: 56px;">
  19. <td style="padding-left: 0.5em;">
  20. <div id="projectname">AVR-GCC Libraries
  21. </div>
  22. </td>
  23. </tr>
  24. </tbody>
  25. </table>
  26. </div>
  27. <!-- end header part -->
  28. <!-- Generated by Doxygen 1.8.9.1 -->
  29. <div id="navrow1" class="tabs">
  30. <ul class="tablist">
  31. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  32. <li><a href="modules.html"><span>Modules</span></a></li>
  33. <li><a href="files.html"><span>Files</span></a></li>
  34. </ul>
  35. </div>
  36. </div><!-- top -->
  37. <div class="header">
  38. <div class="summary">
  39. <a href="#define-members">Macros</a> &#124;
  40. <a href="#func-members">Functions</a> </div>
  41. <div class="headertitle">
  42. <div class="title">I2C Master library</div> </div>
  43. </div><!--header-->
  44. <div class="contents">
  45. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  46. <p>I2C (TWI) Master Software Library. </p>
  47. <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="i2cmaster_8h.html">i2cmaster.h</a>&gt;</span> </div>
  48. </div><!-- fragment --><p>Basic routines for communicating with I2C slave devices. This single master implementation is limited to one bus master on the I2C bus.</p>
  49. <p>This I2c library is implemented as a compact assembler software implementation of the I2C protocol which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c). Since the API for these two implementations is exactly the same, an application can be linked either against the software I2C implementation or the hardware I2C implementation.</p>
  50. <p>Use 4.7k pull-up resistor on the SDA and SCL pin.</p>
  51. <p>Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module i2cmaster.S to your target when using the software I2C implementation !</p>
  52. <p>Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.</p>
  53. <dl class="section note"><dt>Note</dt><dd>The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted to GNU assembler and AVR-GCC C call interface. Replaced the incorrect quarter period delays found in AVR300 with half period delays.</dd></dl>
  54. <dl class="section author"><dt>Author</dt><dd>Peter Fleury <a href="#" onclick="location.href='mai'+'lto:'+'pfl'+'eu'+'ry@'+'gm'+'x.c'+'h'; return false;">pfleu<span style="display: none;">.nosp@m.</span>ry@g<span style="display: none;">.nosp@m.</span>mx.ch</a> <a href="http://tinyurl.com/peterfleury">http://tinyurl.com/peterfleury</a> </dd></dl>
  55. <dl class="section copyright"><dt>Copyright</dt><dd>(C) 2015 Peter Fleury, GNU General Public License Version 3</dd></dl>
  56. <dl class="section user"><dt>API Usage Example</dt><dd>The following code shows typical usage of this library, see example test_i2cmaster.c</dd></dl>
  57. <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="i2cmaster_8h.html">i2cmaster.h</a>&gt;</span></div>
  58. <div class="line"></div>
  59. <div class="line"></div>
  60. <div class="line"><span class="preprocessor">#define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet</span></div>
  61. <div class="line"></div>
  62. <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div>
  63. <div class="line">{</div>
  64. <div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ret;</div>
  65. <div class="line"></div>
  66. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#ga5730d9445429351b9f750084c5cb5aae">i2c_init</a>(); <span class="comment">// initialize I2C library</span></div>
  67. <div class="line"></div>
  68. <div class="line"> <span class="comment">// write 0x75 to EEPROM address 5 (Byte Write) </span></div>
  69. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gaee3747a01738315cd5580588994b6c28">i2c_start_wait</a>(Dev24C02+<a class="code" href="group__pfleury__ic2master.html#ga9536bf85bced4f4e549a82fb18eb6140">I2C_WRITE</a>); <span class="comment">// set device address and write mode</span></div>
  70. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gadd947aade44ed6b7f92265f9dec4a711">i2c_write</a>(0x05); <span class="comment">// write address = 5</span></div>
  71. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gadd947aade44ed6b7f92265f9dec4a711">i2c_write</a>(0x75); <span class="comment">// write value 0x75 to EEPROM</span></div>
  72. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gad35d4e4f52ca74b503d5e5e1e0a3f5f3">i2c_stop</a>(); <span class="comment">// set stop conditon = release bus</span></div>
  73. <div class="line"></div>
  74. <div class="line"></div>
  75. <div class="line"> <span class="comment">// read previously written value back from EEPROM address 5 </span></div>
  76. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gaee3747a01738315cd5580588994b6c28">i2c_start_wait</a>(Dev24C02+<a class="code" href="group__pfleury__ic2master.html#ga9536bf85bced4f4e549a82fb18eb6140">I2C_WRITE</a>); <span class="comment">// set device address and write mode</span></div>
  77. <div class="line"></div>
  78. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gadd947aade44ed6b7f92265f9dec4a711">i2c_write</a>(0x05); <span class="comment">// write address = 5</span></div>
  79. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#ga93a9461da34295250ba935bbce9a980d">i2c_rep_start</a>(Dev24C02+<a class="code" href="group__pfleury__ic2master.html#gab5c0fbe837494c5f9130a5914854250d">I2C_READ</a>); <span class="comment">// set device address and read mode</span></div>
  80. <div class="line"></div>
  81. <div class="line"> ret = <a class="code" href="group__pfleury__ic2master.html#gad89e839fc17b05fbb5dd79897c55234e">i2c_readNak</a>(); <span class="comment">// read one byte from EEPROM</span></div>
  82. <div class="line"> <a class="code" href="group__pfleury__ic2master.html#gad35d4e4f52ca74b503d5e5e1e0a3f5f3">i2c_stop</a>();</div>
  83. <div class="line"></div>
  84. <div class="line"> <span class="keywordflow">for</span>(;;);</div>
  85. <div class="line">}</div>
  86. </div><!-- fragment --> <table class="memberdecls">
  87. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
  88. Macros</h2></td></tr>
  89. <tr class="memitem:gab5c0fbe837494c5f9130a5914854250d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#gab5c0fbe837494c5f9130a5914854250d">I2C_READ</a>&#160;&#160;&#160;1</td></tr>
  90. <tr class="separator:gab5c0fbe837494c5f9130a5914854250d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  91. <tr class="memitem:ga9536bf85bced4f4e549a82fb18eb6140"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga9536bf85bced4f4e549a82fb18eb6140">I2C_WRITE</a>&#160;&#160;&#160;0</td></tr>
  92. <tr class="separator:ga9536bf85bced4f4e549a82fb18eb6140"><td class="memSeparator" colspan="2">&#160;</td></tr>
  93. <tr class="memitem:gad33503cf741851d1bca1d274e9001796"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gad33503cf741851d1bca1d274e9001796"></a>
  94. #define&#160;</td><td class="memItemRight" valign="bottom"><b>i2c_read</b>(ack)&#160;&#160;&#160;(ack) ? <a class="el" href="group__pfleury__ic2master.html#ga32ac22052d55f93375b024192217db21">i2c_readAck</a>() : <a class="el" href="group__pfleury__ic2master.html#gad89e839fc17b05fbb5dd79897c55234e">i2c_readNak</a>();</td></tr>
  95. <tr class="separator:gad33503cf741851d1bca1d274e9001796"><td class="memSeparator" colspan="2">&#160;</td></tr>
  96. </table><table class="memberdecls">
  97. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  98. Functions</h2></td></tr>
  99. <tr class="memitem:ga5730d9445429351b9f750084c5cb5aae"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga5730d9445429351b9f750084c5cb5aae">i2c_init</a> (void)</td></tr>
  100. <tr class="memdesc:ga5730d9445429351b9f750084c5cb5aae"><td class="mdescLeft">&#160;</td><td class="mdescRight">initialize the I2C master interace. Need to be called only once <a href="#ga5730d9445429351b9f750084c5cb5aae">More...</a><br /></td></tr>
  101. <tr class="separator:ga5730d9445429351b9f750084c5cb5aae"><td class="memSeparator" colspan="2">&#160;</td></tr>
  102. <tr class="memitem:gad35d4e4f52ca74b503d5e5e1e0a3f5f3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#gad35d4e4f52ca74b503d5e5e1e0a3f5f3">i2c_stop</a> (void)</td></tr>
  103. <tr class="memdesc:gad35d4e4f52ca74b503d5e5e1e0a3f5f3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Terminates the data transfer and releases the I2C bus. <a href="#gad35d4e4f52ca74b503d5e5e1e0a3f5f3">More...</a><br /></td></tr>
  104. <tr class="separator:gad35d4e4f52ca74b503d5e5e1e0a3f5f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
  105. <tr class="memitem:ga58dfadce0c2fee4bfac01df6cd2b4477"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga58dfadce0c2fee4bfac01df6cd2b4477">i2c_start</a> (unsigned char addr)</td></tr>
  106. <tr class="memdesc:ga58dfadce0c2fee4bfac01df6cd2b4477"><td class="mdescLeft">&#160;</td><td class="mdescRight">Issues a start condition and sends address and transfer direction. <a href="#ga58dfadce0c2fee4bfac01df6cd2b4477">More...</a><br /></td></tr>
  107. <tr class="separator:ga58dfadce0c2fee4bfac01df6cd2b4477"><td class="memSeparator" colspan="2">&#160;</td></tr>
  108. <tr class="memitem:ga93a9461da34295250ba935bbce9a980d"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga93a9461da34295250ba935bbce9a980d">i2c_rep_start</a> (unsigned char addr)</td></tr>
  109. <tr class="memdesc:ga93a9461da34295250ba935bbce9a980d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Issues a repeated start condition and sends address and transfer direction. <a href="#ga93a9461da34295250ba935bbce9a980d">More...</a><br /></td></tr>
  110. <tr class="separator:ga93a9461da34295250ba935bbce9a980d"><td class="memSeparator" colspan="2">&#160;</td></tr>
  111. <tr class="memitem:gaee3747a01738315cd5580588994b6c28"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#gaee3747a01738315cd5580588994b6c28">i2c_start_wait</a> (unsigned char addr)</td></tr>
  112. <tr class="memdesc:gaee3747a01738315cd5580588994b6c28"><td class="mdescLeft">&#160;</td><td class="mdescRight">Issues a start condition and sends address and transfer direction. <a href="#gaee3747a01738315cd5580588994b6c28">More...</a><br /></td></tr>
  113. <tr class="separator:gaee3747a01738315cd5580588994b6c28"><td class="memSeparator" colspan="2">&#160;</td></tr>
  114. <tr class="memitem:gadd947aade44ed6b7f92265f9dec4a711"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#gadd947aade44ed6b7f92265f9dec4a711">i2c_write</a> (unsigned char data)</td></tr>
  115. <tr class="memdesc:gadd947aade44ed6b7f92265f9dec4a711"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send one byte to I2C device. <a href="#gadd947aade44ed6b7f92265f9dec4a711">More...</a><br /></td></tr>
  116. <tr class="separator:gadd947aade44ed6b7f92265f9dec4a711"><td class="memSeparator" colspan="2">&#160;</td></tr>
  117. <tr class="memitem:ga32ac22052d55f93375b024192217db21"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga32ac22052d55f93375b024192217db21">i2c_readAck</a> (void)</td></tr>
  118. <tr class="memdesc:ga32ac22052d55f93375b024192217db21"><td class="mdescLeft">&#160;</td><td class="mdescRight">read one byte from the I2C device, request more data from device <a href="#ga32ac22052d55f93375b024192217db21">More...</a><br /></td></tr>
  119. <tr class="separator:ga32ac22052d55f93375b024192217db21"><td class="memSeparator" colspan="2">&#160;</td></tr>
  120. <tr class="memitem:gad89e839fc17b05fbb5dd79897c55234e"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#gad89e839fc17b05fbb5dd79897c55234e">i2c_readNak</a> (void)</td></tr>
  121. <tr class="memdesc:gad89e839fc17b05fbb5dd79897c55234e"><td class="mdescLeft">&#160;</td><td class="mdescRight">read one byte from the I2C device, read is followed by a stop condition <a href="#gad89e839fc17b05fbb5dd79897c55234e">More...</a><br /></td></tr>
  122. <tr class="separator:gad89e839fc17b05fbb5dd79897c55234e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  123. <tr class="memitem:ga669c0357614a79b3b35ae815f6f50e82"><td class="memItemLeft" align="right" valign="top">unsigned char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__pfleury__ic2master.html#ga669c0357614a79b3b35ae815f6f50e82">i2c_read</a> (unsigned char ack)</td></tr>
  124. <tr class="memdesc:ga669c0357614a79b3b35ae815f6f50e82"><td class="mdescLeft">&#160;</td><td class="mdescRight">read one byte from the I2C device <a href="#ga669c0357614a79b3b35ae815f6f50e82">More...</a><br /></td></tr>
  125. <tr class="separator:ga669c0357614a79b3b35ae815f6f50e82"><td class="memSeparator" colspan="2">&#160;</td></tr>
  126. </table>
  127. <h2 class="groupheader">Macro Definition Documentation</h2>
  128. <a class="anchor" id="gab5c0fbe837494c5f9130a5914854250d"></a>
  129. <div class="memitem">
  130. <div class="memproto">
  131. <table class="memname">
  132. <tr>
  133. <td class="memname">#define I2C_READ&#160;&#160;&#160;1</td>
  134. </tr>
  135. </table>
  136. </div><div class="memdoc">
  137. <p>defines the data direction (reading from I2C device) in <a class="el" href="group__pfleury__ic2master.html#ga58dfadce0c2fee4bfac01df6cd2b4477" title="Issues a start condition and sends address and transfer direction. ">i2c_start()</a>,<a class="el" href="group__pfleury__ic2master.html#ga93a9461da34295250ba935bbce9a980d" title="Issues a repeated start condition and sends address and transfer direction. ">i2c_rep_start()</a> </p>
  138. </div>
  139. </div>
  140. <a class="anchor" id="ga9536bf85bced4f4e549a82fb18eb6140"></a>
  141. <div class="memitem">
  142. <div class="memproto">
  143. <table class="memname">
  144. <tr>
  145. <td class="memname">#define I2C_WRITE&#160;&#160;&#160;0</td>
  146. </tr>
  147. </table>
  148. </div><div class="memdoc">
  149. <p>defines the data direction (writing to I2C device) in <a class="el" href="group__pfleury__ic2master.html#ga58dfadce0c2fee4bfac01df6cd2b4477" title="Issues a start condition and sends address and transfer direction. ">i2c_start()</a>,<a class="el" href="group__pfleury__ic2master.html#ga93a9461da34295250ba935bbce9a980d" title="Issues a repeated start condition and sends address and transfer direction. ">i2c_rep_start()</a> </p>
  150. </div>
  151. </div>
  152. <h2 class="groupheader">Function Documentation</h2>
  153. <a class="anchor" id="ga5730d9445429351b9f750084c5cb5aae"></a>
  154. <div class="memitem">
  155. <div class="memproto">
  156. <table class="memname">
  157. <tr>
  158. <td class="memname">void i2c_init </td>
  159. <td>(</td>
  160. <td class="paramtype">void&#160;</td>
  161. <td class="paramname"></td><td>)</td>
  162. <td></td>
  163. </tr>
  164. </table>
  165. </div><div class="memdoc">
  166. <p>initialize the I2C master interace. Need to be called only once </p>
  167. <dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
  168. </div>
  169. </div>
  170. <a class="anchor" id="gad35d4e4f52ca74b503d5e5e1e0a3f5f3"></a>
  171. <div class="memitem">
  172. <div class="memproto">
  173. <table class="memname">
  174. <tr>
  175. <td class="memname">void i2c_stop </td>
  176. <td>(</td>
  177. <td class="paramtype">void&#160;</td>
  178. <td class="paramname"></td><td>)</td>
  179. <td></td>
  180. </tr>
  181. </table>
  182. </div><div class="memdoc">
  183. <p>Terminates the data transfer and releases the I2C bus. </p>
  184. <dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
  185. </div>
  186. </div>
  187. <a class="anchor" id="ga58dfadce0c2fee4bfac01df6cd2b4477"></a>
  188. <div class="memitem">
  189. <div class="memproto">
  190. <table class="memname">
  191. <tr>
  192. <td class="memname">unsigned char i2c_start </td>
  193. <td>(</td>
  194. <td class="paramtype">unsigned char&#160;</td>
  195. <td class="paramname"><em>addr</em></td><td>)</td>
  196. <td></td>
  197. </tr>
  198. </table>
  199. </div><div class="memdoc">
  200. <p>Issues a start condition and sends address and transfer direction. </p>
  201. <dl class="params"><dt>Parameters</dt><dd>
  202. <table class="params">
  203. <tr><td class="paramname">addr</td><td>address and transfer direction of I2C device </td></tr>
  204. </table>
  205. </dd>
  206. </dl>
  207. <dl class="retval"><dt>Return values</dt><dd>
  208. <table class="retval">
  209. <tr><td class="paramname">0</td><td>device accessible </td></tr>
  210. <tr><td class="paramname">1</td><td>failed to access device </td></tr>
  211. </table>
  212. </dd>
  213. </dl>
  214. </div>
  215. </div>
  216. <a class="anchor" id="ga93a9461da34295250ba935bbce9a980d"></a>
  217. <div class="memitem">
  218. <div class="memproto">
  219. <table class="memname">
  220. <tr>
  221. <td class="memname">unsigned char i2c_rep_start </td>
  222. <td>(</td>
  223. <td class="paramtype">unsigned char&#160;</td>
  224. <td class="paramname"><em>addr</em></td><td>)</td>
  225. <td></td>
  226. </tr>
  227. </table>
  228. </div><div class="memdoc">
  229. <p>Issues a repeated start condition and sends address and transfer direction. </p>
  230. <dl class="params"><dt>Parameters</dt><dd>
  231. <table class="params">
  232. <tr><td class="paramname">addr</td><td>address and transfer direction of I2C device </td></tr>
  233. </table>
  234. </dd>
  235. </dl>
  236. <dl class="retval"><dt>Return values</dt><dd>
  237. <table class="retval">
  238. <tr><td class="paramname">0</td><td>device accessible </td></tr>
  239. <tr><td class="paramname">1</td><td>failed to access device </td></tr>
  240. </table>
  241. </dd>
  242. </dl>
  243. </div>
  244. </div>
  245. <a class="anchor" id="gaee3747a01738315cd5580588994b6c28"></a>
  246. <div class="memitem">
  247. <div class="memproto">
  248. <table class="memname">
  249. <tr>
  250. <td class="memname">void i2c_start_wait </td>
  251. <td>(</td>
  252. <td class="paramtype">unsigned char&#160;</td>
  253. <td class="paramname"><em>addr</em></td><td>)</td>
  254. <td></td>
  255. </tr>
  256. </table>
  257. </div><div class="memdoc">
  258. <p>Issues a start condition and sends address and transfer direction. </p>
  259. <p>If device is busy, use ack polling to wait until device ready </p><dl class="params"><dt>Parameters</dt><dd>
  260. <table class="params">
  261. <tr><td class="paramname">addr</td><td>address and transfer direction of I2C device </td></tr>
  262. </table>
  263. </dd>
  264. </dl>
  265. <dl class="section return"><dt>Returns</dt><dd>none </dd></dl>
  266. </div>
  267. </div>
  268. <a class="anchor" id="gadd947aade44ed6b7f92265f9dec4a711"></a>
  269. <div class="memitem">
  270. <div class="memproto">
  271. <table class="memname">
  272. <tr>
  273. <td class="memname">unsigned char i2c_write </td>
  274. <td>(</td>
  275. <td class="paramtype">unsigned char&#160;</td>
  276. <td class="paramname"><em>data</em></td><td>)</td>
  277. <td></td>
  278. </tr>
  279. </table>
  280. </div><div class="memdoc">
  281. <p>Send one byte to I2C device. </p>
  282. <dl class="params"><dt>Parameters</dt><dd>
  283. <table class="params">
  284. <tr><td class="paramname">data</td><td>byte to be transfered </td></tr>
  285. </table>
  286. </dd>
  287. </dl>
  288. <dl class="retval"><dt>Return values</dt><dd>
  289. <table class="retval">
  290. <tr><td class="paramname">0</td><td>write successful </td></tr>
  291. <tr><td class="paramname">1</td><td>write failed </td></tr>
  292. </table>
  293. </dd>
  294. </dl>
  295. </div>
  296. </div>
  297. <a class="anchor" id="ga32ac22052d55f93375b024192217db21"></a>
  298. <div class="memitem">
  299. <div class="memproto">
  300. <table class="memname">
  301. <tr>
  302. <td class="memname">unsigned char i2c_readAck </td>
  303. <td>(</td>
  304. <td class="paramtype">void&#160;</td>
  305. <td class="paramname"></td><td>)</td>
  306. <td></td>
  307. </tr>
  308. </table>
  309. </div><div class="memdoc">
  310. <p>read one byte from the I2C device, request more data from device </p>
  311. <dl class="section return"><dt>Returns</dt><dd>byte read from I2C device </dd></dl>
  312. </div>
  313. </div>
  314. <a class="anchor" id="gad89e839fc17b05fbb5dd79897c55234e"></a>
  315. <div class="memitem">
  316. <div class="memproto">
  317. <table class="memname">
  318. <tr>
  319. <td class="memname">unsigned char i2c_readNak </td>
  320. <td>(</td>
  321. <td class="paramtype">void&#160;</td>
  322. <td class="paramname"></td><td>)</td>
  323. <td></td>
  324. </tr>
  325. </table>
  326. </div><div class="memdoc">
  327. <p>read one byte from the I2C device, read is followed by a stop condition </p>
  328. <dl class="section return"><dt>Returns</dt><dd>byte read from I2C device </dd></dl>
  329. </div>
  330. </div>
  331. <a class="anchor" id="ga669c0357614a79b3b35ae815f6f50e82"></a>
  332. <div class="memitem">
  333. <div class="memproto">
  334. <table class="memname">
  335. <tr>
  336. <td class="memname">unsigned char i2c_read </td>
  337. <td>(</td>
  338. <td class="paramtype">unsigned char&#160;</td>
  339. <td class="paramname"><em>ack</em></td><td>)</td>
  340. <td></td>
  341. </tr>
  342. </table>
  343. </div><div class="memdoc">
  344. <p>read one byte from the I2C device </p>
  345. <p>Implemented as a macro, which calls either <a class="el" href="group__pfleury__ic2master.html#ga32ac22052d55f93375b024192217db21">i2c_readAck</a> or <a class="el" href="group__pfleury__ic2master.html#gad89e839fc17b05fbb5dd79897c55234e">i2c_readNak</a></p>
  346. <dl class="params"><dt>Parameters</dt><dd>
  347. <table class="params">
  348. <tr><td class="paramname">ack</td><td>1 send ack, request more data from device<br />
  349. 0 send nak, read is followed by a stop condition </td></tr>
  350. </table>
  351. </dd>
  352. </dl>
  353. <dl class="section return"><dt>Returns</dt><dd>byte read from I2C device </dd></dl>
  354. </div>
  355. </div>
  356. </div><!-- contents -->
  357. <!-- start footer part -->
  358. <hr class="footer"/><address class="footer"><small>
  359. Generated on Sat Jan 31 2015 21:02:51 for AVR-GCC Libraries by &#160;<a href="http://www.doxygen.org/index.html">
  360. <img class="footer" src="doxygen.png" alt="doxygen"/>
  361. </a> 1.8.9.1
  362. </small></address>
  363. </body>
  364. </html>