167 lines
15 KiB
HTML
167 lines
15 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||
|
<meta name="generator" content="Doxygen 1.9.6"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
<title>Solar panel: crc.c 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>
|
||
|
<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 id="projectrow">
|
||
|
<td id="projectalign">
|
||
|
<div id="projectname">Solar panel
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
<!-- end header part -->
|
||
|
<!-- Generated by Doxygen 1.9.6 -->
|
||
|
<script type="text/javascript">
|
||
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||
|
/* @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:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
$(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:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||
|
$(document).ready(function(){initNavTree('crc_8c_source.html',''); initResizable(); });
|
||
|
/* @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">
|
||
|
<div id="MSearchResults">
|
||
|
<div class="SRPage">
|
||
|
<div id="SRIndex">
|
||
|
<div id="SRResults"></div>
|
||
|
<div class="SRStatus" id="Loading">Loading...</div>
|
||
|
<div class="SRStatus" id="Searching">Searching...</div>
|
||
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="header">
|
||
|
<div class="headertitle"><div class="title">crc.c</div></div>
|
||
|
</div><!--header-->
|
||
|
<div class="contents">
|
||
|
<a href="crc_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
|
||
|
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include "<a class="code" href="crc_8h.html">crc.h</a>"</span></div>
|
||
|
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span> </div>
|
||
|
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"><a class="line" href="crc_8c.html#a7362c72c8a4b1f27641c41b04d899e6b"> 7</a></span><span class="keyword">const</span> uint8_t <a class="code hl_variable" href="crc_8c.html#a7362c72c8a4b1f27641c41b04d899e6b">auchCRCHi</a>[] = {</div>
|
||
|
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span> 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,</div>
|
||
|
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span> 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
|
||
|
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span> 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,</div>
|
||
|
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,</div>
|
||
|
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,</div>
|
||
|
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,</div>
|
||
|
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,</div>
|
||
|
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,</div>
|
||
|
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,</div>
|
||
|
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
|
||
|
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,</div>
|
||
|
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
|
||
|
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,</div>
|
||
|
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,</div>
|
||
|
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,</div>
|
||
|
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,</div>
|
||
|
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,</div>
|
||
|
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> 0x40</div>
|
||
|
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span>};</div>
|
||
|
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="crc_8c.html#a1f5449b8e6577d9b28f66b9453ccb2f3"> 27</a></span><span class="keyword">const</span> uint8_t <a class="code hl_variable" href="crc_8c.html#a1f5449b8e6577d9b28f66b9453ccb2f3">auchCRCLo</a>[] = {</div>
|
||
|
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4,</div>
|
||
|
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,</div>
|
||
|
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD,</div>
|
||
|
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,</div>
|
||
|
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7,</div>
|
||
|
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,</div>
|
||
|
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE,</div>
|
||
|
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,</div>
|
||
|
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2,</div>
|
||
|
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,</div>
|
||
|
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB,</div>
|
||
|
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,</div>
|
||
|
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91,</div>
|
||
|
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,</div>
|
||
|
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88,</div>
|
||
|
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,</div>
|
||
|
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80,</div>
|
||
|
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> 0x40</div>
|
||
|
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span>};</div>
|
||
|
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> </div>
|
||
|
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"><a class="line" href="crc_8c.html#a0fb245e3321a13b9170f7a948ed08b51"> 48</a></span>uint16_t <a class="code hl_function" href="crc_8c.html#a0fb245e3321a13b9170f7a948ed08b51">CRC16</a>(<span class="keyword">const</span> uint8_t *msg, uint16_t length)</div>
|
||
|
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span>{</div>
|
||
|
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> uint8_t uchCRCHi = 0xFF; <span class="comment">/* high byte of CRC initialized */</span></div>
|
||
|
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> uint8_t uchCRCLo = 0xFF; <span class="comment">/* low byte of CRC initialized */</span></div>
|
||
|
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> uint8_t uIndex; <span class="comment">/* will index into CRC lookup table */</span></div>
|
||
|
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> </div>
|
||
|
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <span class="keywordflow">while</span> (length--) <span class="comment">/* pass through message buffer */</span> {</div>
|
||
|
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> uIndex = uchCRCLo ^ *msg++; <span class="comment">/* calculate the CRC */</span></div>
|
||
|
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> uchCRCLo = uchCRCHi ^ <a class="code hl_variable" href="crc_8c.html#a7362c72c8a4b1f27641c41b04d899e6b">auchCRCHi</a>[uIndex];</div>
|
||
|
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> uchCRCHi = <a class="code hl_variable" href="crc_8c.html#a1f5449b8e6577d9b28f66b9453ccb2f3">auchCRCLo</a>[uIndex];</div>
|
||
|
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> }</div>
|
||
|
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keywordflow">return</span> (uchCRCHi << 8 | uchCRCLo);</div>
|
||
|
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span>}</div>
|
||
|
<div class="ttc" id="acrc_8c_html_a0fb245e3321a13b9170f7a948ed08b51"><div class="ttname"><a href="crc_8c.html#a0fb245e3321a13b9170f7a948ed08b51">CRC16</a></div><div class="ttdeci">uint16_t CRC16(const uint8_t *msg, uint16_t length)</div><div class="ttdef"><b>Definition:</b> <a href="crc_8c_source.html#l00048">crc.c:48</a></div></div>
|
||
|
<div class="ttc" id="acrc_8c_html_a1f5449b8e6577d9b28f66b9453ccb2f3"><div class="ttname"><a href="crc_8c.html#a1f5449b8e6577d9b28f66b9453ccb2f3">auchCRCLo</a></div><div class="ttdeci">const uint8_t auchCRCLo[]</div><div class="ttdef"><b>Definition:</b> <a href="crc_8c_source.html#l00027">crc.c:27</a></div></div>
|
||
|
<div class="ttc" id="acrc_8c_html_a7362c72c8a4b1f27641c41b04d899e6b"><div class="ttname"><a href="crc_8c.html#a7362c72c8a4b1f27641c41b04d899e6b">auchCRCHi</a></div><div class="ttdeci">const uint8_t auchCRCHi[]</div><div class="ttdef"><b>Definition:</b> <a href="crc_8c_source.html#l00007">crc.c:7</a></div></div>
|
||
|
<div class="ttc" id="acrc_8h_html"><div class="ttname"><a href="crc_8h.html">crc.h</a></div><div class="ttdoc">CRC calculation for Modbus.</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="crc_8c.html">crc.c</a></li>
|
||
|
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|