⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ethernet_8c-source.html

📁 Freescale mcu OpenTCP-1.0.4.doc.html.zip 文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00238  00239 }00240 <a name="l00252"></a><a class="code" href="ethernet_8c.html#a10">00252</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a10">inNE2000againbuf</a> (UINT8* buf, UINT16 len)00253 {00254         <span class="keywordflow">while</span>(len--)00255         {00256                 <a class="code" href="config_8h.html#a7">IOR</a> = 0;00257                 <span class="keywordflow">while</span>(<a class="code" href="config_8h.html#a8">IOCHRDY</a> == 0);            <span class="comment">/* Wait until bus free */</span>                               00258                 *buf++ = <a class="code" href="config_8h.html#a3">DATABUS</a>;00259                 <a class="code" href="config_8h.html#a7">IOR</a> = 1;        00260         }00261 }00262 <a name="l00274"></a><a class="code" href="ethernet_8c.html#a11">00274</a> UINT8 <a class="code" href="ethernet_8c.html#a11">NE2000CheckRxFrame</a> (<span class="keywordtype">void</span>)00275 {00276         <span class="comment">/* Checks to see if ethernet frame has been received */</span>00277         00278         UINT8 temp;00279         00280         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a> ,0x62);                   <span class="comment">/* page 1, abort DMA */</span>00281         temp = <a class="code" href="ethernet_8c.html#a8">inNE2000</a>( <a class="code" href="ethernet_8h.html#a29">CURR</a> );00282         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x02 );                  <span class="comment">/* page 0 */</span>00283         00284         <span class="keywordflow">if</span>( temp != <a class="code" href="ethernet_8c.html#a8">inNE2000</a>( <a class="code" href="ethernet_8h.html#a9">BOUNDARY</a> ) ) {00285                 <span class="comment">/* Boundary != Current =&gt; packet exists */</span>00286                 00287                 <span class="comment">/* Check still for receive status       */</span>00288                 <span class="keywordflow">if</span>(<a class="code" href="ethernet_8c.html#a8">inNE2000</a>(<a class="code" href="ethernet_8h.html#a19">RCR</a>) &amp; 0x01)00289                         <span class="keywordflow">return</span>(TRUE);00290 00291         }       00292         00293         <span class="keywordflow">return</span>(FALSE); 00294 }00295 <a name="l00304"></a><a class="code" href="ethernet_8c.html#a12">00304</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a12">NE2000DumpRxFrame</a> (<span class="keywordtype">void</span>)00305 {00306  00307         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x22 );                  <span class="comment">/* page0, abort DMA */</span>00308         00309         <span class="comment">/* Set boundary to start of next packet */</span>00310         00311         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a9">BOUNDARY</a>, <a class="code" href="ethernet_8c.html#a0">NE2000NextPktPtr</a> );        00312 00313  00314 }00315  00316  <a name="l00327"></a><a class="code" href="ethernet_8c.html#a1">00327</a> <span class="keywordtype">void</span> <a class="code" href="ethernet_8c.html#a1">NE2000Init</a> (UINT8* mac)00328 {00329 00330         <span class="comment">/* Give HW Reset        */</span>00331         00332         <a class="code" href="config_8h.html#a9">RESETPIN_NE2000</a> = 1;00333         wait(10000);00334         <a class="code" href="config_8h.html#a9">RESETPIN_NE2000</a> = 0;00335         wait(10000);00336         00337         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( RESETPORT, 0 );              <span class="comment">/* reset NE2000*/</span>00338         <span class="comment">/* Wait for a while */</span>00339         00340         wait(30000);00341 00342         00343         <span class="comment">/* Goto page 3 and set registers */</span>00344         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0xC1 );                  <span class="comment">/* page3, stop */</span>00345         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( 0x01, 0xC0 );                <span class="comment">/* config reg. write enble */</span>00346         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( 0x05, 0 );                   <span class="comment">/* link test enable */</span>00347         <span class="comment">/* outNE2000( 0x06, 0x70 );             //Full duplex, leds */</span>00348         00349         <span class="comment">/* Goto page 1 and set registers */</span>00350         00351         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x41 );                                                          <span class="comment">/* page1, stop */</span>00352         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( PAR5, *mac++);                       <span class="comment">/* Set MAC Address  */</span>00353         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( PAR4, *mac++);00354         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( PAR3, *mac++);00355         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( PAR2, *mac++);00356         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( PAR1, *mac++);00357         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a23">PAR0</a>, *mac); 00358         00359         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a29">CURR</a>, <a class="code" href="ethernet_8h.html#a33">RXBUF_START</a> ); <span class="comment">/* Current address */</span>00360         <a class="code" href="ethernet_8c.html#a0">NE2000NextPktPtr</a> = <a class="code" href="ethernet_8h.html#a33">RXBUF_START</a>;00361         <a class="code" href="ethernet_8c.html#a1">NE2000CurrPktPtr</a> = <a class="code" href="ethernet_8h.html#a33">RXBUF_START</a>;00362         00363         <span class="comment">/* Goto page 0 and set registers */</span>00364         00365         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0 );                                             <span class="comment">/* page0, Stop */</span>00366         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a7">PSTART</a>, <a class="code" href="ethernet_8h.html#a33">RXBUF_START</a>);                <span class="comment">/* Rx buffer start address */</span>00367         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a8">PSTOP</a>, <a class="code" href="ethernet_8h.html#a34">RXBUF_END</a> );                  <span class="comment">/* Rx buffer end address */</span>00368         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a9">BOUNDARY</a>, <a class="code" href="ethernet_8h.html#a33">RXBUF_START</a> );             <span class="comment">/* Boundary */</span>00369         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a14">ISR</a>, 0xFF );                                 <span class="comment">/* Interrupt services */</span>00370         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a19">RCR</a>, 0xC4);                                  <span class="comment">/* Rx config (Accept all), was C4 */</span>00371         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a20">TCR</a>, 0xE0);                                  <span class="comment">/* Tx config */</span>00372         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a21">DCR</a>, 0xB8);                                  <span class="comment">/* Dataconfig */</span>00373         00374         <span class="comment">/* Start action ! */</span>00375         00376         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x22 );                   <span class="comment">/* Page0, start */</span>00377         00378 }00379 00380 <a name="l00393"></a><a class="code" href="ethernet_8c.html#a1">00393</a> <span class="keywordtype">void</span> <a class="code" href="group__periodic__functions.html#a1">NE2000CheckOverFlow</a> (<span class="keywordtype">void</span>)00394 {00395         <span class="comment">/* Checks if Receive Buffer overflow has happened */</span>00396         <span class="comment">/* and re-initializes the NIC if needed                   */</span>00397         00398         UINT8 temp;00399 00400         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x22 );                  <span class="comment">/* page0, abort DMA */</span>00401 00402         <span class="keywordflow">if</span>( <a class="code" href="ethernet_8c.html#a8">inNE2000</a>( <a class="code" href="ethernet_8h.html#a14">ISR</a> ) &amp; 0x10 ) {00403         00404                 <span class="comment">/* OverFlow occured!! */</span>00405         00406                 <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a6">CR</a>, 0x21 );          <span class="comment">/* Issue Stop-command           */</span>00407  00408                 <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a17">RBCR0</a>, 0x00 );       <span class="comment">/* Clear remote Byte Count      */</span>00409                 <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( RBCR1, 0x00 );00410         00411                 <span class="comment">/* Poll the interrupt status register for RST bit */</span>00412         00413                 kick_WD();00414                 <span class="keywordflow">while</span>( ( <a class="code" href="ethernet_8c.html#a8">inNE2000</a>( <a class="code" href="ethernet_8h.html#a14">ISR</a> ) &amp; 0x80 ) == 0 );00415 00416                 <span class="comment">/* RST was set, NIC is in Stop mode     */</span>00417                 <span class="comment">/* Enter to LOOPBACK mode now           */</span>00418         00419                 <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a20">TCR</a>, 0x02 );00420         00421                 <span class="comment">/* Issue Start Command                                                  */</span>00422                 <span class="comment">/* NIC is still inactive because LOOPBACK on    */</span>00423         00424                 <a class="code" href="ethernet_8c.html#a5">outNE2000</a>(<a class="code" href="ethernet_8h.html#a6">CR</a>,0x22);00425         00426                 <span class="comment">/* Remove Packet from buffer */</span>00427         00428                 <span class="keywordflow">if</span>(<a class="code" href="ethernet_8c.html#a8">inNE2000</a>(<a class="code" href="ethernet_8h.html#a9">BOUNDARY</a>) != <a class="code" href="ethernet_8c.html#a0">NE2000NextPktPtr</a>) {00429                         ETH_DEBUGOUT(<span class="stringliteral">"\r\n*********Normal Overflow**********\r\n"</span>);00430                         <a class="code" href="ethernet_8c.html#a5">outNE2000</a>( <a class="code" href="ethernet_8h.html#a9">BOUNDARY</a>, <a class="code" href="ethernet_8c.html#a0">NE2000NextPktPtr</a> );00431                 } <span class="keywordflow">else</span> {00432                         <span class="comment">/* There has been an overflow after we have received the packet */</span>00433                         <span class="comment">/* last time                                                                                                    */</span>00434                 00435                         ETH_DEBUGOUT(<span class="stringliteral">"???????????????????????????????????\r\n"</span>);00436                         ETH_DEBUGOUT(<span class="stringliteral">"Unrecognized overflow!!\r\n"</span>);00437                         ETH_DEBUGOUT(<span class="stringliteral">"いいいいいいいいいいいいいいいいい

⌨️ 快捷键说明

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