📄 protocol_8c.html
字号:
<!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>WirelessUSB(TM) LS PRoC DVK Protocol Slave Tutorial: protocol.c File Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>protocol.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
Collection of master protocol and bind prototypes.
<p>
<code>#include "<a class="el" href="protocol_8h.html">protocol.h</a>"</code><br>
<code>#include "radio.h"</code><br>
<p>
Include dependency graph for protocol.c:<p><center><img src="protocol_8c__incl.png" border="0" usemap="#protocol.c_map" alt="Include dependency graph"></center>
<map name="protocol.c_map">
<area href="protocol_8h.html" shape="rect" coords="154,157,234,184" alt="">
<area href="ls__config_8h.html" shape="rect" coords="152,82,237,109" alt="">
<area href="isr_8h.html" shape="rect" coords="133,8,178,34" alt="">
<area href="timer_8h.html" shape="rect" coords="202,8,266,34" alt="">
<area href="flash_8h.html" shape="rect" coords="290,8,352,34" alt="">
</map>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a0">protocol_device_type</a> DEVICE_TYPE</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a1">NUM_PN_CODES</a> 8</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a14">protocol_init</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a15">protocol_set_role_slave</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a16">slave_bind</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a17">slave_reconnect</a> ()</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a18">slave_send_packet</a> (<a class="el" href="cypdef_8h.html#a1">UINT8</a> data_length)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a19">protocol_calc_ck_sum</a> (<a class="el" href="cypdef_8h.html#a1">UINT8</a> *data, <a class="el" href="cypdef_8h.html#a1">UINT8</a> len, <a class="el" href="cypdef_8h.html#a1">UINT8</a> seed)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a20">protocol_gen_parity</a> (<a class="el" href="cypdef_8h.html#a1">UINT8</a> data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a21">protocol_get_rx_packet_length</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a22">protocol_send_ack</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a23">protocol_verify_packet</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a24">protocol_get_tx_pkt</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a25">protocol_get_rx_pkt</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a26">protocol_get_next_channel</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a27">protocol_init_channel</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a28">protocol_calculate_network_id</a> (void)</td></tr>
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="struct__SYS__PARAMETERS.html">SYS_PARAMETERS</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a2">sys_params</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="union__LS__DATA__PACKET.html">LS_DATA_PACKET</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a3">rx_packet</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="union__LS__DATA__PACKET.html">LS_DATA_PACKET</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a4">tx_packet</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="union__LS__CONTROL__PACKET.html">LS_CONTROL_PACKET</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a5">cmd_packet</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a6">tx_length</a> = 0</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a7">valid_buffer</a> [LS_RX_PACKET_LEN]</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a8">master_rx_data_toggle</a> = 1</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a9">rx_data_length</a> = 0</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a10">bind_state</a> = 0</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a11">slave_tx_data_toggle</a> = 1</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a12">slave_rx_data_toggle</a> = 1</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="cypdef_8h.html#a1">UINT8</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="protocol_8c.html#a13">pn_code_table</a> []</td></tr>
</table>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="a0" doxytag="protocol.c::protocol_device_type"></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">#define protocol_device_type DEVICE_TYPE </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Macro for the device type.
<p>
</td>
</tr>
</table>
<a class="anchor" name="a1" doxytag="protocol.c::NUM_PN_CODES"></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">#define NUM_PN_CODES 8 </td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Number of PN codes for data rate of 64.
<p>
</td>
</tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="a14" doxytag="protocol.c::protocol_init"></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="cypdef_8h.html#a1">UINT8</a> protocol_init </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Description: Calls radio init, and figures device parameters using algorithms to find PN code, channel, pin, and checksum seed (based off the MID). The PN code data toggles, and time stamp get set. Then makes sure a channel is found at startup<p>
Inputs: Void<p>
Returns:<ul>
<li>LS_STATUS_SUCCESS - for successful initialization </li></ul>
</td>
</tr>
</table>
<p>
Here is the call graph for this function:<p><center><img src="protocol_8c_a14_cgraph.png" border="0" usemap="#protocol_8c_a14_cgraph_map" alt=""></center>
<map name="protocol_8c_a14_cgraph_map">
<area href="protocol_8c.html#a15" shape="rect" coords="153,8,316,34" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="365,8,568,34" alt="">
</map>
<a class="anchor" name="a15" doxytag="protocol.c::protocol_set_role_slave"></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 protocol_set_role_slave </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Description: Configures the device for master or slave mode. If master mode is selected this function also calls master_ping_mode() to find a quiet channel.<p>
Inputs: Void<p>
Returns: Void </td>
</tr>
</table>
<p>
Here is the call graph for this function:<p><center><img src="protocol_8c_a15_cgraph.png" border="0" usemap="#protocol_8c_a15_cgraph_map" alt=""></center>
<map name="protocol_8c_a15_cgraph_map">
<area href="protocol_8c.html#a28" shape="rect" coords="221,8,424,34" alt="">
</map>
<a class="anchor" name="a16" doxytag="protocol.c::slave_bind"></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="cypdef_8h.html#a1">UINT8</a> slave_bind </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Description: Sets the transmit power level used to kiss bind. Formats and sends a bind response packet on every channel and PN code. Then it sends a bind request using the KISS_BIND_CHANNEL. It then looks for an ACK from the Master device. Using the KISS_BIND_CHANNEL it sends bind requests with all PN codes until an acknowledge is received (or the maximum amount of requests have been sent). If all channels and PN codes have been run through without an ack, then a bind timeout occurs which would result to an unsuccessful bind and all bind parameters are reinitialized. If a good ack packet is received, it then creates and sends an ack packet back 3 times to ensure delivery. Then the settings are saved in NVRAM and the power settings are restored.<p>
Inputs: Void<p>
Returns:<ul>
<li>LS_STATUS_SUCCESS - successful bind</li><li>LS_STATUS_FAILED - unsuccessful bind </li></ul>
</td>
</tr>
</table>
<p>
Here is the call graph for this function:<p><center><img src="protocol_8c_a16_cgraph.png" border="0" usemap="#protocol_8c_a16_cgraph_map" alt=""></center>
<map name="protocol_8c_a16_cgraph_map">
<area href="protocol_8h.html#a96" shape="rect" coords="626,85,781,112" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="143,338,346,365" alt="">
<area href="protocol_8h.html#a95" shape="rect" coords="634,186,773,213" alt="">
<area href="protocol_8c.html#a27" shape="rect" coords="170,389,319,416" alt="">
<area href="protocol_8c.html#a23" shape="rect" coords="407,85,565,112" alt="">
<area href="protocol_8c.html#a17" shape="rect" coords="185,186,305,213" alt="">
<area href="protocol_8c.html#a26" shape="rect" coords="395,237,577,264" alt="">
</map>
<a class="anchor" name="a17" doxytag="protocol.c::slave_reconnect"></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="cypdef_8h.html#a1">UINT8</a> slave_reconnect </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">void </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Description: Checks for an unbound device, resets radio (and restore transmit valid bits if necessary), formats a connect data packet, reads radio information and sets up the radio. It then reads and adjusts power level (if DYNAMIC_PA enabled). Then as it runs through the channels it sends connect requests until an good response is received (or the maximum amount of requests have been sent). If all channels have been run through without a response, then it tries the original channel a few times. If no response is received on any channel the connection is unsuccessful.<p>
Inputs: Void<p>
Returns:<ul>
<li>LS_STATUS_SUCCESS - successful connection</li><li>LS_STATUS_FAILED - unsuccessful connection </li></ul>
</td>
</tr>
</table>
<p>
Here is the call graph for this function:<p><center><img src="protocol_8c_a17_cgraph.png" border="0" usemap="#protocol_8c_a17_cgraph_map" alt=""></center>
<map name="protocol_8c_a17_cgraph_map">
<area href="protocol_8h.html#a96" shape="rect" coords="408,33,562,60" alt="">
<area href="protocol_8h.html#a95" shape="rect" coords="416,109,554,136" alt="">
<area href="protocol_8c.html#a26" shape="rect" coords="177,109,358,136" alt="">
<area href="protocol_8c.html#a23" shape="rect" coords="189,58,346,85" alt="">
</map>
<a class="anchor" name="a18" doxytag="protocol.c::slave_send_packet"></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="cypdef_8h.html#a1">UINT8</a> slave_send_packet </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="cypdef_8h.html#a1">UINT8</a> </td>
<td class="mdname1" valign="top" nowrap> <em>data_length</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Description: Makes sure that the device is connected. If there is no data to send, it will prepare a null packet to keep things alive. If there is data, a packet is prepared with actual data. Once the packet is prepared it is transmitted. Once an acknowledge (DATA/ACK or ACK) is received from the master device, then it sends an ACK back (stripping the checksum and header from packet first).<p>
Inputs:<ul>
<li>data_length - Length of packet, 0 = send NULL packet</li></ul>
<p>
Returns:<ul>
<li>TX_TIMEOUT_ERR - If not bound or when a timeout occurs on the transmit</li><li>INVALID_DATA - When data_length is >= APP_TX_PACKET_SIZE</li><li>ACK_DATA - If the data toggle parameter is set in the receive packet</li><li>DATA_SENT - Data transmitted successfully </li></ul>
</td>
</tr>
</table>
<p>
Here is the call graph for this function:<p><center><img src="protocol_8c_a18_cgraph.png" border="0" usemap="#protocol_8c_a18_cgraph_map" alt=""></center>
<map name="protocol_8c_a18_cgraph_map">
<area href="protocol_8h.html#a96" shape="rect" coords="861,143,1016,170" alt="">
<area href="protocol_8h.html#a95" shape="rect" coords="869,422,1008,449" alt="">
<area href="protocol_8c.html#a22" shape="rect" coords="196,447,329,474" alt="">
<area href="protocol_8c.html#a23" shape="rect" coords="642,270,800,297" alt="">
<area href="protocol_8c.html#a16" shape="rect" coords="220,270,305,297" alt="">
<area href="protocol_8c.html#a17" shape="rect" coords="420,118,540,145" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="378,321,581,347" alt="">
<area href="protocol_8c.html#a27" shape="rect" coords="405,270,554,297" alt="">
<area href="protocol_8c.html#a26" shape="rect" coords="630,67,812,94" alt="">
</map>
<a class="anchor" name="a19" doxytag="protocol.c::protocol_calc_ck_sum"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -