Micro template library A library for building device drivers
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

137 linhas
60 KiB

  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.14"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>uTL: include/utl/com/i2c_bb.h Source File</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="resize.js"></script>
  14. <script type="text/javascript" src="navtreedata.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  18. $(document).ready(initResizable);
  19. /* @license-end */</script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/searchdata.js"></script>
  22. <script type="text/javascript" src="search/search.js"></script>
  23. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  24. </head>
  25. <body>
  26. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  27. <div id="titlearea">
  28. <table cellspacing="0" cellpadding="0">
  29. <tbody>
  30. <tr style="height: 56px;">
  31. <td id="projectalign" style="padding-left: 0.5em;">
  32. <div id="projectname">uTL
  33. </div>
  34. <div id="projectbrief">micro Template library</div>
  35. </td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </div>
  40. <!-- end header part -->
  41. <!-- Generated by Doxygen 1.8.14 -->
  42. <script type="text/javascript">
  43. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  44. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  45. /* @license-end */
  46. </script>
  47. <script type="text/javascript" src="menudata.js"></script>
  48. <script type="text/javascript" src="menu.js"></script>
  49. <script type="text/javascript">
  50. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  51. $(function() {
  52. initMenu('',true,false,'search.php','Search');
  53. $(document).ready(function() { init_search(); });
  54. });
  55. /* @license-end */</script>
  56. <div id="main-nav"></div>
  57. </div><!-- top -->
  58. <div id="side-nav" class="ui-resizable side-nav-resizable">
  59. <div id="nav-tree">
  60. <div id="nav-tree-contents">
  61. <div id="nav-sync" class="sync"></div>
  62. </div>
  63. </div>
  64. <div id="splitbar" style="-moz-user-select:none;"
  65. class="ui-resizable-handle">
  66. </div>
  67. </div>
  68. <script type="text/javascript">
  69. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  70. $(document).ready(function(){initNavTree('i2c__bb_8h_source.html','');});
  71. /* @license-end */
  72. </script>
  73. <div id="doc-content">
  74. <!-- window showing the filter options -->
  75. <div id="MSearchSelectWindow"
  76. onmouseover="return searchBox.OnSearchSelectShow()"
  77. onmouseout="return searchBox.OnSearchSelectHide()"
  78. onkeydown="return searchBox.OnSearchSelectKey(event)">
  79. </div>
  80. <!-- iframe showing the search results (closed by default) -->
  81. <div id="MSearchResultsWindow">
  82. <iframe src="javascript:void(0)" frameborder="0"
  83. name="MSearchResults" id="MSearchResults">
  84. </iframe>
  85. </div>
  86. <div class="header">
  87. <div class="headertitle">
  88. <div class="title">i2c_bb.h</div> </div>
  89. </div><!--header-->
  90. <div class="contents">
  91. <a href="i2c__bb_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160;<span class="preprocessor">#ifndef __utl_com_i2c_bb_h__</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;<span class="preprocessor">#define __utl_com_i2c_bb_h__</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="impl_8h.html">utl/core/impl.h</a>&gt;</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="crtp_8h.html">utl/core/crtp.h</a>&gt;</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="i2c_8h.html">utl/com/i2c.h</a>&gt;</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceutl.html">utl</a> {</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> impl_t&gt;</div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html"> 47</a></span>&#160; <span class="keyword">class </span><a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a> : <span class="keyword">public</span> <a class="code" href="classutl_1_1i2c__i.html">i2c_i</a>&lt;i2c_bb_i&lt;impl_t&gt;&gt; {</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a5c9f28c59f87ebb8a937abb039e11150">_CRTP_IMPL</a>(impl_t);</div><div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a9932eded730c8f9a7b1d15988082b699"> 49</a></span>&#160; <span class="keyword">friend</span> <a class="code" href="classutl_1_1i2c__i.html">i2c_i&lt;i2c_bb_i&lt;impl_t&gt;</a>&gt;;</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a428c847d950993fa2cd005416edfb720"> 52</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classutl_1_1i2c__bb__i.html">type</a> = <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i&lt;impl_t&gt;</a>; </div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052"> 53</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> = <span class="keyword">typename</span> <a class="code" href="classutl_1_1i2c__i.html#a7e2dde443c6c9bde4a2293beb22950c5">i2c_i&lt;type&gt;::Sequence</a>;</div><div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d"> 55</a></span>&#160; <span class="keyword">enum class</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d">SDAMode</a> {</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">INPUT</a> =0,</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">OUTPUT</a></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; };</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#ac2d9b97778a5dd57eb5e6425b4b0833c">~i2c_bb_i</a> () noexcept = default;</div><div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#ab657379ca2e4b3624e2d4520542a9464"> 68</a></span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a> (uint32_t clk) noexcept</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; : <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a> {1000000/(2*clk)} { }</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160;</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922"> 85</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d">SDAMode</a> mode, <span class="keywordtype">bool</span> st) { <span class="keywordflow">return</span> impl().SDA (mode, st); }</div><div class="line"><a name="l00086"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699"> 86</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (uint8_t st) { impl().SCL (st); } </div><div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1"> 87</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (uint32_t usec) { impl().delay(usec); } </div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a1f491d6ccadce71fa6cc59eebc74e82f"> 95</a></span>&#160; uint32_t <a class="code" href="classutl_1_1i2c__bb__i.html#a1f491d6ccadce71fa6cc59eebc74e82f">_clock</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1000000/(2*<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>); }</div><div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#aef4db6e89447b2f0921df5b291b86232"> 96</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#aef4db6e89447b2f0921df5b291b86232">_clock</a> (uint32_t c) { <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a> = 1000000/(2*c); }</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160;</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da">_start</a> (); </div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e">_stop</a> (); </div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> <a class="code" href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110">_rx_data</a> (<span class="keywordtype">bool</span> ack, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq);</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f">_tx_data</a> (<a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq);</div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee"> 102</a></span>&#160; uint32_t <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>; </div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; };</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160; <span class="comment">/*</span></div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160;<span class="comment"> * ============= User functions ================</span></div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> impl_t&gt;</div><div class="line"><a name="l00115"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da"> 115</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da">i2c_bb_i&lt;impl_t&gt;::_start</a> (<span class="keywordtype">void</span>) {</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; <span class="comment">//Initially set pins</span></div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; SDA (SDAMode::OUTPUT, 1);</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; SCL (1);</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; delay (usec_);</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; SDA (SDAMode::OUTPUT, 0);</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; delay (usec_);</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; SCL (0); <span class="comment">//Clear Clock</span></div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; }</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160;</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> impl_t&gt;</div><div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e"> 131</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e">i2c_bb_i&lt;impl_t&gt;::_stop</a> (<span class="keywordtype">void</span>) {</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; <span class="comment">//Stop bit Operation</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; SDA (SDAMode::OUTPUT, 0);</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; SCL (0);</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; SCL (1);</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; delay (usec_);</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; SDA (SDAMode::OUTPUT, 1);</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; delay (usec_);</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; }</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> impl_t&gt;</div><div class="line"><a name="l00154"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110"> 154</a></span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> <a class="code" href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110">i2c_bb_i&lt;impl_t&gt;::_rx_data</a> (<span class="keywordtype">bool</span> ack, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq) {</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte {0};</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; <span class="comment">//Initial conditions</span></div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160; SCL (0);</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; SDA (SDAMode::INPUT, 0);</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160;</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::BYTE || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; <span class="comment">// read 8 data bits</span></div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=8 ; i!=0 ; --i) {</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; byte &lt;&lt;= 1;</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; SCL (1);</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; delay (usec_);</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; byte |= SDA (SDAMode::INPUT, 0);</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; SCL (0);</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; delay (usec_);</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; }</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; }</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::ACK || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; SDA (SDAMode::OUTPUT, !ack); <span class="comment">//Send (or not) ACK bit</span></div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; SCL (1);</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; delay (usec_);</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160; SCL (0); <span class="comment">// Keep the bus busy</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160; SDA (SDAMode::OUTPUT, 0);</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160; }</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>&#160; <span class="keywordflow">return</span> byte;</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>&#160; }</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; <span class="keyword">template</span> &lt;<span class="keyword">typename</span> impl_t&gt;</div><div class="line"><a name="l00194"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f"> 194</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f">i2c_bb_i&lt;impl_t&gt;::_tx_data</a> (<a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq) {</div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160; <span class="keywordtype">bool</span> ack {<span class="keyword">false</span>};</div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160; <span class="comment">//Initial conditions</span></div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; SCL (0);</div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; SDA (SDAMode::OUTPUT, 0);</div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160;</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::BYTE || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; <span class="comment">//Send 8 bit data</span></div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=8 ; i!=0 ; --i) {</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <span class="comment">//Send MSB</span></div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; SDA (SDAMode::OUTPUT, byte &amp; 0x80);</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; byte &lt;&lt;= 1;</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; SCL (1);</div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; delay (usec_);</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; SCL (0);</div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; delay (usec_);</div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; }</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; }</div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::ACK || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; <span class="comment">// Get ACK</span></div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; SDA (SDAMode::INPUT, 0);</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; SCL (1);</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; delay (usec_);</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; ack = !SDA (SDAMode::INPUT, 0);</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; SCL (0); <span class="comment">// Keep the bus busy</span></div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; delay (usec_);</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; SDA (SDAMode::OUTPUT, 0);</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; }</div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; <span class="keywordflow">return</span> ack;</div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; }</div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160;</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160;</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; <span class="keyword">template</span>&lt;&gt;</div><div class="line"><a name="l00234"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html"> 234</a></span>&#160; <span class="keyword">class </span><a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a>&lt;<a class="code" href="structutl_1_1virtual__tag.html">virtual_tag</a>&gt; : <span class="keyword">public</span> <a class="code" href="classutl_1_1i2c__i.html">i2c_i</a>&lt;virtual_tag&gt; {</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00236"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#abedad1f30e2c695d47a84dc68ff05897"> 236</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html">type</a> = <a class="code" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html">i2c_bb_i&lt;virtual_tag&gt;</a>; </div><div class="line"><a name="l00237"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#af8c7ac3797343e39e7e052ec51aec232"> 237</a></span>&#160; <span class="keyword">using</span> <a class="code" href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html#a260541de452a9a653162b8b109b26c09">Sequence</a> = <span class="keyword">typename</span> <a class="code" href="classutl_1_1i2c__i.html#a7e2dde443c6c9bde4a2293beb22950c5">i2c_i&lt;virtual_tag&gt;::Sequence</a>;</div><div class="line"><a name="l00239"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#af4bc7eeeb830e49046a1033e9c79db7f"> 239</a></span>&#160; <span class="keyword">enum class</span> <a class="code" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#af4bc7eeeb830e49046a1033e9c79db7f">SDAMode</a> {</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">INPUT</a> =0,</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">OUTPUT</a></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; };</div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160;</div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00250"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a0c9341b2a60e9400523de0397c472a76"> 250</a></span>&#160; <a class="code" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a0c9341b2a60e9400523de0397c472a76">i2c_bb_i</a> (uint32_t clk) noexcept</div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160; : <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a> {1000000/(2*clk)} { }</div><div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160; <span class="keyword">virtual</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ac2d9b97778a5dd57eb5e6425b4b0833c">~i2c_bb_i</a> () noexcept = default;</div><div class="line"><a name="l00255"></a><span class="lineno"> 255</span>&#160;</div><div class="line"><a name="l00259"></a><span class="lineno"> 259</span>&#160; private:</div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span>&#160; virtual <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d">SDAMode</a> mode, <span class="keywordtype">bool</span> st) =0;</div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span>&#160; virtual <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (<span class="keywordtype">bool</span> st) =0; </div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span>&#160; virtual <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (uint32_t usec) =0; </div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span>&#160;</div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span>&#160; private:</div><div class="line"><a name="l00276"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a0e05ef5f042a1642c9920dd5d7da34b4"> 276</a></span>&#160; uint32_t <a class="code" href="classutl_1_1i2c__bb__i.html#a1f491d6ccadce71fa6cc59eebc74e82f">_clock</a> () const final { <span class="keywordflow">return</span> 1000000/(2*<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>); }</div><div class="line"><a name="l00277"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a47e0f23aa64714a0a95c579994a84fcc"> 277</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a47e0f23aa64714a0a95c579994a84fcc">_clock</a> (uint32_t c) <span class="keyword">final</span> { <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a> = 1000000/(2*c); }</div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span>&#160;</div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da">_start</a> () final;</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e">_stop</a> () final;</div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> <a class="code" href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110">_rx_data</a> (<span class="keywordtype">bool</span> ack, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq) final;</div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f">_tx_data</a> (<a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte, <a class="code" href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">Sequence</a> seq) final;</div><div class="line"><a name="l00284"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#aa3e73dad28462bf6d8c132ddfeb3a390"> 284</a></span>&#160; uint32_t <a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>;</div><div class="line"><a name="l00286"></a><span class="lineno"> 286</span>&#160; };</div><div class="line"><a name="l00287"></a><span class="lineno"> 287</span>&#160;</div><div class="line"><a name="l00293"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#acf1d49b23e9c7b1c42cd43296b8b171c"> 293</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a>&lt;<a class="code" href="structutl_1_1virtual__tag.html">virtual_tag</a>&gt;::<a class="code" href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da">_start</a> (<span class="keywordtype">void</span>) {</div><div class="line"><a name="l00294"></a><span class="lineno"> 294</span>&#160; <span class="comment">//Initially set pins</span></div><div class="line"><a name="l00295"></a><span class="lineno"> 295</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 1);</div><div class="line"><a name="l00296"></a><span class="lineno"> 296</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 0);</div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00300"></a><span class="lineno"> 300</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0); <span class="comment">//Clear Clock</span></div><div class="line"><a name="l00301"></a><span class="lineno"> 301</span>&#160; }</div><div class="line"><a name="l00302"></a><span class="lineno"> 302</span>&#160;</div><div class="line"><a name="l00308"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#acee317f97c201b10680c89ed1a64f694"> 308</a></span>&#160; <span class="keywordtype">void</span> <a class="code" href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e">i2c_bb_i&lt;virtual_tag&gt;::_stop</a> (<span class="keywordtype">void</span>) {</div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span>&#160; <span class="comment">//Stop bit Operation</span></div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 0);</div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0);</div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 1);</div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span>&#160; }</div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span>&#160;</div><div class="line"><a name="l00330"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#abb3eda6549482ff538f2b536d67752ed"> 330</a></span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> <a class="code" href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110">i2c_bb_i&lt;virtual_tag&gt;::_rx_data</a> (<span class="keywordtype">bool</span> ack, <a class="code" href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html#a260541de452a9a653162b8b109b26c09">Sequence</a> seq) {</div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span>&#160; <a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte {0};</div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span>&#160; <span class="comment">//Initial conditions</span></div><div class="line"><a name="l00333"></a><span class="lineno"> 333</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0);</div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">SDAMode::INPUT</a>, 0);</div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span>&#160;</div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::BYTE || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00337"></a><span class="lineno"> 337</span>&#160; <span class="comment">// read 8 data bits</span></div><div class="line"><a name="l00338"></a><span class="lineno"> 338</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=8 ; i!=0 ; --i) {</div><div class="line"><a name="l00339"></a><span class="lineno"> 339</span>&#160; byte &lt;&lt;= 1;</div><div class="line"><a name="l00340"></a><span class="lineno"> 340</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00341"></a><span class="lineno"> 341</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span>&#160; byte |= <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">SDAMode::INPUT</a>, 0);</div><div class="line"><a name="l00343"></a><span class="lineno"> 343</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0);</div><div class="line"><a name="l00344"></a><span class="lineno"> 344</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00345"></a><span class="lineno"> 345</span>&#160; }</div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span>&#160; }</div><div class="line"><a name="l00347"></a><span class="lineno"> 347</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::ACK || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00348"></a><span class="lineno"> 348</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, !ack); <span class="comment">//Send (or not) ACK bit</span></div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00350"></a><span class="lineno"> 350</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00351"></a><span class="lineno"> 351</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0); <span class="comment">// Keep the bus busy</span></div><div class="line"><a name="l00352"></a><span class="lineno"> 352</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 0);</div><div class="line"><a name="l00353"></a><span class="lineno"> 353</span>&#160; }</div><div class="line"><a name="l00354"></a><span class="lineno"> 354</span>&#160; <span class="keywordflow">return</span> byte;</div><div class="line"><a name="l00355"></a><span class="lineno"> 355</span>&#160; }</div><div class="line"><a name="l00356"></a><span class="lineno"> 356</span>&#160;</div><div class="line"><a name="l00369"></a><span class="lineno"><a class="line" href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#abbc42b60004046048a2ac6fd312188a6"> 369</a></span>&#160; <span class="keywordtype">bool</span> <a class="code" href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f">i2c_bb_i&lt;virtual_tag&gt;::_tx_data</a> (<a class="code" href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">byte_t</a> byte, <a class="code" href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html#a260541de452a9a653162b8b109b26c09">Sequence</a> seq) {</div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span>&#160; <span class="keywordtype">bool</span> ack {<span class="keyword">false</span>};</div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span>&#160; <span class="comment">//Initial conditions</span></div><div class="line"><a name="l00372"></a><span class="lineno"> 372</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0);</div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 0);</div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span>&#160;</div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::BYTE || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>&#160; <span class="comment">//Send 8 bit data</span></div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=8 ; i!=0 ; --i) {</div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span>&#160; <span class="comment">//Send MSB</span></div><div class="line"><a name="l00379"></a><span class="lineno"> 379</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, byte &amp; 0x80);</div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span>&#160; byte &lt;&lt;= 1;</div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0);</div><div class="line"><a name="l00384"></a><span class="lineno"> 384</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span>&#160; }</div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span>&#160; }</div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span>&#160; <span class="keywordflow">if</span> (seq == Sequence::ACK || seq == Sequence::BYTEnACK) {</div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span>&#160; <span class="comment">// Get ACK</span></div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">SDAMode::INPUT</a>, 0);</div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (1);</div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span>&#160; ack = !<a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">SDAMode::INPUT</a>, 0);</div><div class="line"><a name="l00393"></a><span class="lineno"> 393</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">SCL</a> (0); <span class="comment">// Keep the bus busy</span></div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">delay</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">usec_</a>);</div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span>&#160; <a class="code" href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">SDA</a> (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">SDAMode::OUTPUT</a>, 0);</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span>&#160; }</div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span>&#160; <span class="keywordflow">return</span> ack;</div><div class="line"><a name="l00398"></a><span class="lineno"> 398</span>&#160; }</div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span>&#160;</div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span>&#160;} <span class="comment">// namspace utl</span></div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span>&#160;</div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span>&#160;<span class="preprocessor">#endif // #ifndef __utl_com_i2c_bb_h__</span></div><div class="ttc" id="classutl_1_1i2c__bb__i_html_ad2872b7e17116f8379144488fe135052"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#ad2872b7e17116f8379144488fe135052">utl::i2c_bb_i::Sequence</a></div><div class="ttdeci">typename i2c_i&lt; type &gt;::Sequence Sequence</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00053">i2c_bb.h:53</a></div></div>
  92. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a8bd3726104fc91eb8f283d7ffec71cee"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a8bd3726104fc91eb8f283d7ffec71cee">utl::i2c_bb_i::usec_</a></div><div class="ttdeci">uint32_t usec_</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00102">i2c_bb.h:102</a></div></div>
  93. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26da50a87f0d71f7221582dad4bf507a0f34">utl::i2c_bb_i::SDAMode::OUTPUT</a></div></div>
  94. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a2f4df606609ef7465109990d9fc0f1da"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a2f4df606609ef7465109990d9fc0f1da">utl::i2c_bb_i::_start</a></div><div class="ttdeci">void _start()</div><div class="ttdoc">Send start functionality. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00115">i2c_bb.h:115</a></div></div>
  95. <div class="ttc" id="classutl_1_1i2c__i_html"><div class="ttname"><a href="classutl_1_1i2c__i.html">utl::i2c_i</a></div><div class="ttdoc">Abstract base class for i2c bus. </div><div class="ttdef"><b>Definition:</b> <a href="i2c_8h_source.html#l00043">i2c.h:43</a></div></div>
  96. <div class="ttc" id="classutl_1_1i2c__bb__i_html_aa197be76016b82fd6f8b66875430d922"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#aa197be76016b82fd6f8b66875430d922">utl::i2c_bb_i::SDA</a></div><div class="ttdeci">bool SDA(SDAMode mode, bool st)</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00085">i2c_bb.h:85</a></div></div>
  97. <div class="ttc" id="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4_html_af4bc7eeeb830e49046a1033e9c79db7f"><div class="ttname"><a href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#af4bc7eeeb830e49046a1033e9c79db7f">utl::i2c_bb_i&lt; virtual_tag &gt;::SDAMode</a></div><div class="ttdeci">SDAMode</div><div class="ttdoc">SDA pin direction enumerator. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00239">i2c_bb.h:239</a></div></div>
  98. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a5c9f28c59f87ebb8a937abb039e11150"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a5c9f28c59f87ebb8a937abb039e11150">utl::i2c_bb_i::_CRTP_IMPL</a></div><div class="ttdeci">_CRTP_IMPL(impl_t)</div></div>
  99. <div class="ttc" id="classutl_1_1i2c__i_3_01virtual__tag_01_4_html"><div class="ttname"><a href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html">utl::i2c_i&lt; virtual_tag &gt;</a></div><div class="ttdoc">A virtual base class specialization. </div><div class="ttdef"><b>Definition:</b> <a href="i2c_8h_source.html#l00140">i2c.h:140</a></div></div>
  100. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a3a459ded18fe55460ae438e312c22110"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a3a459ded18fe55460ae438e312c22110">utl::i2c_bb_i::_rx_data</a></div><div class="ttdeci">byte_t _rx_data(bool ack, Sequence seq)</div><div class="ttdoc">Receive a byte from the i2c bus. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00154">i2c_bb.h:154</a></div></div>
  101. <div class="ttc" id="crtp_8h_html"><div class="ttname"><a href="crtp_8h.html">crtp.h</a></div></div>
  102. <div class="ttc" id="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4_html_a47e0f23aa64714a0a95c579994a84fcc"><div class="ttname"><a href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a47e0f23aa64714a0a95c579994a84fcc">utl::i2c_bb_i&lt; virtual_tag &gt;::_clock</a></div><div class="ttdeci">void _clock(uint32_t c) final</div><div class="ttdoc">set clock frequency of the bus [Hz] </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00277">i2c_bb.h:277</a></div></div>
  103. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a1f491d6ccadce71fa6cc59eebc74e82f"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a1f491d6ccadce71fa6cc59eebc74e82f">utl::i2c_bb_i::_clock</a></div><div class="ttdeci">uint32_t _clock() const</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00095">i2c_bb.h:95</a></div></div>
  104. <div class="ttc" id="classutl_1_1i2c__bb__i_html_ade9235a9d8ccfd7233494631d66ba07e"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#ade9235a9d8ccfd7233494631d66ba07e">utl::i2c_bb_i::_stop</a></div><div class="ttdeci">void _stop()</div><div class="ttdoc">Send stop functionality. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00131">i2c_bb.h:131</a></div></div>
  105. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a085e38e545049ac64cd745b08e0be18f"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a085e38e545049ac64cd745b08e0be18f">utl::i2c_bb_i::_tx_data</a></div><div class="ttdeci">bool _tx_data(byte_t byte, Sequence seq)</div><div class="ttdoc">Transmit a byte to the i2c bus. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00194">i2c_bb.h:194</a></div></div>
  106. <div class="ttc" id="classutl_1_1i2c__bb__i_html_aef4db6e89447b2f0921df5b291b86232"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#aef4db6e89447b2f0921df5b291b86232">utl::i2c_bb_i::_clock</a></div><div class="ttdeci">void _clock(uint32_t c)</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00096">i2c_bb.h:96</a></div></div>
  107. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a4369b434fde250d503bfdc07d5c6a26d"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d">utl::i2c_bb_i::SDAMode</a></div><div class="ttdeci">SDAMode</div><div class="ttdoc">SDA pin direction enumerator. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00055">i2c_bb.h:55</a></div></div>
  108. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26daa84cc046d48610b05c21fd3670d0c829">utl::i2c_bb_i::SDAMode::INPUT</a></div></div>
  109. <div class="ttc" id="namespaceutl_html"><div class="ttname"><a href="namespaceutl.html">utl</a></div><div class="ttdoc">STL&amp;#39;s core language concepts. </div><div class="ttdef"><b>Definition:</b> <a href="__1wire_8h_source.html#l00030">_1wire.h:30</a></div></div>
  110. <div class="ttc" id="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4_html_a0c9341b2a60e9400523de0397c472a76"><div class="ttname"><a href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html#a0c9341b2a60e9400523de0397c472a76">utl::i2c_bb_i&lt; virtual_tag &gt;::i2c_bb_i</a></div><div class="ttdeci">i2c_bb_i(uint32_t clk) noexcept</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00250">i2c_bb.h:250</a></div></div>
  111. <div class="ttc" id="classutl_1_1i2c__i_html_a7e2dde443c6c9bde4a2293beb22950c5"><div class="ttname"><a href="classutl_1_1i2c__i.html#a7e2dde443c6c9bde4a2293beb22950c5">utl::i2c_i::Sequence</a></div><div class="ttdeci">Sequence</div><div class="ttdoc">I2C transmit/receive sequence. </div><div class="ttdef"><b>Definition:</b> <a href="i2c_8h_source.html#l00049">i2c.h:49</a></div></div>
  112. <div class="ttc" id="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4_html"><div class="ttname"><a href="classutl_1_1i2c__bb__i_3_01virtual__tag_01_4.html">utl::i2c_bb_i&lt; virtual_tag &gt;</a></div><div class="ttdoc">A virtual base class interface specialization. Using the private virtual interface we provide the int...</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00234">i2c_bb.h:234</a></div></div>
  113. <div class="ttc" id="classutl_1_1i2c__bb__i_html"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html">utl::i2c_bb_i</a></div><div class="ttdoc">A bit banking implementation of i2c bus inherited from i2c_i base class. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00047">i2c_bb.h:47</a></div></div>
  114. <div class="ttc" id="namespaceutl_html_a1427cb5a2b13313147a902173b91e3c1"><div class="ttname"><a href="namespaceutl.html#a1427cb5a2b13313147a902173b91e3c1">utl::byte_t</a></div><div class="ttdeci">uint8_t byte_t</div><div class="ttdoc">8 bits wide </div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00031">types.h:31</a></div></div>
  115. <div class="ttc" id="structutl_1_1virtual__tag_html"><div class="ttname"><a href="structutl_1_1virtual__tag.html">utl::virtual_tag</a></div><div class="ttdoc">virtual support tag type </div><div class="ttdef"><b>Definition:</b> <a href="crtp_8h_source.html#l00040">crtp.h:40</a></div></div>
  116. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a18db1fab1be2aafbb2612242df2667f1"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a18db1fab1be2aafbb2612242df2667f1">utl::i2c_bb_i::delay</a></div><div class="ttdeci">void delay(uint32_t usec)</div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00087">i2c_bb.h:87</a></div></div>
  117. <div class="ttc" id="classutl_1_1i2c__i_3_01virtual__tag_01_4_html_a260541de452a9a653162b8b109b26c09"><div class="ttname"><a href="classutl_1_1i2c__i_3_01virtual__tag_01_4.html#a260541de452a9a653162b8b109b26c09">utl::i2c_i&lt; virtual_tag &gt;::Sequence</a></div><div class="ttdeci">Sequence</div><div class="ttdoc">I2C transmit/receive sequence. </div><div class="ttdef"><b>Definition:</b> <a href="i2c_8h_source.html#l00145">i2c.h:145</a></div></div>
  118. <div class="ttc" id="classutl_1_1i2c__bb__i_html_ac2d9b97778a5dd57eb5e6425b4b0833c"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#ac2d9b97778a5dd57eb5e6425b4b0833c">utl::i2c_bb_i::~i2c_bb_i</a></div><div class="ttdeci">~i2c_bb_i() noexcept=default</div><div class="ttdoc">A default destructor, allow destructor from derived only. </div></div>
  119. <div class="ttc" id="impl_8h_html"><div class="ttname"><a href="impl_8h.html">impl.h</a></div><div class="ttdoc">Implementation detail main forward header. </div></div>
  120. <div class="ttc" id="classutl_1_1i2c__bb__i_html_a0c9f7d9fc10ac2ceaef93cb6daf8a699"><div class="ttname"><a href="classutl_1_1i2c__bb__i.html#a0c9f7d9fc10ac2ceaef93cb6daf8a699">utl::i2c_bb_i::SCL</a></div><div class="ttdeci">void SCL(uint8_t st)</div><div class="ttdoc">Implementers&amp;#39;s scl pin function. </div><div class="ttdef"><b>Definition:</b> <a href="i2c__bb_8h_source.html#l00086">i2c_bb.h:86</a></div></div>
  121. <div class="ttc" id="i2c_8h_html"><div class="ttname"><a href="i2c_8h.html">i2c.h</a></div><div class="ttdoc">An Abstract base class interface for the i2c bus. </div></div>
  122. </div><!-- fragment --></div><!-- contents -->
  123. </div><!-- doc-content -->
  124. <!-- start footer part -->
  125. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  126. <ul>
  127. <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_82754f54d9380477ef02477185c1f103.html">utl</a></li><li class="navelem"><a class="el" href="dir_b2ad3c1a6521a4924fa9194d98c323e2.html">com</a></li><li class="navelem"><a class="el" href="i2c__bb_8h.html">i2c_bb.h</a></li>
  128. <li class="footer">Generated by
  129. <a href="http://www.doxygen.org/index.html">
  130. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  131. </ul>
  132. </div>
  133. </body>
  134. </html>