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

📄 rtl8019.lst

📁 51单片机实现网页显示功能
💻 LST
📖 第 1 页 / 共 2 页
字号:
 176   1              WriteReg(RBCRL_WPAGE0,0);
 177   1              WriteReg(CR,((PrePage&0xC0) | CR_ABORT_COMPLETE_DMA | CR_START_COMMAND));
C51 COMPILER V7.06   RTL8019                                                               11/26/2007 20:40:53 PAGE 4   

 178   1      }
 179          /* call this function to send a packet by RTL8019. packet store in ram
 180          starts at 'buffer' and its size is 'size'. 'size' should not large than
 181          MAX_PACKET_SIZE or the excess data will be discard. */
 182          BOOL RTLSendPacket(BYTE DT_XDATA * buffer,WORD size) REENTRANT_SIG
 183          {
 184   1              BYTE StartPage;
 185   1              BYTE PrePage;
 186   1              
 187   1              /* if send is already running */
 188   1              if(InSending == TRUE)
 189   1                      return FALSE;
 190   1              else
 191   1                      InSending = TRUE;
 192   1              /* store page */
 193   1              PrePage = ReadReg(CR);
 194   1              
 195   1              /* check pakcet size */
 196   1              if(size < MIN_PACKET_SIZE)
 197   1              {
 198   2                      size = MIN_PACKET_SIZE;
 199   2              }
 200   1              else
 201   1              {
 202   2                      if(size > MAX_PACKET_SIZE)
 203   2                              size = MAX_PACKET_SIZE;
 204   2              }
 205   1      
 206   1              /* write packet to ram */
 207   1              if(LastSendStartPage == SEND_START_PAGE0)
 208   1              {
 209   2                      StartPage = SEND_START_PAGE1;
 210   2                      LastSendStartPage = SEND_START_PAGE1;
 211   2              }
 212   1              else
 213   1              {
 214   2                      StartPage = SEND_START_PAGE0;
 215   2                      LastSendStartPage = SEND_START_PAGE0;
 216   2              }
 217   1              RTLWriteRam((WORD)(((WORD)StartPage)<<8),size,buffer);
 218   1              
 219   1              /* wait for last time trasmition to complete */
 220   1              while((ReadReg(CR) & CR_TXP) == CR_TXP);
 221   1      
 222   1              /* write trasmit start page and size */
 223   1              RTLPage(0);
 224   1              WriteReg(TPSR_WPAGE0,StartPage);        /* TPSR */                              
 225   1              WriteReg(TBCRL_WPAGE0,(BYTE)size);/*low */                                      
 226   1              WriteReg(TBCRH_WPAGE0,(BYTE)((size>>8)&0x00ff));        /*high*/
 227   1              WriteReg(CR,((PrePage&0xC0) | CR_ABORT_COMPLETE_DMA | CR_TXP | CR_START_COMMAND));              
 228   1              
 229   1              InSending = FALSE;
 230   1              return TRUE;
 231   1      }
 232          
 233          /* call this function to receive a ethernet packet from RTL8019. 
 234          return value: 
 235                  NULL: no packet can receive yet. 
 236                  not NULL: 
 237                          a address point to MemHead. This Head contain merory 
 238                          Imformation(memory start address, memory end address ...) of 
 239                          received packet. Memory is allocated by function 'MemAllocate(WORD size)'.
C51 COMPILER V7.06   RTL8019                                                               11/26/2007 20:40:53 PAGE 5   

 240                          a example of struct SMemHead is:
 241          
 242                          struct SMemHead
 243                          {
 244                                  BOOL used;                                              // if in using 
 245                                  BYTE DT_XDATA *pStart;                  // the start address of memory 
 246                                  BYTE DT_XDATA *pEnd;
 247                          };
 248                          
 249                          You can use your own struct SMemHead and MemAllocat function in your project.           
 250          */
 251          struct SMemHead DT_XDATA * RTLReceivePacket() REENTRANT_SIG
 252          {
 253   1              BYTE curr,bnry;
 254   1              WORD address;
 255   1              WORD PacketSize;
 256   1              struct SMemHead DT_XDATA *MemHead;
 257   1      
 258   1              /* if send is running don't crrupt RTL register*/
 259   1              if(InSending == TRUE)
 260   1                      return NULL;
 261   1      
 262   1              MemHead = NULL;
 263   1      
 264   1              RTLPage(1);
 265   1              curr = ReadReg(CURR_RPAGE1);
 266   1              RTLPage(0);
 267   1      
 268   1              /* check if startpage exceed range becasue of unknow error */
 269   1              if(StartPageOfPacket >= RECEIVE_STOP_PAGE || StartPageOfPacket < RECEIVE_START_PAGE)
 270   1              {
 271   2                      /* use curr as the StartPageOfPacket in this case */
 272   2                      StartPageOfPacket = curr;
 273   2                      return NULL;
 274   2              }
 275   1              
 276   1              /* check if there is packets to read */
 277   1              if(StartPageOfPacket == curr)
 278   1                      return NULL;
 279   1      
 280   1              /* 
 281   1               * read a packet 
 282   1               */
 283   1      
 284   1              /* read packet head imformation */
 285   1              address = ((WORD)StartPageOfPacket)<<8;
 286   1              RTLReadRam(address,4,Head);
 287   1      
 288   1              /* check rsr, if isn't a good packet no read */
 289   1              if(Head[0] & RSR_RECEIVE_NO_ERROR)
 290   1              {
 291   2                      /* this is a good packet */
 292   2      
 293   2                      /* packet size, sub 4 bytes, this 4 byte is MAC checksum */
 294   2                      PacketSize = ((WORD)Head[3])*256 + Head[2] - 4; 
 295   2      
 296   2                      /* allocate buffer and read packet into buffer */
 297   2                      if((MemHead = MemAllocate(PacketSize)) != NULL)
 298   2                      {       
 299   3                              /* if packet is put from bnry+1 to receive_stop_page and receive
 300   3                                 start page to next packet startpage, that is if bnry+1 > next
 301   3                                 packet start page and next start page != receive_start_page, 
C51 COMPILER V7.06   RTL8019                                                               11/26/2007 20:40:53 PAGE 6   

 302   3                                 we need read by two times. the first time from bnry+1 to receive
 303   3                                 _stop_page, the second time from receive start page to next packet
 304   3                                 startpage.
 305   3                              */
 306   3                              address += 4;
 307   3                              if(StartPageOfPacket > Head[1] && Head[1] != RECEIVE_START_PAGE)
 308   3                              {
 309   4                                      RTLReadRam(address,(WORD)((((WORD)RECEIVE_STOP_PAGE)<<8) - address),MemHead->pStart);   /* read from rtl
             - */
 310   4                                      RTLReadRam((WORD)(((WORD)RECEIVE_START_PAGE)<<8),(WORD)(PacketSize - ((((WORD)RECEIVE_STOP_PAGE)<<8) -
             - address)),
 311   4                                              MemHead->pStart + ((((WORD)RECEIVE_STOP_PAGE)<<8) - address));  /* read from rtl */
 312   4                              }
 313   3                              else
 314   3                              {
 315   4                                      RTLReadRam(address,PacketSize,MemHead->pStart); /* read from rtl */
 316   4                              }
 317   3                              
 318   3                      }
 319   2              }
 320   1              
 321   1              /* get next packet start page */
 322   1              StartPageOfPacket = Head[1];
 323   1      
 324   1              /* reset bnry */
 325   1              bnry = StartPageOfPacket - 1;
 326   1              if(bnry < RECEIVE_START_PAGE)
 327   1                      bnry = RECEIVE_STOP_PAGE - 1;
 328   1              WriteReg(BNRY_WPAGE0,bnry);
 329   1      
 330   1              return MemHead;
 331   1      }
 332          
 333          /*void Start8019()
 334          {
 335                  WriteReg(CR,CR_ABORT_COMPLETE_DMA | CR_START_COMMAND);
 336          }
 337          
 338          void Stop8019()
 339          {
 340                  WriteReg(CR,CR_ABORT_COMPLETE_DMA | CR_STOP_COMMAND);
 341          }*/


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 + -