util_8h.html

来自「BlueLab3 bluetooth API 说明文档」· HTML 代码 · 共 330 行

HTML
330
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>BlueLab: util.h File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.8 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>util.h File Reference</h1>Utility routines. <a href="#_details">More...</a><p><h2>Functions</h2><ul><li>int <a class="el" href="util_8h.html#a0">UtilCompare</a> (const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *a, const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *b, <a class="el" href="csrtypes_8h.html#a2">size_t</a> size)<dl class="el"><dd class="mdescRight">Compare two blocks of memory of extent 'size', as uint16's.  <a href="#a0"></a><br></dl><li>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * <a class="el" href="util_8h.html#a1">UtilFind</a> (<a class="el" href="csrtypes_8h.html#a4">uint16</a> mask, <a class="el" href="csrtypes_8h.html#a4">uint16</a> value, const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *data_start, <a class="el" href="csrtypes_8h.html#a4">uint16</a> offset, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size, <a class="el" href="csrtypes_8h.html#a4">uint16</a> count)<dl class="el"><dd class="mdescRight">Compares two memory blocks.  <a href="#a1"></a><br></dl><li>const <a class="el" href="csrtypes_8h.html#a8">uint8</a> * <a class="el" href="util_8h.html#a2">UtilGetNumber</a> (const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *start, const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *end, <a class="el" href="csrtypes_8h.html#a4">uint16</a> *result)<dl class="el"><dd class="mdescRight">Converts a string into a number.  <a href="#a2"></a><br></dl><li><a class="el" href="csrtypes_8h.html#a4">uint16</a> <a class="el" href="util_8h.html#a3">UtilHash</a> (const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *data, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size, <a class="el" href="csrtypes_8h.html#a4">uint16</a> seed)<dl class="el"><dd class="mdescRight">Compute a uint16 hash value for the memory at 'data', of extent 'size' uint16's, starting with the given 'seed'.  <a href="#a3"></a><br></dl><li><a class="el" href="csrtypes_8h.html#a4">uint16</a> <a class="el" href="util_8h.html#a4">UtilRandom</a> (void)<dl class="el"><dd class="mdescRight">Returns a 16-bit random number.  <a href="#a4"></a><br></dl><li>void <a class="el" href="util_8h.html#a5">UtilSwap</a> (<a class="el" href="csrtypes_8h.html#a4">uint16</a> *data, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size)<dl class="el"><dd class="mdescRight">Exchanges the high and low bytes of 'size' words at 'data'.  <a href="#a5"></a><br></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>Utility routines. <p>These routines perform a number of frequently required tasks. They will execute at a greater speed than similar routines written in VM application code.<hr><h2>Function Documentation</h2><a class="anchor" name="a0" doxytag="util.h::UtilCompare" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> int UtilCompare           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>a</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>b</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a2">size_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>size</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Compare two blocks of memory of extent 'size', as uint16's. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>a</em>&nbsp;</td><td>First memory block to compare. </td></tr>    <tr><td></td><td valign=top><em>b</em>&nbsp;</td><td>Second memory block to compare. </td></tr>    <tr><td></td><td valign=top><em>size</em>&nbsp;</td><td>Size of memory blocks to compare.</td></tr>  </table></dl>Return &gt; 0 if 'a' is lexicographically greater than 'b', &lt; 0 if 'a' is lexicographically less than 'b', 0 if 'a' and 'b' have identical contents.     </td>  </tr></table><a class="anchor" name="a1" doxytag="util.h::UtilFind" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> const <a class="el" href="csrtypes_8h.html#a4">uint16</a>* UtilFind           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>mask</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>value</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>data_start</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>offset</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>size</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>count</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Compares two memory blocks. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>mask</em>&nbsp;</td><td>The bitmask to use. </td></tr>    <tr><td></td><td valign=top><em>value</em>&nbsp;</td><td>The value to look for. </td></tr>    <tr><td></td><td valign=top><em>data_start</em>&nbsp;</td><td>The memory location of the start of the table. </td></tr>    <tr><td></td><td valign=top><em>offset</em>&nbsp;</td><td>The offset into each table entry that the search will be performed at. </td></tr>    <tr><td></td><td valign=top><em>size</em>&nbsp;</td><td>The size of each table entry. </td></tr>    <tr><td></td><td valign=top><em>count</em>&nbsp;</td><td>The number of entries in the table.</td></tr>  </table></dl>Conceptually we have a table in memory starting at 'data_start', with 'count' entries where each entry is 'size'. UtilFind searches for 'value', at 'offset' from the start of each entry, using bitmask 'mask'. Returns vm address of the table entry containing 'value' if found, else 0.     </td>  </tr></table><a class="anchor" name="a2" doxytag="util.h::UtilGetNumber" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> const <a class="el" href="csrtypes_8h.html#a8">uint8</a>* UtilGetNumber           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>start</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>end</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>result</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Converts a string into a number. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>start</em>&nbsp;</td><td>The start of the string to convert. </td></tr>    <tr><td></td><td valign=top><em>end</em>&nbsp;</td><td>The end of the string to convert. </td></tr>    <tr><td></td><td valign=top><em>result</em>&nbsp;</td><td>Will contain the resulting number.</td></tr>  </table></dl>The return value is a pointer into the string (the first character after the number) unless no number was found, in which case 0 is returned. The number is expected to be an unsigned decimal in the range 0 to 2^16.     </td>  </tr></table><a class="anchor" name="a3" doxytag="util.h::UtilHash" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> <a class="el" href="csrtypes_8h.html#a4">uint16</a> UtilHash           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>data</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>size</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>seed</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Compute a uint16 hash value for the memory at 'data', of extent 'size' uint16's, starting with the given 'seed'. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>data</em>&nbsp;</td><td>The start of the memory block to hash. </td></tr>    <tr><td></td><td valign=top><em>size</em>&nbsp;</td><td>The size of the memory block to hash. </td></tr>    <tr><td></td><td valign=top><em>seed</em>&nbsp;</td><td>The seed value to use for the hash. </td></tr>  </table></dl>    </td>  </tr></table><a class="anchor" name="a4" doxytag="util.h::UtilRandom" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> <a class="el" href="csrtypes_8h.html#a4">uint16</a> UtilRandom           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Returns a 16-bit random number. <p>Uses a numerical approach, but the state is shared with the BlueCore firmware which also makes calls into this function so predicability will be low.     </td>  </tr></table><a class="anchor" name="a5" doxytag="util.h::UtilSwap" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> void UtilSwap           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="csrtypes_8h.html#a4">uint16</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>data</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a>&nbsp;</td>          <td class="mdname" nowrap> <em>size</em></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Exchanges the high and low bytes of 'size' words at 'data'. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>data</em>&nbsp;</td><td>The memory location to begin swapping from. </td></tr>    <tr><td></td><td valign=top><em>size</em>&nbsp;</td><td>The number of swaps to perform. </td></tr>  </table></dl>    </td>  </tr></table></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?