📄 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 Master 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#a16">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#a17">protocol_set_role_master</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#a18">master_ping_mode</a> (<a class="el" href="cypdef_8h.html#a1">UINT8</a> reason)</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">master_bind_mode</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#a20">master_data_mode</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#a21">master_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#a22">master_is_tx_buffer_empty</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">master_read_rx_packet</a> (<a class="el" href="cypdef_8h.html#a1">UINT8</a> *data_ptr, <a class="el" href="cypdef_8h.html#a1">UINT8</a> num_bytes)</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#a24">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#a25">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#a26">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#a27">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#a28">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#a29">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#a30">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#a31">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#a32">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#a33">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">master_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">rssi_counter</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#a13">rssi_checked</a> = FALSE</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">app_rx_length</a></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#a15">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="a16" 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_a16_cgraph.png" border="0" usemap="#protocol_8c_a16_cgraph_map" alt=""></center>
<map name="protocol_8c_a16_cgraph_map">
<area href="protocol_8c.html#a17" shape="rect" coords="152,84,325,110" alt="">
<area href="protocol_8h.html#a105" shape="rect" coords="374,84,510,110" alt="">
<area href="protocol_8c.html#a31" shape="rect" coords="561,8,742,34" alt="">
<area href="protocol_8c.html#a32" shape="rect" coords="577,58,726,85" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="573,109,730,136" alt="">
<area href="timer_8h.html#a13" shape="rect" coords="573,160,730,186" alt="">
</map>
<a class="anchor" name="a17" doxytag="protocol.c::protocol_set_role_master"></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_master </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 <a class="el" href="protocol_8c.html#a18">master_ping_mode()</a> 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_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#a105" shape="rect" coords="230,83,366,110" alt="">
<area href="protocol_8c.html#a31" shape="rect" coords="417,7,598,34" alt="">
<area href="protocol_8c.html#a32" shape="rect" coords="433,58,582,85" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="429,109,586,135" alt="">
<area href="timer_8h.html#a13" shape="rect" coords="429,159,586,186" alt="">
<area href="protocol_8h.html#a99" shape="rect" coords="648,58,802,85" alt="">
<area href="protocol_8h.html#a98" shape="rect" coords="656,109,794,135" alt="">
<area href="timer_8c.html#a5" shape="rect" coords="668,159,782,186" alt="">
<area href="timer_8c.html#a4" shape="rect" coords="669,210,781,237" alt="">
</map>
<a class="anchor" name="a18" doxytag="protocol.c::master_ping_mode"></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> master_ping_mode </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>reason</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: Sets the channel/pn_code and parameters for the ping, transmits a ping packet and turns on receive mode to receive the acknowledge, checks RSSI and resets it along with the corrupt counter<p>
Inputs:<ul>
<li>reason - to check if we need to start with the top channel</li></ul>
<p>
Returns:<ul>
<li>LS_STATUS_SUCCESS - Successful ping </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_8c.html#a31" shape="rect" coords="195,7,377,34" alt="">
<area href="protocol_8c.html#a32" shape="rect" coords="211,58,361,85" alt="">
<area href="protocol_8c.html#a28" shape="rect" coords="207,109,365,135" alt="">
<area href="timer_8h.html#a13" shape="rect" coords="207,159,365,186" alt="">
<area href="protocol_8h.html#a99" shape="rect" coords="426,58,581,85" alt="">
<area href="protocol_8h.html#a98" shape="rect" coords="434,109,573,135" alt="">
<area href="timer_8c.html#a5" shape="rect" coords="446,159,561,186" alt="">
<area href="timer_8c.html#a4" shape="rect" coords="447,210,559,237" alt="">
</map>
<a class="anchor" name="a19" doxytag="protocol.c::master_bind_mode"></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> master_bind_mode </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: Initially sets the PN code. Continuously sets the channel, looks for a bind request, formats and transmits the bind packet, sets up to receive an acknowledge. Upon a good acknowledge, it binds to the device and returns. It checks for a timeout, and if it occurs then it will return. Before any return it goes into ping mode<p>
Inputs: Void<p>
Returns:<ul>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -