-
Notifications
You must be signed in to change notification settings - Fork 0
/
_i2_c_8cpp_source.html
136 lines (134 loc) · 50.4 KB
/
_i2_c_8cpp_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>myWRIO: C:/Users/jackb/OneDrive - etu.univ-lyon1.fr/TERi/Eclipse/workspace/APIForRIO/src/I2C.cpp Source File</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</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">myWRIO
</div>
<div id="projectbrief">C++ framework for NationalInstruments myRIO</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_i2_c_8cpp_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- 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="headertitle">
<div class="title">I2C.cpp</div> </div>
</div><!--header-->
<div class="contents">
<a href="_i2_c_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#include "<a class="code" href="_i2_c_8h.html">I2C.h</a>"</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> </div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="keyword">using namespace </span><a class="code" href="namespacemy_r_i_o.html">myRIO</a>;</div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="keyword">extern</span> NiFpga_Session <a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>; <span class="comment">// global variable defined in CAPI/MyRio.c</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="keywordtype">int</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#ac743f00dad30c25bbec38724390b4b0c">I2C::nbInstance</a> = 0;</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> </div><div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a7a9a84fccdacb3346ff97d6f3e158850"> 10</a></span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a7a9a84fccdacb3346ff97d6f3e158850">I2C::I2C</a>() : slaveAddr(0) {</div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>  <a class="code" href="classmy_r_i_o_1_1_i2_c.html#ac743f00dad30c25bbec38724390b4b0c">nbInstance</a>++;</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> </div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>  <span class="comment">// enable I2C in SYS.SELECT</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span>  uint8_t select;</div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>  <a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a> = NiFpga_ReadU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, SYSSELECTA, &select);</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>  select |= (1<<7);</div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, SYSSELECTA, select));</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  <span class="comment">// enable I2C in I2C.CNFG</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNFG, 1));</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>  <span class="comment">// setup default clock speed</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  <span class="comment">// 40e6/xe3 : 40e3/x (speed is in KBPS, not in BPS)</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>  <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a8fc07132464800950fec5db8d80d60e3">cntr</a> = (uint8_t)(((<span class="keywordtype">double</span>)40e3/<a class="code" href="namespacemy_r_i_o.html#a2b619f28b73958e88a4e880f6b06b98baf8035e01f05c5456b48ac2bbc6267b21">SPD_400KBPS</a>)+26.0)/2.0;</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> }</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#af38bb693bc9c445ca675faeb9bacd6ee"> 30</a></span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html">I2C</a>* <a class="code" href="classmy_r_i_o_1_1_i2_c.html#af38bb693bc9c445ca675faeb9bacd6ee">I2C::open</a>() {</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="keywordflow">if</span>(<a class="code" href="classmy_r_i_o_1_1_i2_c.html#ac743f00dad30c25bbec38724390b4b0c">nbInstance</a>==0)</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a7a9a84fccdacb3346ff97d6f3e158850">I2C</a>();</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> }</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a46c2a82b1a8146fc6b4a688a82a0970d"> 41</a></span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html">I2C</a>* <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a46c2a82b1a8146fc6b4a688a82a0970d">I2C::slave</a>(uint8_t addr) {</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a0bba74f1bfa8195e11ca1e26255f531b">slaveAddr</a> = addr;</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="keywordflow">return</span> <span class="keyword">this</span>;</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> }</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> </div><div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a17cbf8d61e1ecaf6dc21a2aa0def1f27"> 51</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a17cbf8d61e1ecaf6dc21a2aa0def1f27">I2C::write</a>(uint8_t reg, uint8_t data) {</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="keywordflow">return</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#ab7aa6e32b813f4291619d3693cac7132">writeFrom</a>(reg, <span class="keyword">new</span> uint8_t(data), 1);</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> }</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span> </div><div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#ab7aa6e32b813f4291619d3693cac7132"> 61</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#ab7aa6e32b813f4291619d3693cac7132">I2C::writeFrom</a>(uint8_t reg, uint8_t*data, uint8_t dataSize) {</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <span class="keywordflow">return</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a3d8367c29c94b70ab2b5743a211599f8">start</a>(<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a1579b1a2f39010510467b7183f5b7748">I2C_WRITE</a>, reg, data, dataSize);</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span> }</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> </div><div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a0885faa777f4c62e70979c84d5133090"> 70</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a0885faa777f4c62e70979c84d5133090">I2C::read</a>(uint8_t reg, uint8_t*data) {</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="keywordflow">return</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a3067e3c1553f3b0a8d17c5ab9807d5db">readFrom</a>(reg, data, 1);</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> }</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> </div><div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a3067e3c1553f3b0a8d17c5ab9807d5db"> 80</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a3067e3c1553f3b0a8d17c5ab9807d5db">I2C::readFrom</a>(uint8_t reg, uint8_t*data, uint8_t dataSize) {</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <span class="keywordflow">if</span>(dataSize>1)</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  reg|=0x80; <span class="comment">// enable multi byte read</span></div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keywordflow">return</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a3d8367c29c94b70ab2b5743a211599f8">start</a>(<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">I2C_READ</a>, reg, data, dataSize);</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span> }</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span> </div><div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a57755eab4de5779268181852311750a2"> 90</a></span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html">I2C</a> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a57755eab4de5779268181852311750a2">I2C::speed</a>(<span class="keywordtype">int</span> spd) {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a8fc07132464800950fec5db8d80d60e3">cntr</a> = (uint8_t)(((<span class="keywordtype">double</span>)40e3/spd)+26.0)/2.0;</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keywordflow">return</span> *<span class="keyword">this</span>;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span> }</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span> </div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a3d8367c29c94b70ab2b5743a211599f8"> 102</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a3d8367c29c94b70ab2b5743a211599f8">I2C::start</a>(<span class="keywordtype">bool</span> RW, uint8_t reg, uint8_t*data, uint8_t dataSize) {</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> <span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  std::cout << <span class="stringliteral">"START "</span> << ((RW==<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">I2C_READ</a>)?<span class="stringliteral">"READ"</span>:<span class="stringliteral">"WRITE"</span>) << std::endl;</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  uint8_t state;</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keyword">union </span><a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html">I2C_CNTL</a> cntl = {0};</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span> </div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="comment">// setup I2C bus clock</span></div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a> = NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNTR, <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a8fc07132464800950fec5db8d80d60e3">cntr</a>);</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="comment">/*</span></div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span> <span class="comment"> * Generate start</span></div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span> <span class="comment"> * Send address + RW</span></div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span> <span class="comment"> * Receive address ACK</span></div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="comment"> * Send data (register addr)</span></div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span> <span class="comment"> * Receive data ACK</span></div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span> <span class="comment"> * Go to TX/RX IDLE state</span></div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span> <span class="comment"> */</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#adca03f901a3067c8e4a1573be3fea8aa">tx</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#ab721b45eb7ceae44692e5cee08491a9c">start</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> </div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="comment">// choose the slave address and set W</span></div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CAADDR, <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a0bba74f1bfa8195e11ca1e26255f531b">slaveAddr</a>));</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span> </div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="comment">// write procedure to myRIO</span></div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNTL, cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">data</a>));</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> <span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  std::cout << <span class="stringliteral">"CNTL : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">data</a>) << <span class="stringliteral">" - Slave : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(<a class="code" href="classmy_r_i_o_1_1_i2_c.html#a0bba74f1bfa8195e11ca1e26255f531b">slaveAddr</a>) << <span class="stringliteral">" - Reg : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(reg) << std::endl;</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="comment">// choose the device register to operate</span></div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CADATO, reg));</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span> </div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="comment">// start the first procedure</span></div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  NiFpga_WriteBool(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CAGO, NiFpga_True));</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span> </div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="comment">// wait for the end of the communication</span></div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  state = <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a677b038aa4bb75d92a8c24087e8c3743">wait</a>();</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  </div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="comment">// if there was an error, stop</span></div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="keywordflow">if</span>(!<a class="code" href="classmy_r_i_o_1_1_i2_c.html#a10f0d27f69fb7421bf1772341802ded6">checkErrors</a>(state)) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  </div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="comment">// choose the slave address and set R/W</span></div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CAADDR, <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a0bba74f1bfa8195e11ca1e26255f531b">slaveAddr</a>|RW));</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span> </div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<dataSize; i++) {</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  <span class="comment">/*</span></div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span> <span class="comment"> * if(i==0&&reading) Generate REPEATED START</span></div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span> <span class="comment"> * if(i==0) Send address + read/write</span></div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span> <span class="comment"> * if(i==0) Receive address ACK</span></div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span> <span class="comment"> * Receive/send data</span></div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span> <span class="comment"> * Receive data ACK/send data ACK/(if i==size-1)NACK</span></div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="comment"> * if(i==size-1) Generate STOP</span></div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span> <span class="comment"> * Go to if(i!=size-1)TX|RX IDLE/(else)IDLE state</span></div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span> <span class="comment"> */</span></div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  cntl = {0};</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#adca03f901a3067c8e4a1573be3fea8aa">tx</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  <span class="keywordflow">if</span>(i==0 && RW==<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">I2C_READ</a>) cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#ab721b45eb7ceae44692e5cee08491a9c">start</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  <span class="keywordflow">if</span>(i==dataSize-1)</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#aeaf980c2488cc3ba590d202065421e46">stop</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span>(RW==<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">I2C_READ</a>)</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a5838102ead54753b5a49dba007672f9e">ack</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span> <span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  std::cout << <span class="stringliteral">"CNTL : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">data</a>) << <span class="stringliteral">" - "</span>;</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="comment">// write the procedure</span></div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNTL, cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">data</a>));</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span> </div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <span class="comment">// if we are writing, setup the "DATA OUT" register</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="keywordflow">if</span>(RW==<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a1579b1a2f39010510467b7183f5b7748">I2C_WRITE</a>) {</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CADATO, *(data+i)));</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span> <span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  std::cout << <span class="stringliteral">"Wrote : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(*(data+i)) << std::endl;</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  }</div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span> </div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  <span class="comment">// start the procedure</span></div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  NiFpga_WriteBool(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CAGO, NiFpga_True));</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span> </div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  <span class="comment">// wait for the end of the communication</span></div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  state = <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a677b038aa4bb75d92a8c24087e8c3743">wait</a>();</div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  </div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  <span class="comment">// if there was an error, stop</span></div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  <span class="keywordflow">if</span>(!<a class="code" href="classmy_r_i_o_1_1_i2_c.html#a10f0d27f69fb7421bf1772341802ded6">checkErrors</a>(state)) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span> </div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span>  <span class="comment">// if we are reading, read the "DATA IN" register</span></div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span>  <span class="keywordflow">if</span>(RW==<a class="code" href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">I2C_READ</a>) {</div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  NiFpga_ReadU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CADATI, data+i));</div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span> <span class="preprocessor">#ifdef DEBUG</span></div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  std::cout << <span class="stringliteral">"Received : "</span> << <a class="code" href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">printBits</a>(*(data+i)) << std::endl;</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  }</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  }</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span> }</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span> </div><div class="line"><a name="l00210"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a677b038aa4bb75d92a8c24087e8c3743"> 210</a></span> uint8_t <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a677b038aa4bb75d92a8c24087e8c3743">I2C::wait</a>() {</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  uint8_t state;</div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>  NiFpga_ReadU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CASTAT, &state));</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  } <span class="keywordflow">while</span>(state&1); <span class="comment">// BSY flag</span></div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  <span class="keywordflow">return</span> state;</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span> }</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span> </div><div class="line"><a name="l00224"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a10f0d27f69fb7421bf1772341802ded6"> 224</a></span> <span class="keywordtype">bool</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a10f0d27f69fb7421bf1772341802ded6">I2C::checkErrors</a>(uint8_t state) {</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  <span class="keywordflow">if</span>(state&0x02) {</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>  <span class="keyword">union </span><a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html">I2C_CNTL</a> cntl = {0};</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#aeaf980c2488cc3ba590d202065421e46">stop</a> = <span class="keyword">true</span>;</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  NiFpga_MergeStatus(&<a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a>,</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNTL, cntl.<a class="code" href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">data</a>));</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  }</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span> }</div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span> </div><div class="line"><a name="l00238"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#a8c039ad2880f4a27b07374ca60f41eff"> 238</a></span> <span class="keywordtype">void</span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#a8c039ad2880f4a27b07374ca60f41eff">I2C::close</a>() {</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  <span class="keyword">delete</span> <span class="keyword">this</span>;</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span> }</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span> </div><div class="line"><a name="l00245"></a><span class="lineno"><a class="line" href="classmy_r_i_o_1_1_i2_c.html#afaad09fa9bdd23623bddbdcd7585a9fe"> 245</a></span> <a class="code" href="classmy_r_i_o_1_1_i2_c.html#afaad09fa9bdd23623bddbdcd7585a9fe">I2C::~I2C</a>() {</div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span>  <a class="code" href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">status</a> = NiFpga_WriteU8(<a class="code" href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a>, I2CACNFG, 0);</div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  <a class="code" href="classmy_r_i_o_1_1_i2_c.html#ac743f00dad30c25bbec38724390b4b0c">nbInstance</a>--;</div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span> }</div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span> </div><div class="ttc" id="namespacemy_r_i_o_html_a2b619f28b73958e88a4e880f6b06b98baf8035e01f05c5456b48ac2bbc6267b21"><div class="ttname"><a href="namespacemy_r_i_o.html#a2b619f28b73958e88a4e880f6b06b98baf8035e01f05c5456b48ac2bbc6267b21">myRIO::SPD_400KBPS</a></div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00027">I2C.h:27</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a46c2a82b1a8146fc6b4a688a82a0970d"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a46c2a82b1a8146fc6b4a688a82a0970d">myRIO::I2C::slave</a></div><div class="ttdeci">I2C * slave(uint8_t addr)</div><div class="ttdoc">Set the slave address to talk to.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00041">I2C.cpp:41</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a10f0d27f69fb7421bf1772341802ded6"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a10f0d27f69fb7421bf1772341802ded6">myRIO::I2C::checkErrors</a></div><div class="ttdeci">bool checkErrors(uint8_t state)</div><div class="ttdoc">Check for errors during the previous communication.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00224">I2C.cpp:224</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a57755eab4de5779268181852311750a2"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a57755eab4de5779268181852311750a2">myRIO::I2C::speed</a></div><div class="ttdeci">I2C speed(int SPD_XXKBPS)</div><div class="ttdoc">Set the I2C bus speed.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00090">I2C.cpp:90</a></div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html_adca03f901a3067c8e4a1573be3fea8aa"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#adca03f901a3067c8e4a1573be3fea8aa">myRIO::I2C_CNTL::tx</a></div><div class="ttdeci">bool tx</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00015">I2C.h:15</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a3067e3c1553f3b0a8d17c5ab9807d5db"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a3067e3c1553f3b0a8d17c5ab9807d5db">myRIO::I2C::readFrom</a></div><div class="ttdeci">bool readFrom(uint8_t reg, uint8_t *data, uint8_t dataSize)</div><div class="ttdoc">Read multiple registers, starting to reg.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00080">I2C.cpp:80</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_afaad09fa9bdd23623bddbdcd7585a9fe"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#afaad09fa9bdd23623bddbdcd7585a9fe">myRIO::I2C::~I2C</a></div><div class="ttdeci">~I2C()</div><div class="ttdoc">Close the I2C channel.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00245">I2C.cpp:245</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a677b038aa4bb75d92a8c24087e8c3743"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a677b038aa4bb75d92a8c24087e8c3743">myRIO::I2C::wait</a></div><div class="ttdeci">uint8_t wait()</div><div class="ttdoc">Wait for myRIO to end a frame.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00210">I2C.cpp:210</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a7a9a84fccdacb3346ff97d6f3e158850"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a7a9a84fccdacb3346ff97d6f3e158850">myRIO::I2C::I2C</a></div><div class="ttdeci">I2C()</div><div class="ttdoc">Enable the I2C channel A on myRIO.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00010">I2C.cpp:10</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_ac743f00dad30c25bbec38724390b4b0c"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#ac743f00dad30c25bbec38724390b4b0c">myRIO::I2C::nbInstance</a></div><div class="ttdeci">static int nbInstance</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00055">I2C.h:55</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html">myRIO::I2C</a></div><div class="ttdoc">In this configuration, myRIO will always be the master.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00041">I2C.h:41</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a0bba74f1bfa8195e11ca1e26255f531b"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a0bba74f1bfa8195e11ca1e26255f531b">myRIO::I2C::slaveAddr</a></div><div class="ttdeci">uint8_t slaveAddr</div><div class="ttdoc">Slave address.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00061">I2C.h:61</a></div></div>
<div class="ttc" id="namespacemy_r_i_o_html_a4a95a51adb92d1bfede6144d499c1cff"><div class="ttname"><a href="namespacemy_r_i_o.html#a4a95a51adb92d1bfede6144d499c1cff">myRIO::status</a></div><div class="ttdeci">static NiFpga_Status status</div><div class="ttdoc">This global variable allow the user to keep track of errors if not 0.</div><div class="ttdef"><b>Definition:</b> <a href="_my_r_i_o_8h_source.html#l00030">MyRIO.h:30</a></div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html_ab721b45eb7ceae44692e5cee08491a9c"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#ab721b45eb7ceae44692e5cee08491a9c">myRIO::I2C_CNTL::start</a></div><div class="ttdeci">bool start</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00016">I2C.h:16</a></div></div>
<div class="ttc" id="namespacemy_r_i_o_html_a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402"><div class="ttname"><a href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a973c1b9fd75c1517c4747a4b4896f402">myRIO::I2C_READ</a></div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00035">I2C.h:35</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a3d8367c29c94b70ab2b5743a211599f8"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a3d8367c29c94b70ab2b5743a211599f8">myRIO::I2C::start</a></div><div class="ttdeci">bool start(bool RW, uint8_t reg, uint8_t *data, uint8_t dataSize)</div><div class="ttdoc">Begin the procedure.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00102">I2C.cpp:102</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_af38bb693bc9c445ca675faeb9bacd6ee"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#af38bb693bc9c445ca675faeb9bacd6ee">myRIO::I2C::open</a></div><div class="ttdeci">static I2C * open()</div><div class="ttdoc">You can use this to open multiple I2C channels, for exemple use I2CB.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00030">I2C.cpp:30</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a8fc07132464800950fec5db8d80d60e3"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a8fc07132464800950fec5db8d80d60e3">myRIO::I2C::cntr</a></div><div class="ttdeci">uint8_t cntr</div><div class="ttdoc">Contains informations relative to the procedure to come.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00062">I2C.h:62</a></div></div>
<div class="ttc" id="namespacemy_r_i_o_html_a86c89b50665c5b9e40e94a1e63bbae38a1579b1a2f39010510467b7183f5b7748"><div class="ttname"><a href="namespacemy_r_i_o.html#a86c89b50665c5b9e40e94a1e63bbae38a1579b1a2f39010510467b7183f5b7748">myRIO::I2C_WRITE</a></div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00034">I2C.h:34</a></div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html_a590e8a16f27531253fc48bd52aa363d1"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a590e8a16f27531253fc48bd52aa363d1">myRIO::I2C_CNTL::data</a></div><div class="ttdeci">uint8_t data</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00013">I2C.h:13</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_ab7aa6e32b813f4291619d3693cac7132"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#ab7aa6e32b813f4291619d3693cac7132">myRIO::I2C::writeFrom</a></div><div class="ttdeci">bool writeFrom(uint8_t reg, uint8_t *data, uint8_t dataSize)</div><div class="ttdoc">Write any size of data starting from reg address.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00061">I2C.cpp:61</a></div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html_a5838102ead54753b5a49dba007672f9e"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#a5838102ead54753b5a49dba007672f9e">myRIO::I2C_CNTL::ack</a></div><div class="ttdeci">bool ack</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00018">I2C.h:18</a></div></div>
<div class="ttc" id="_i2_c_8cpp_html_a185bfa2d35885a0f891c399e2b5399db"><div class="ttname"><a href="_i2_c_8cpp.html#a185bfa2d35885a0f891c399e2b5399db">myrio_session</a></div><div class="ttdeci">NiFpga_Session myrio_session</div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html">myRIO::I2C_CNTL</a></div><div class="ttdoc">I2C_CNTL contains informations about the procedure to come.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00012">I2C.h:12</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a17cbf8d61e1ecaf6dc21a2aa0def1f27"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a17cbf8d61e1ecaf6dc21a2aa0def1f27">myRIO::I2C::write</a></div><div class="ttdeci">bool write(uint8_t reg, uint8_t data)</div><div class="ttdoc">Write 8 bits data to the given registry on a previously set slave.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00051">I2C.cpp:51</a></div></div>
<div class="ttc" id="namespacemy_r_i_o_html"><div class="ttname"><a href="namespacemy_r_i_o.html">myRIO</a></div><div class="ttdef"><b>Definition:</b> <a href="_acc_8h_source.html#l00008">Acc.h:8</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a8c039ad2880f4a27b07374ca60f41eff"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a8c039ad2880f4a27b07374ca60f41eff">myRIO::I2C::close</a></div><div class="ttdeci">void close()</div><div class="ttdoc">Delete (somehow violently) an I2C object.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00238">I2C.cpp:238</a></div></div>
<div class="ttc" id="_i2_c_8h_html"><div class="ttname"><a href="_i2_c_8h.html">I2C.h</a></div></div>
<div class="ttc" id="namespacemy_r_i_o_html_a43b663ef1e679ce81af8d6b3e04510e3"><div class="ttname"><a href="namespacemy_r_i_o.html#a43b663ef1e679ce81af8d6b3e04510e3">myRIO::printBits</a></div><div class="ttdeci">static std::string printBits(uint8_t byte)</div><div class="ttdoc">This function can be used to print each bit of an unsigned char.</div><div class="ttdef"><b>Definition:</b> <a href="_my_r_i_o_8h_source.html#l00038">MyRIO.h:38</a></div></div>
<div class="ttc" id="classmy_r_i_o_1_1_i2_c_html_a0885faa777f4c62e70979c84d5133090"><div class="ttname"><a href="classmy_r_i_o_1_1_i2_c.html#a0885faa777f4c62e70979c84d5133090">myRIO::I2C::read</a></div><div class="ttdeci">bool read(uint8_t reg, uint8_t *data)</div><div class="ttdoc">Read a register and get that data back to data.</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8cpp_source.html#l00070">I2C.cpp:70</a></div></div>
<div class="ttc" id="unionmy_r_i_o_1_1_i2_c___c_n_t_l_html_aeaf980c2488cc3ba590d202065421e46"><div class="ttname"><a href="unionmy_r_i_o_1_1_i2_c___c_n_t_l.html#aeaf980c2488cc3ba590d202065421e46">myRIO::I2C_CNTL::stop</a></div><div class="ttdeci">bool stop</div><div class="ttdef"><b>Definition:</b> <a href="_i2_c_8h_source.html#l00017">I2C.h:17</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_98fb12f9c07806436144af22cad486e4.html">Eclipse</a></li><li class="navelem"><a class="el" href="dir_e17da8bc7b823c1f82c904fefd57a078.html">workspace</a></li><li class="navelem"><a class="el" href="dir_814e4b17f8683e03c2431c0e57f58eb6.html">APIForRIO</a></li><li class="navelem"><a class="el" href="dir_c047dd42b8eba02cf6377cb404ab9432.html">src</a></li><li class="navelem"><a class="el" href="_i2_c_8cpp.html">I2C.cpp</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
</ul>
</div>
</body>
</html>