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

📄 rtl8019.lst

📁 我的网口控制程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 162   1              else
 163   1                      InSending = TRUE;
 164   1              /* store page */
 165   1              PrePage = ReadReg(CR);
 166   1              
 167   1              /* check pakcet size */
 168   1              if(size < MIN_PACKET_SIZE)
 169   1              {
 170   2                      size = MIN_PACKET_SIZE;
 171   2              }
 172   1              else
 173   1              {
 174   2                      if(size > MAX_PACKET_SIZE)
 175   2                              size = MAX_PACKET_SIZE;
 176   2              }
 177   1      
C51 COMPILER V7.06   RTL8019                                                               11/06/2008 08:54:11 PAGE 4   

 178   1              /* write packet to ram */
 179   1              if(LastSendStartPage == SEND_START_PAGE0)
 180   1              {
 181   2                      StartPage = SEND_START_PAGE1;
 182   2                      LastSendStartPage = SEND_START_PAGE1;
 183   2              }
 184   1              else
 185   1              {
 186   2                      StartPage = SEND_START_PAGE0;
 187   2                      LastSendStartPage = SEND_START_PAGE0;
 188   2              }
 189   1              RTLWriteRam((WORD)(((WORD)StartPage)<<8),size,buffer);
 190   1              
 191   1              /* wait for last time trasmition to complete */
 192   1              while((ReadReg(CR) & CR_TXP) == CR_TXP);
 193   1      
 194   1              /* write trasmit start page and size */
 195   1              RTLPage(0);
 196   1              WriteReg(TPSR_WPAGE0,StartPage);        /* TPSR */                              
 197   1              WriteReg(TBCRL_WPAGE0,(BYTE)size);/*low */                                      
 198   1              WriteReg(TBCRH_WPAGE0,(BYTE)((size>>8)&0x00ff));        /*high*/
 199   1              WriteReg(CR,((PrePage&0xC0) | CR_ABORT_COMPLETE_DMA | CR_TXP | CR_START_COMMAND));              
 200   1              
 201   1              InSending = FALSE;
 202   1              return TRUE;
 203   1      }
 204          
 205          /* call this function to receive a ethernet packet from RTL8019. 
 206          return value: 
 207                  NULL: no packet can receive yet. 
 208                  not NULL: 
 209                          a address point to MemHead. This Head contain merory 
 210                          Imformation(memory start address, memory end address ...) of 
 211                          received packet. Memory is allocated by function 'MemAllocate(WORD size)'.
 212                          a example of struct SMemHead is:
 213          
 214                          struct SMemHead
 215                          {
 216                                  BOOL used;                                              // if in using 
 217                                  BYTE DT_XDATA *pStart;                  // the start address of memory 
 218                                  BYTE DT_XDATA *pEnd;
 219                          };
 220                          
 221                          You can use your own struct SMemHead and MemAllocat function in your project.           
 222          */
 223          struct SMemHead DT_XDATA * RTLReceivePacket() REENTRANT_SIG
 224          {
 225   1              BYTE curr,bnry;
 226   1              WORD address;
 227   1              WORD PacketSize;
 228   1              struct SMemHead DT_XDATA *MemHead;
 229   1      
 230   1              /* if send is running don't crrupt RTL register*/
 231   1              if(InSending == TRUE)
 232   1                      return NULL;
 233   1      
 234   1              MemHead = NULL;
 235   1      
 236   1              RTLPage(1);
 237   1              curr = ReadReg(CURR_RPAGE1);
 238   1              RTLPage(0);
 239   1      
C51 COMPILER V7.06   RTL8019                                                               11/06/2008 08:54:11 PAGE 5   

 240   1              /* check if startpage exceed range becasue of unknow error */
 241   1              if(StartPageOfPacket >= RECEIVE_STOP_PAGE || StartPageOfPacket < RECEIVE_START_PAGE)
 242   1              {
 243   2                      /* use curr as the StartPageOfPacket in this case */
 244   2                      StartPageOfPacket = curr;
 245   2                      return NULL;
 246   2              }
 247   1              
 248   1              /* check if there is packets to read */
 249   1              if(StartPageOfPacket == curr)
 250   1                      return NULL;
 251   1      
 252   1              /* 
 253   1               * read a packet 
 254   1               */
 255   1      
 256   1              /* read packet head imformation */
 257   1              address = ((WORD)StartPageOfPacket)<<8;
 258   1              RTLReadRam(address,4,Head);
 259   1      
 260   1              /* check rsr, if isn't a good packet no read */
 261   1              if(Head[0] & RSR_RECEIVE_NO_ERROR)
 262   1              {
 263   2                      /* this is a good packet */
 264   2      
 265   2                      /* packet size, sub 4 bytes, this 4 byte is MAC checksum */
 266   2                      PacketSize = ((WORD)Head[3])*256 + Head[2] - 4; 
 267   2      
 268   2                      /* allocate buffer and read packet into buffer */
 269   2                      if((MemHead = MemAllocate(PacketSize)) != NULL)
 270   2                      {       
 271   3                              /* if packet is put from bnry+1 to receive_stop_page and receive
 272   3                                 start page to next packet startpage, that is if bnry+1 > next
 273   3                                 packet start page and next start page != receive_start_page, 
 274   3                                 we need read by two times. the first time from bnry+1 to receive
 275   3                                 _stop_page, the second time from receive start page to next packet
 276   3                                 startpage.
 277   3                              */
 278   3                              address += 4;
 279   3                              if(StartPageOfPacket > Head[1] && Head[1] != RECEIVE_START_PAGE)
 280   3                              {
 281   4                                      RTLReadRam(address,(WORD)((((WORD)RECEIVE_STOP_PAGE)<<8) - address),MemHead->pStart);   /* read from rtl
             - */
 282   4                                      RTLReadRam((WORD)(((WORD)RECEIVE_START_PAGE)<<8),(WORD)(PacketSize - ((((WORD)RECEIVE_STOP_PAGE)<<8) -
             - address)),
 283   4                                              MemHead->pStart + ((((WORD)RECEIVE_STOP_PAGE)<<8) - address));  /* read from rtl */
 284   4                              }
 285   3                              else
 286   3                              {
 287   4                                      RTLReadRam(address,PacketSize,MemHead->pStart); /* read from rtl */
 288   4                              }
 289   3                              
 290   3                      }
 291   2              }
 292   1              
 293   1              /* get next packet start page */
 294   1              StartPageOfPacket = Head[1];
 295   1      
 296   1              /* reset bnry */
 297   1              bnry = StartPageOfPacket - 1;
 298   1              if(bnry < RECEIVE_START_PAGE)
 299   1                      bnry = RECEIVE_STOP_PAGE - 1;
C51 COMPILER V7.06   RTL8019                                                               11/06/2008 08:54:11 PAGE 6   

 300   1              WriteReg(BNRY_WPAGE0,bnry);
 301   1      
 302   1              return MemHead;
 303   1      }
 304          
 305          /*void Start8019()
 306          {
 307                  WriteReg(CR,CR_ABORT_COMPLETE_DMA | CR_START_COMMAND);
 308          }
 309          
 310          void Stop8019()
 311          {
 312                  WriteReg(CR,CR_ABORT_COMPLETE_DMA | CR_STOP_COMMAND);
 313          }*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1119    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      7    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       4
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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