sdk-ameba-v4.0b_without_nda.../doc/api_doc/group__i2c.html

932 lines
38 KiB
HTML
Raw Permalink Normal View History

2017-10-15 06:36:37 +00:00
<!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.11"/>
<title>SDK4.0: I2C</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>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</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">SDK4.0
</div>
<div id="projectbrief">This document shows Ameba SDK 4.0 APIs</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li class="current"><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<!-- 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 class="header">
<div class="summary">
<a href="#enumval-members">Enumerator</a> </div>
<div class="headertitle">
<div class="title">I2C<div class="ingroups"><a class="el" href="group__sdk.html">Ameba SDK</a> &raquo; <a class="el" href="group__hal.html">HAL</a></div></div> </div>
</div><!--header-->
<div class="contents">
<p>I2C functions.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
Ameba Common</h2></td></tr>
<tr class="memitem:ga99fb83031ce9923c84392b4e92f956b5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga99fb83031ce9923c84392b4e92f956b5"></a>enum &#160;</td><td class="memItemRight" valign="bottom">{ <b>I2C_ERROR_NO_SLAVE</b> = -1,
<b>I2C_ERROR_BUS_BUSY</b> = -2
}</td></tr>
<tr class="separator:ga99fb83031ce9923c84392b4e92f956b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab81ea18d9e45cf0f66fd70fa327567f4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gab81ea18d9e45cf0f66fd70fa327567f4"></a>
typedef struct i2c_s&#160;</td><td class="memItemRight" valign="bottom"><b>i2c_t</b></td></tr>
<tr class="separator:gab81ea18d9e45cf0f66fd70fa327567f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1b0ae695823965bbc29453fd2f4027ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga1b0ae695823965bbc29453fd2f4027ba">i2c_init</a> (i2c_t *obj, PinName sda, PinName scl)</td></tr>
<tr class="memdesc:ga1b0ae695823965bbc29453fd2f4027ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the I2C device, include clock/function/I2C registers. <a href="#ga1b0ae695823965bbc29453fd2f4027ba">More...</a><br /></td></tr>
<tr class="separator:ga1b0ae695823965bbc29453fd2f4027ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga911a872027faf4dbed3dc7900af2ae63"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga911a872027faf4dbed3dc7900af2ae63">i2c_frequency</a> (i2c_t *obj, int hz)</td></tr>
<tr class="memdesc:ga911a872027faf4dbed3dc7900af2ae63"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set i2c frequency. <a href="#ga911a872027faf4dbed3dc7900af2ae63">More...</a><br /></td></tr>
<tr class="separator:ga911a872027faf4dbed3dc7900af2ae63"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga633ef0b7903f8d8a02e39bc92e5e1cd4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga633ef0b7903f8d8a02e39bc92e5e1cd4">i2c_start</a> (i2c_t *obj)</td></tr>
<tr class="memdesc:ga633ef0b7903f8d8a02e39bc92e5e1cd4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start i2c device. <a href="#ga633ef0b7903f8d8a02e39bc92e5e1cd4">More...</a><br /></td></tr>
<tr class="separator:ga633ef0b7903f8d8a02e39bc92e5e1cd4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga884e7fb02c8c405f940f5733f2396e38"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga884e7fb02c8c405f940f5733f2396e38">i2c_stop</a> (i2c_t *obj)</td></tr>
<tr class="memdesc:ga884e7fb02c8c405f940f5733f2396e38"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stop i2c device. <a href="#ga884e7fb02c8c405f940f5733f2396e38">More...</a><br /></td></tr>
<tr class="separator:ga884e7fb02c8c405f940f5733f2396e38"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8c49d3c4d4f9bf189b91ca582a5e0360"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga8c49d3c4d4f9bf189b91ca582a5e0360">i2c_reset</a> (i2c_t *obj)</td></tr>
<tr class="memdesc:ga8c49d3c4d4f9bf189b91ca582a5e0360"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deinitializes the I2C device. <a href="#ga8c49d3c4d4f9bf189b91ca582a5e0360">More...</a><br /></td></tr>
<tr class="separator:ga8c49d3c4d4f9bf189b91ca582a5e0360"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab785445664c6d96cd87b3b4b9b3ec190"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gab785445664c6d96cd87b3b4b9b3ec190">i2c_byte_read</a> (i2c_t *obj, int last)</td></tr>
<tr class="memdesc:gab785445664c6d96cd87b3b4b9b3ec190"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C master receive single byte. <a href="#gab785445664c6d96cd87b3b4b9b3ec190">More...</a><br /></td></tr>
<tr class="separator:gab785445664c6d96cd87b3b4b9b3ec190"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga55292c588c9f79d92198139d46d3111e"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga55292c588c9f79d92198139d46d3111e">i2c_byte_write</a> (i2c_t *obj, int data)</td></tr>
<tr class="memdesc:ga55292c588c9f79d92198139d46d3111e"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C master send single byte. <a href="#ga55292c588c9f79d92198139d46d3111e">More...</a><br /></td></tr>
<tr class="separator:ga55292c588c9f79d92198139d46d3111e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac1e9a41eb4c76bcc62c1d236b61f3898"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gac1e9a41eb4c76bcc62c1d236b61f3898">i2c_slave_mode</a> (i2c_t *obj, int enable_slave)</td></tr>
<tr class="memdesc:gac1e9a41eb4c76bcc62c1d236b61f3898"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set i2c device to be slave. <a href="#gac1e9a41eb4c76bcc62c1d236b61f3898">More...</a><br /></td></tr>
<tr class="separator:gac1e9a41eb4c76bcc62c1d236b61f3898"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4cb20c34467f6bc7f972e1bf6995c8d9"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga4cb20c34467f6bc7f972e1bf6995c8d9">i2c_slave_receive</a> (i2c_t *obj)</td></tr>
<tr class="memdesc:ga4cb20c34467f6bc7f972e1bf6995c8d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get i2c slave state. <a href="#ga4cb20c34467f6bc7f972e1bf6995c8d9">More...</a><br /></td></tr>
<tr class="separator:ga4cb20c34467f6bc7f972e1bf6995c8d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0542eb3761a36e3682c6a09a15756105"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga0542eb3761a36e3682c6a09a15756105">i2c_slave_address</a> (i2c_t *obj, int idx, uint32_t address, uint32_t mask)</td></tr>
<tr class="memdesc:ga0542eb3761a36e3682c6a09a15756105"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set i2c slave address. <a href="#ga0542eb3761a36e3682c6a09a15756105">More...</a><br /></td></tr>
<tr class="separator:ga0542eb3761a36e3682c6a09a15756105"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga67f564fd103e3f2d56f6506239834ffe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga67f564fd103e3f2d56f6506239834ffe">i2c_read</a> (i2c_t *obj, int address, char *data, int length, int stop)</td></tr>
<tr class="memdesc:ga67f564fd103e3f2d56f6506239834ffe"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C master read in poll mode. <a href="#ga67f564fd103e3f2d56f6506239834ffe">More...</a><br /></td></tr>
<tr class="separator:ga67f564fd103e3f2d56f6506239834ffe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga62c619e5640f444c914839699a3cd0a4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga62c619e5640f444c914839699a3cd0a4">i2c_write</a> (i2c_t *obj, int address, const char *data, int length, int stop)</td></tr>
<tr class="memdesc:ga62c619e5640f444c914839699a3cd0a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C master write in poll mode. <a href="#ga62c619e5640f444c914839699a3cd0a4">More...</a><br /></td></tr>
<tr class="separator:ga62c619e5640f444c914839699a3cd0a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5b56b4f4a3fbe0e1e64cd482db1de7a4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga5b56b4f4a3fbe0e1e64cd482db1de7a4">i2c_slave_read</a> (i2c_t *obj, char *data, int length)</td></tr>
<tr class="memdesc:ga5b56b4f4a3fbe0e1e64cd482db1de7a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C slave read in poll mode. <a href="#ga5b56b4f4a3fbe0e1e64cd482db1de7a4">More...</a><br /></td></tr>
<tr class="separator:ga5b56b4f4a3fbe0e1e64cd482db1de7a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4fe28a2b1e9c69eb67c085e5e6005d3d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga4fe28a2b1e9c69eb67c085e5e6005d3d">i2c_slave_write</a> (i2c_t *obj, const char *data, int length)</td></tr>
<tr class="memdesc:ga4fe28a2b1e9c69eb67c085e5e6005d3d"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C slave write in poll mode. <a href="#ga4fe28a2b1e9c69eb67c085e5e6005d3d">More...</a><br /></td></tr>
<tr class="separator:ga4fe28a2b1e9c69eb67c085e5e6005d3d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8f9894fec30c83809dd02929c9feff76"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga8f9894fec30c83809dd02929c9feff76">i2c_slave_set_for_rd_req</a> (i2c_t *obj, int set)</td></tr>
<tr class="memdesc:ga8f9894fec30c83809dd02929c9feff76"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set/clear i2c slave RD_REQ interrupt mask. <a href="#ga8f9894fec30c83809dd02929c9feff76">More...</a><br /></td></tr>
<tr class="separator:ga8f9894fec30c83809dd02929c9feff76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab6f24da9a64df1851fa747111365722a"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#gab6f24da9a64df1851fa747111365722a">i2c_slave_set_for_data_nak</a> (i2c_t *obj, int set_nak)</td></tr>
<tr class="memdesc:gab6f24da9a64df1851fa747111365722a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set/clear i2c slave NAK or ACK data part in transfer. <a href="#gab6f24da9a64df1851fa747111365722a">More...</a><br /></td></tr>
<tr class="separator:gab6f24da9a64df1851fa747111365722a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="member-group"></a>
AmebaZ Only</h2></td></tr>
<tr class="memitem:ga8b9d3f27dde8fd4a7c2699a442036469"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__i2c.html#ga8b9d3f27dde8fd4a7c2699a442036469">i2c_repeatread</a> (i2c_t *obj, int address, u8 *pWriteBuf, int Writelen, u8 *pReadBuf, int Readlen)</td></tr>
<tr class="memdesc:ga8b9d3f27dde8fd4a7c2699a442036469"><td class="mdescLeft">&#160;</td><td class="mdescRight">I2C master send data and read data in poll mode. <a href="#ga8b9d3f27dde8fd4a7c2699a442036469">More...</a><br /></td></tr>
<tr class="separator:ga8b9d3f27dde8fd4a7c2699a442036469"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>I2C functions. </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="gab785445664c6d96cd87b3b4b9b3ec190"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_byte_read </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>last</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C master receive single byte. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">last</td><td>hold the received data. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>the received data. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga55292c588c9f79d92198139d46d3111e"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_byte_write </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>data</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C master send single byte. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">data</td><td>the data to be sent. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>result. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga911a872027faf4dbed3dc7900af2ae63"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void i2c_frequency </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>hz</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set i2c frequency. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">hz</td><td>i2c clock(unit is Hz). </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga1b0ae695823965bbc29453fd2f4027ba"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void i2c_init </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PinName&#160;</td>
<td class="paramname"><em>sda</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PinName&#160;</td>
<td class="paramname"><em>scl</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes the I2C device, include clock/function/I2C registers. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">sda</td><td>SDA PinName according to pinmux spec. </td></tr>
<tr><td class="paramname">scl</td><td>SCL PinName according to pinmux spec. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga67f564fd103e3f2d56f6506239834ffe"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_read </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>length</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>stop</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C master read in poll mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">address</td><td>slave address which will be transmitted. </td></tr>
<tr><td class="paramname">data</td><td>point to the buffer to hold the received data. </td></tr>
<tr><td class="paramname">length</td><td>the length of data that to be received. </td></tr>
<tr><td class="paramname">stop</td><td>specifies whether a STOP is issued after all the bytes are received. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>the length of data received. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga8b9d3f27dde8fd4a7c2699a442036469"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_repeatread </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u8 *&#160;</td>
<td class="paramname"><em>pWriteBuf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>Writelen</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">u8 *&#160;</td>
<td class="paramname"><em>pReadBuf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>Readlen</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C master send data and read data in poll mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">address</td><td>slave address which will be transmitted. </td></tr>
<tr><td class="paramname">pWriteBuf</td><td>point to the data to be sent. </td></tr>
<tr><td class="paramname">Writelen</td><td>the length of data that to be sent. </td></tr>
<tr><td class="paramname">pReadBuf</td><td>point to the buffer to hold the received data. </td></tr>
<tr><td class="paramname">Readlen</td><td>the length of data that to be received. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">the</td><td>length of data received. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga8c49d3c4d4f9bf189b91ca582a5e0360"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void i2c_reset </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Deinitializes the I2C device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga0542eb3761a36e3682c6a09a15756105"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void i2c_slave_address </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>idx</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>mask</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set i2c slave address. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">idx</td><td>i2c index, this parameter can be one of the following values: <ul>
<li>0 I2C0 Device </li>
<li>1 I2C1 Device </li>
</ul>
</td></tr>
<tr><td class="paramname">address</td><td>slave address. </td></tr>
<tr><td class="paramname">mask</td><td>the mask of address </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gac1e9a41eb4c76bcc62c1d236b61f3898"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void i2c_slave_mode </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>enable_slave</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set i2c device to be slave. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">enable_slave</td><td>enable slave function, this parameter can be one of the following values: <ul>
<li>0 disable </li>
<li>1 enable </li>
</ul>
</td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">none</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga5b56b4f4a3fbe0e1e64cd482db1de7a4"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_slave_read </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C slave read in poll mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">data</td><td>point to the buffer to hold the received data. </td></tr>
<tr><td class="paramname">length</td><td>the length of data that to be received. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>the length of data received. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga4cb20c34467f6bc7f972e1bf6995c8d9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_slave_receive </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get i2c slave state. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>the state of i2c slave. </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="gab6f24da9a64df1851fa747111365722a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_slave_set_for_data_nak </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>set_nak</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set/clear i2c slave NAK or ACK data part in transfer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">set_nak</td><td>set or clear for data NAK. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">1</td><td>SUCCESS </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga8f9894fec30c83809dd02929c9feff76"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_slave_set_for_rd_req </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>set</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Set/clear i2c slave RD_REQ interrupt mask. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">set</td><td>set or clear for read request. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">1</td><td>SUCCESS </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga4fe28a2b1e9c69eb67c085e5e6005d3d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_slave_write </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C slave write in poll mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">data</td><td>point to the data to be sent. </td></tr>
<tr><td class="paramname">length</td><td>the length of data that to be sent. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">0</td><td>FAIL </td></tr>
<tr><td class="paramname">1</td><td>SUCCESS </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga633ef0b7903f8d8a02e39bc92e5e1cd4"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_start </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Start i2c device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">0</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga884e7fb02c8c405f940f5733f2396e38"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_stop </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Stop i2c device. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">0</td><td></td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a class="anchor" id="ga62c619e5640f444c914839699a3cd0a4"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int i2c_write </td>
<td>(</td>
<td class="paramtype">i2c_t *&#160;</td>
<td class="paramname"><em>obj</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>address</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>length</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>stop</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>I2C master write in poll mode. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">obj</td><td>i2c object define in application software. </td></tr>
<tr><td class="paramname">address</td><td>slave address which will be transmitted. </td></tr>
<tr><td class="paramname">data</td><td>point to the data to be sent. </td></tr>
<tr><td class="paramname">length</td><td>the length of data that to be sent. </td></tr>
<tr><td class="paramname">stop</td><td>specifies whether a STOP is issued after all the bytes are sent. </td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname"></td><td>the length of data send. </td></tr>
</table>
</dd>
</dl>
</div>
</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.11
</small></address>
</body>
</html>