日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于51單片機(jī)RTL8019AS的網(wǎng)卡驅(qū)動(dòng)程序

          基于51單片機(jī)RTL8019AS的網(wǎng)卡驅(qū)動(dòng)程序

          作者: 時(shí)間:2012-01-20 來(lái)源:網(wǎng)絡(luò) 收藏

           }

          本文引用地址:http://yuyingmama.com.cn/article/172229.htm

            if(txd_buffer_select) reg04=0x40; //txd packet start;

            else reg04=0x46; //txd packet start;

            reg06=length>>8; //high byte counter

            reg05=length0xFF; //low byte counter

            reg00=0x3E; //to sendpacket;

            }

            bit recv_packet(union netcard *rxdnet)//ne2000收包子程序

            {

            unsigned char i;

            unsigned int ii;

            unsigned char bnry,curr;

            page(0);

            reg07=0xFF;

            bnry=reg03; //bnry page have read 讀頁(yè)指針

            page(1);

            curr=reg07; //curr writepoint 8019寫(xiě)頁(yè)指針

            page(0);

            if(curr==0)

            return 0; //讀的過(guò)程出錯(cuò)

            bnry=bnry++;

            if(bnry>0x7F) bnry=0x4C;

            if(bnry!=curr){ //此時(shí)表示有新的數(shù)據(jù)包在緩沖區(qū)里

            //讀取一包的前18個(gè)字節(jié):4字節(jié)的8019頭部,6字節(jié)目的地址,6字節(jié)原地址,2字節(jié)協(xié)議

            //在任何操作都最好返回page0

            page(0);

            reg09=bnry; //read page address high

            reg08=0x00; //read page address low

            reg0b=0x00; //read count high

            reg0a=18; //read count low;

            reg00=0x0A; //read dma

            for(i=0;i18;i++)

            rxdnet->bytes.bytebuf[i]=reg10;

            i=rxdnet->bytes.bytebuf[3]; //將長(zhǎng)度字段的高低字節(jié)掉轉(zhuǎn)

            rxdnet->bytes.bytebuf[3]=rxdnet->bytes.bytebuf[2];

            rxdnet->bytes.bytebuf[2]=i;

            rxdnet->etherframe.length=rxdnet->etherframe.length-4; //去掉4個(gè)字節(jié)的CRC

            //表示讀入的數(shù)據(jù)包有效

            if(((rxdnet->bytes.bytebuf[0]0x01)==0)||(rxdnet->bytes.bytebuf[1]>0x7F)||(rxdnet->bytes.bytebuf[1]0x4C)||(rxdnet->bytes.bytebuf[2]>0x06)){

            //接收狀態(tài)錯(cuò)誤,或者next_page_start錯(cuò)誤或者長(zhǎng)度錯(cuò)誤,將丟棄所有數(shù)據(jù)包

            page(1);

            curr=reg07; //page1

            page(0); //切換回page0

            bnry=curr-1;

            if(bnry0x4C) bnry=0x7F;

            reg03=bnry; //write to bnry

            return 0;

            }

            else{//表示數(shù)據(jù)包是完好的.讀取剩下的數(shù)據(jù)

            if((rxdnet->etherframe.protocal==0x0800)||(rxdnet->etherframe.protocal==0x0806)){

            //協(xié)議為IP或ARP才接收

            reg09=bnry; //read page address high

            reg08=4; //read page address low

            reg0b=rxdnet->etherframe.length>>8; //read count high

            reg0a=rxdnet->etherframe.length0xFF; //read count low;

            reg00=0x0A; //read dma

            for(ii=4;iietherframe.length+4;ii++)

            rxdnet->bytes.bytebuf[ii]=reg10;

            }

            bnry=rxdnet->bytes.bytebuf[1]-1;//next page start-1

            if(bnry0x4C) bnry=0x7F;

            reg03=bnry; //write to bnry

            return 1; //have new packet

            }

            }

            return 0;

            }


          上一頁(yè) 1 2 3 4 下一頁(yè)

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉