|
- <!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_spi_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__spi__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_spi_impl.cpp</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="test__spi__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="spi__bb_8h.html">utl/com/spi_bb.h</a>></span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> </div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="namespacetest__spi.html"> 30</a></span> <span class="keyword">namespace </span><a class="code" href="namespacetest__spi.html">test_spi</a> {</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="keyword">using namespace </span><a class="code" href="namespaceutl.html">utl</a>;</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> </div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  <span class="comment">// implementer class stub</span></div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classtest__spi_1_1_s_p_i.html"> 34</a></span>  <span class="keyword">class </span><a class="code" href="classtest__spi_1_1_s_p_i.html">SPI</a> : <span class="keyword">public</span> <a class="code" href="classutl_1_1spi__bb__i.html">spi_bb_i</a><SPI, spi::cpol::LOW, spi::cpha::LOW> {</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  <span class="keyword">friend</span> <a class="code" href="classutl_1_1spi__bb__i.html">spi_bb_i<SPI, spi::cpol::LOW, spi::cpha::LOW></a>;</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keywordtype">void</span> MOSI (<span class="keywordtype">bool</span> st) { (void)st; } <span class="comment">// Imaginary pin functionality</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  <span class="keywordtype">bool</span> MISO () { <span class="keywordflow">return</span> <span class="keyword">true</span>; } <span class="comment">// All reads become 0xFF</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <span class="keywordtype">void</span> SCLK (<span class="keywordtype">bool</span> st) { (void)st; } <span class="comment">// Imaginary pin functionality</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="keywordtype">void</span> delay (uint32_t nsec) { (void)nsec; } <span class="comment">// Imaginary delay functionality</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> </div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classtest__spi_1_1_s_p_i.html#a588741b66c9890b0d47d84a09f8a19ce"> 42</a></span>  <a class="code" href="classtest__spi_1_1_s_p_i.html#a588741b66c9890b0d47d84a09f8a19ce">SPI</a> (uint32_t clk =100000) noexcept : <span class="comment">// expect 100000 default constructed clock</span></div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <a class="code" href="classutl_1_1spi__bb__i.html">spi_bb_i</a><<a class="code" href="classtest__spi_1_1_s_p_i.html">SPI</a>, spi::<a class="code" href="namespaceutl_1_1spi.html#a89e3e1af5df0b6c37239f7e336969f8a">cpol</a>::LOW, spi::<a class="code" href="namespaceutl_1_1spi.html#aa49fe33d495226891cef0a870cba59df">cpha</a>::LOW>(clk) {</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="l00046"></a><span class="lineno"> 46</span> </div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="comment">// fixture</span></div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="classtest__spi_1_1_test__spi__impl.html"> 48</a></span>  <span class="keyword">class </span><a class="code" href="classtest__spi_1_1_test__spi__impl.html">Test_spi_impl</a> : <span class="keyword">public</span> <a class="code" href="classtesting_1_1_test.html">::testing::Test</a> {</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">protected</span>:</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="comment">//void SetUp() override { }</span></div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="comment">//void TearDown() override { }</span></div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="classtest__spi_1_1_test__spi__impl.html#aba59883c01ad683d209dcf422991d131"> 52</a></span>  <a class="code" href="classtest__spi_1_1_s_p_i.html">SPI</a> spi {};</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"><a class="line" href="namespacetest__spi.html#a08b6fb6773314f5914664f2089ea4eac"> 55</a></span>  <a class="code" href="namespacetest__spi.html#a08b6fb6773314f5914664f2089ea4eac">TEST_F</a>(<a class="code" href="classtest__spi_1_1_test__spi__impl.html">Test_spi_impl</a>, TestConcept) {</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="comment">// EXPECT_EQ(Spi_i<SPI>, true);</span></div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  }</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="namespacetest__spi.html#a751c0b9fe17b002b0ab620f180a46307"> 59</a></span>  <a class="code" href="namespacetest__spi.html#a08b6fb6773314f5914664f2089ea4eac">TEST_F</a>(<a class="code" href="classtest__spi_1_1_test__spi__impl.html">Test_spi_impl</a>, TestConstruction) {</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(spi.clock(), 100000UL);</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  }</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> </div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="namespacetest__spi.html#aa98da2aecf8b42f492ec1c206e8b8aba"> 63</a></span>  <a class="code" href="namespacetest__spi.html#a08b6fb6773314f5914664f2089ea4eac">TEST_F</a> (<a class="code" href="classtest__spi_1_1_test__spi__impl.html">Test_spi_impl</a>, TestFunctionality) {</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  uint8_t b = 42;</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  uint8_t bb[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  uint8_t bbb[<span class="keyword">sizeof</span> bb];</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> </div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  spi.clock(500000UL);</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(spi.clock(), 500000UL);</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> </div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(spi.tx_data(b), 0xFF);</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(spi.tx_data(bb, bbb, <span class="keyword">sizeof</span>(bb)), <span class="keyword">sizeof</span> (bb));</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a>(spi.rx_data(), 0xFF);</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  spi.rx_data(bbb, <span class="keyword">sizeof</span> bb);</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0 ; i<<span class="keyword">sizeof</span> bb ; ++i) {</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <a class="code" href="gtest_8h.html#a4159019abda84f5366acdb7604ff220a">EXPECT_EQ</a> (bbb[i], 0xFF);</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  }</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  }</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span> }</div><div class="ttc" id="namespaceutl_1_1spi_html_a89e3e1af5df0b6c37239f7e336969f8a"><div class="ttname"><a href="namespaceutl_1_1spi.html#a89e3e1af5df0b6c37239f7e336969f8a">utl::spi::cpol</a></div><div class="ttdeci">cpol</div><div class="ttdef"><b>Definition:</b> <a href="spi_8h_source.html#l00047">spi.h:47</a></div></div>
- <div class="ttc" id="classtest__spi_1_1_test__spi__impl_html"><div class="ttname"><a href="classtest__spi_1_1_test__spi__impl.html">test_spi::Test_spi_impl</a></div><div class="ttdef"><b>Definition:</b> <a href="test__spi__impl_8cpp_source.html#l00048">test_spi_impl.cpp:48</a></div></div>
- <div class="ttc" id="classtest__spi_1_1_s_p_i_html"><div class="ttname"><a href="classtest__spi_1_1_s_p_i.html">test_spi::SPI</a></div><div class="ttdef"><b>Definition:</b> <a href="test__spi__impl_8cpp_source.html#l00034">test_spi_impl.cpp:34</a></div></div>
- <div class="ttc" id="namespacetest__spi_html"><div class="ttname"><a href="namespacetest__spi.html">test_spi</a></div><div class="ttdef"><b>Definition:</b> <a href="test__spi__impl_8cpp_source.html#l00030">test_spi_impl.cpp:30</a></div></div>
- <div class="ttc" id="namespacetest__spi_html_a08b6fb6773314f5914664f2089ea4eac"><div class="ttname"><a href="namespacetest__spi.html#a08b6fb6773314f5914664f2089ea4eac">test_spi::TEST_F</a></div><div class="ttdeci">TEST_F(Test_spi_impl, TestConcept)</div><div class="ttdef"><b>Definition:</b> <a href="test__spi__impl_8cpp_source.html#l00055">test_spi_impl.cpp:55</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="namespaceutl_1_1spi_html_aa49fe33d495226891cef0a870cba59df"><div class="ttname"><a href="namespaceutl_1_1spi.html#aa49fe33d495226891cef0a870cba59df">utl::spi::cpha</a></div><div class="ttdeci">cpha</div><div class="ttdef"><b>Definition:</b> <a href="spi_8h_source.html#l00054">spi.h:54</a></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_1spi__bb__i_html"><div class="ttname"><a href="classutl_1_1spi__bb__i.html">utl::spi_bb_i</a></div><div class="ttdoc">A bit banking implementation of spi bus inherited from spi_i base class. </div><div class="ttdef"><b>Definition:</b> <a href="spi__bb_8h_source.html#l00056">spi_bb.h:56</a></div></div>
- <div class="ttc" id="classtesting_1_1_test_html"><div class="ttname"><a href="classtesting_1_1_test.html">testing::Test</a></div><div class="ttdef"><b>Definition:</b> <a href="gtest_8h_source.html#l15014">gtest.h:15014</a></div></div>
- <div class="ttc" id="spi__bb_8h_html"><div class="ttname"><a href="spi__bb_8h.html">spi_bb.h</a></div><div class="ttdoc">A bit banking implementation of spi bus inherited from spi_i base class. </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="classtest__spi_1_1_s_p_i_html_a588741b66c9890b0d47d84a09f8a19ce"><div class="ttname"><a href="classtest__spi_1_1_s_p_i.html#a588741b66c9890b0d47d84a09f8a19ce">test_spi::SPI::SPI</a></div><div class="ttdeci">SPI(uint32_t clk=100000) noexcept</div><div class="ttdef"><b>Definition:</b> <a href="test__spi__impl_8cpp_source.html#l00042">test_spi_impl.cpp:42</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__spi__impl_8cpp.html">test_spi_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>
|