|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.14"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>uTL: test/tests/test_i2c_impl.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">uTL
- </div>
- <div id="projectbrief">micro Template library</div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.14 -->
- <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('test__i2c__impl_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">test_i2c_impl.cpp</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="test__i2c__impl_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> </div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include <<a class="code" href="gtest_8h.html">gtest/gtest.h</a>></span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include <<a class="code" href="i2c__bb_8h.html">utl/com/i2c_bb.h</a>></span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="namespacetest__i2c.html"> 29</a></span> <span class="keyword">namespace </span><a class="code" href="namespacetest__i2c.html">test_i2c</a> {</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  <span class="keyword">using namespace </span><a class="code" href="namespaceutl.html">utl</a>;</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  <span class="comment">// implementer class stub</span></div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classtest__i2c_1_1_i2_c.html"> 33</a></span>  <span class="keyword">class </span><a class="code" href="classtest__i2c_1_1_i2_c.html">I2C</a> : <span class="keyword">public</span> <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a><I2C> {</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  <span class="keyword">friend</span> <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i<I2C></a>;</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  <span class="keywordtype">void</span> SCL (<span class="keywordtype">bool</span> x) { (void)x; } <span class="comment">// imaginary SCL pin functionality</span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keywordtype">bool</span> SDA (<a class="code" href="classutl_1_1i2c__bb__i.html#a4369b434fde250d503bfdc07d5c6a26d">SDAMode</a> mode, <span class="keywordtype">bool</span> x) {</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  (void)mode;</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  (void)x;</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="comment">// always read 0 back (which means always ACK)</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  }</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keywordtype">void</span> delay (uint32_t u) {</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  (void)u;</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="comment">// Pseudo-delay</span></div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i =0 ; i<10 ; ++i)</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  ;</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  }</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classtest__i2c_1_1_i2_c.html#accd54d8b7f168eece3d462194964f967"> 50</a></span>  <a class="code" href="classtest__i2c_1_1_i2_c.html#accd54d8b7f168eece3d462194964f967">I2C</a> (uint32_t clk =100000) noexcept</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  : <a class="code" href="classutl_1_1i2c__bb__i.html">i2c_bb_i</a><<a class="code" href="classtest__i2c_1_1_i2_c.html">I2C</a>>(clk) {</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  start();</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="l00055"></a><span class="lineno"> 55</span> </div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="namespacetest__i2c.html#a04c34c5bd7848008eb6803be850b2296"> 56</a></span>  <a class="code" href="namespacetest__i2c.html#a04c34c5bd7848008eb6803be850b2296">TEST</a>(Test_i2c_impl, TestConcept) {</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <a class="code" href="classtest__i2c_1_1_i2_c.html">I2C</a> i2c {};</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="comment">// EXPECT_EQ(I2c_i<I2C>, true);</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  }</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div><div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="namespacetest__i2c.html#a74c8554cb3a4c7bd022cd854feb06688"> 61</a></span>  <a class="code" href="namespacetest__i2c.html#a04c34c5bd7848008eb6803be850b2296">TEST</a>(Test_i2c_impl, TestConstruction) {</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <a class="code" href="classtest__i2c_1_1_i2_c.html">I2C</a> i2c {};</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(i2c.clock(), 100000UL);</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  }</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> </div><div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="namespacetest__i2c.html#aee88e63fc24ad87c0987c6f207dd20fa"> 66</a></span>  <a class="code" href="namespacetest__i2c.html#a04c34c5bd7848008eb6803be850b2296">TEST</a>(Test_i2c_impl, TestFunctionality) {</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <a class="code" href="classtest__i2c_1_1_i2_c.html">I2C</a> i2c {};</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  uint8_t b = 42;</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  i2c.<a class="code" href="classutl_1_1i2c__i.html#aac5fed816701cc4543acd717ec804ac0">clock</a>(200000UL);</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="comment">//EXPECT_EQ(i2c.clock(), 200000UL);</span></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>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(i2c.tx_data(b), <span class="keyword">true</span>);</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(i2c.rx_data(<span class="keyword">true</span>), 0x00);</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(i2c.rx_data(<span class="keyword">false</span>), 0x00);</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  }</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> }</div><div class="ttc" id="classtest__i2c_1_1_i2_c_html_accd54d8b7f168eece3d462194964f967"><div class="ttname"><a href="classtest__i2c_1_1_i2_c.html#accd54d8b7f168eece3d462194964f967">test_i2c::I2C::I2C</a></div><div class="ttdeci">I2C(uint32_t clk=100000) noexcept</div><div class="ttdef"><b>Definition:</b> <a href="test__i2c__impl_8cpp_source.html#l00050">test_i2c_impl.cpp:50</a></div></div>
- <div class="ttc" id="namespacetest__i2c_html"><div class="ttname"><a href="namespacetest__i2c.html">test_i2c</a></div><div class="ttdef"><b>Definition:</b> <a href="test__i2c__impl_8cpp_source.html#l00029">test_i2c_impl.cpp:29</a></div></div>
- <div class="ttc" id="namespacetest__i2c_html_a04c34c5bd7848008eb6803be850b2296"><div class="ttname"><a href="namespacetest__i2c.html#a04c34c5bd7848008eb6803be850b2296">test_i2c::TEST</a></div><div class="ttdeci">TEST(Test_i2c_impl, TestConcept)</div><div class="ttdef"><b>Definition:</b> <a href="test__i2c__impl_8cpp_source.html#l00056">test_i2c_impl.cpp:56</a></div></div>
- <div class="ttc" id="gtest_8h_html"><div class="ttname"><a href="gtest_8h.html">gtest.h</a></div></div>
- <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< I2C >::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>
- <div class="ttc" id="i2c__bb_8h_html"><div class="ttname"><a href="i2c__bb_8h.html">i2c_bb.h</a></div><div class="ttdoc">A bit banking implementation of i2c bus inherited from i2c_i base class. </div></div>
- <div class="ttc" id="namespaceutl_html"><div class="ttname"><a href="namespaceutl.html">utl</a></div><div class="ttdoc">STL&#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>
- <div class="ttc" id="classutl_1_1i2c__i_html_aac5fed816701cc4543acd717ec804ac0"><div class="ttname"><a href="classutl_1_1i2c__i.html#aac5fed816701cc4543acd717ec804ac0">utl::i2c_i::clock</a></div><div class="ttdeci">uint32_t clock() const</div><div class="ttdef"><b>Definition:</b> <a href="i2c_8h_source.html#l00087">i2c.h:87</a></div></div>
- <div class="ttc" id="gtest_8h_html_a4159019abda84f5366acdb7604ff220a"><div class="ttname"><a href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a></div><div class="ttdeci">#define EXPECT_EQ(val1, val2)</div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l16643">gtest.h:16643</a></div></div>
- <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>
- <div class="ttc" id="classtest__i2c_1_1_i2_c_html"><div class="ttname"><a href="classtest__i2c_1_1_i2_c.html">test_i2c::I2C</a></div><div class="ttdef"><b>Definition:</b> <a href="test__i2c__impl_8cpp_source.html#l00033">test_i2c_impl.cpp:33</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_13e138d54eb8818da29c3992edef070a.html">test</a></li><li class="navelem"><a class="el" href="dir_d84abbe486a7f5f39e3c9088ffc1760a.html">tests</a></li><li class="navelem"><a class="el" href="test__i2c__impl_8cpp.html">test_i2c_impl.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.14 </li>
- </ul>
- </div>
- </body>
- </html>
|