📄 ethernet_8c-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>/opentcp/ethernet.c Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="main.html">Main Page</a> <a class="qindex" href="modules.html">Modules</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> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindex" href="examples.html">Examples</a> </center><hr><h1>/opentcp/ethernet.c</h1><a href="ethernet_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> *Copyright (c) 2000-2002 Viola Systems Ltd.</span>00003 <span class="comment"> *All rights reserved.</span>00004 <span class="comment"> *</span>00005 <span class="comment"> *Redistribution and use in source and binary forms, with or without </span>00006 <span class="comment"> *modification, are permitted provided that the following conditions </span>00007 <span class="comment"> *are met:</span>00008 <span class="comment"> *</span>00009 <span class="comment"> *1. Redistributions of source code must retain the above copyright </span>00010 <span class="comment"> *notice, this list of conditions and the following disclaimer.</span>00011 <span class="comment"> *</span>00012 <span class="comment"> *2. Redistributions in binary form must reproduce the above copyright </span>00013 <span class="comment"> *notice, this list of conditions and the following disclaimer in the </span>00014 <span class="comment"> *documentation and/or other materials provided with the distribution.</span>00015 <span class="comment"> *</span>00016 <span class="comment"> *3. The end-user documentation included with the redistribution, if </span>00017 <span class="comment"> *any, must include the following acknowledgment:</span>00018 <span class="comment"> * "This product includes software developed by Viola </span>00019 <span class="comment"> * Systems (http://www.violasystems.com/)."</span>00020 <span class="comment"> *</span>00021 <span class="comment"> *Alternately, this acknowledgment may appear in the software itself, </span>00022 <span class="comment"> *if and wherever such third-party acknowledgments normally appear.</span>00023 <span class="comment"> *</span>00024 <span class="comment"> *4. The names "OpenTCP" and "Viola Systems" must not be used to </span>00025 <span class="comment"> *endorse or promote products derived from this software without prior </span>00026 <span class="comment"> *written permission. For written permission, please contact </span>00027 <span class="comment"> *opentcp@opentcp.org.</span>00028 <span class="comment"> *</span>00029 <span class="comment"> *5. Products derived from this software may not be called "OpenTCP", </span>00030 <span class="comment"> *nor may "OpenTCP" appear in their name, without prior written </span>00031 <span class="comment"> *permission of the Viola Systems Ltd.</span>00032 <span class="comment"> *</span>00033 <span class="comment"> *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED </span>00034 <span class="comment"> *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF </span>00035 <span class="comment"> *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. </span>00036 <span class="comment"> *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE </span>00037 <span class="comment"> *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR </span>00038 <span class="comment"> *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF </span>00039 <span class="comment"> *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR </span>00040 <span class="comment"> *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, </span>00041 <span class="comment"> *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE </span>00042 <span class="comment"> *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, </span>00043 <span class="comment"> *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>00044 <span class="comment"> *====================================================================</span>00045 <span class="comment"> *</span>00046 <span class="comment"> *OpenTCP is the unified open source TCP/IP stack available on a series </span>00047 <span class="comment"> *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.</span>00048 <span class="comment"> *</span>00049 <span class="comment"> *For more information on how to network-enable your devices, or how to </span>00050 <span class="comment"> *obtain commercial technical support for OpenTCP, please see </span>00051 <span class="comment"> *<http://www.violasystems.com/>.</span>00052 <span class="comment"> */</span>00053 00071 <span class="preprocessor">#include <<a class="code" href="debug_8h.html">inet/debug.h</a>></span>00072 <span class="preprocessor">#include <<a class="code" href="datatypes_8h.html">inet/datatypes.h</a>></span>00073 <span class="preprocessor">#include <<a class="code" href="system_8h.html">inet/system.h</a>></span>00074 <span class="preprocessor">#include <<a class="code" href="ethernet_8h.html">inet/ethernet.h</a>></span>00075 00076 00077 <span class="preprocessor">#include <<a class="code" href="config_8h.html">inet/arch/config.h</a>></span>00078 <a name="l00079"></a><a class="code" href="ethernet_8c.html#a0">00079</a> UINT8 <a class="code" href="ethernet_8c.html#a0">NE2000NextPktPtr</a>; <a name="l00080"></a><a class="code" href="ethernet_8c.html#a1">00080</a> UINT8 <a class="code" href="ethernet_8c.html#a1">NE2000CurrPktPtr</a>; <a name="l00082"></a><a class="code" href="ethernet_8c.html#a2">00082</a> UINT8 <a class="code" href="ethernet_8c.html#a2">EtherSleep</a> = 0; <a name="l00093"></a><a class="code" href="ethernet_8c.html#a3">00093</a> <span class="keyword">struct </span><a class="code" href="structethernet__frame.html">ethernet_frame</a> received_frame;00094 <a name="l00105"></a><a class="code" href="ethernet_8c.html#a4">00105</a> <span class="keyword">struct </span><a class="code" href="structethernet__frame.html">ethernet_frame</a> send_frame;00106 00107 <a name="l00118"></a><a class="code" href="ethernet_8c.html#a5">00118</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a5">outNE2000</a> (UINT8 reg , UINT8 dat)00119 {00120 00121 UINT8 temp = reg;00122 00123 <a class="code" href="config_8h.html#a4">DATADIR</a> = <a class="code" href="config_8h.html#a1">DDR_OUT</a>; <span class="comment">/* datapins = output */</span>00124 <a class="code" href="config_8h.html#a3">DATABUS</a> = dat; <span class="comment">/* data to bus */</span>00125 <a class="code" href="config_8h.html#a5">ADRBUS</a> = (temp | 0x60); <span class="comment">/* dont change R,W,Reset pins */</span>00126 00127 <span class="comment">/* Wait until bus free */</span>00128 00129 <a class="code" href="config_8h.html#a6">IOW</a> = 0; <span class="comment">/* do writestrobe */</span>00130 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0);00131 <a class="code" href="config_8h.html#a6">IOW</a> = 1;00132 00133 } 00134 <a name="l00148"></a><a class="code" href="ethernet_8c.html#a6">00148</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a6">outNE2000again</a> (UINT8 dat)00149 {00150 <span class="comment">/* Write data to same reg as outNE2000 before */</span>00151 00152 <a class="code" href="config_8h.html#a3">DATABUS</a> = dat;00153 00154 <span class="comment">/* Wait until bus free */</span>00155 00156 <a class="code" href="config_8h.html#a6">IOW</a> = 0; <span class="comment">/* do writestrobe */</span>00157 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0);00158 <a class="code" href="config_8h.html#a6">IOW</a> = 1;00159 }00160 <a name="l00175"></a><a class="code" href="ethernet_8c.html#a7">00175</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a7">outNE2000againbuf</a> (UINT8* buf, UINT16 len)00176 {00177 00178 <span class="keywordflow">while</span>(len--)00179 {00180 <a class="code" href="config_8h.html#a3">DATABUS</a> = *buf++;00181 <a class="code" href="config_8h.html#a6">IOW</a> = 0;00182 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0); <span class="comment">/* Wait until bus free */</span>00183 <a class="code" href="config_8h.html#a6">IOW</a> = 1;00184 }00185 }00186 00187 <a name="l00198"></a><a class="code" href="ethernet_8c.html#a8">00198</a> UINT8 <a class="code" href="ethernet_8c.html#a8">inNE2000</a> (UINT8 reg)00199 {00200 UINT8 temp = reg;00201 <a class="code" href="config_8h.html#a4">DATADIR</a> = <a class="code" href="config_8h.html#a2">DDR_IN</a>; <span class="comment">/* port input */</span>00202 <a class="code" href="config_8h.html#a5">ADRBUS</a> = (temp | 0x60);00203 00204 <span class="comment">/* Wait until bus free */</span>00205 00206 <a class="code" href="config_8h.html#a7">IOR</a> = 0; <span class="comment">/* do readstrobe */</span>00207 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0);00208 temp = <a class="code" href="config_8h.html#a3">DATABUS</a>;00209 <a class="code" href="config_8h.html#a7">IOR</a> = 1;00210 00211 <span class="keywordflow">return</span> temp;00212 }00213 <a name="l00226"></a><a class="code" href="ethernet_8c.html#a9">00226</a> UINT8 <a class="code" href="ethernet_8c.html#a9">inNE2000again</a> (<span class="keywordtype">void</span>)00227 {00228 UINT8 temp;00229 00230 <span class="comment">/* Wait until bus free */</span>00231 00232 <a class="code" href="config_8h.html#a7">IOR</a> = 0; 00233 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0);00234 temp = <a class="code" href="config_8h.html#a3">DATABUS</a>;00235 <a class="code" href="config_8h.html#a7">IOR</a> = 1;00236 00237 <span class="keywordflow">return</span>(temp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -