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

📄 vend_ax.lst

📁 USB芯片cy7c68013与AD转换芯片MAX115实现数据转换
💻 LST
📖 第 1 页 / 共 2 页
字号:
 300   2                              addr = SETUPDAT[2];             // Get address and length
 301   2                              addr |= SETUPDAT[3] << 8;
 302   2                              len = SETUPDAT[6];
 303   2                              len |= SETUPDAT[7] << 8;
C51 COMPILER V7.50   VEND_AX                                                               04/23/2009 15:18:28 PAGE 6   

 304   2                              // Is this an upload command ?
 305   2                              if(SETUPDAT[0] == VR_UPLOAD)
 306   2                              {
 307   3                                      while(len)                                      // Move requested data through EP0IN 
 308   3                                      {                                                       // one packet at a time.
 309   4      
 310   4                     while(EP0CS & bmEPBUSY);
 311   4      
 312   4                                              if(len < EP0BUFF_SIZE)
 313   4                                                      bc = len;
 314   4                                              else
 315   4                                                      bc = EP0BUFF_SIZE;
 316   4      
 317   4                                              // Is this a RAM upload ?
 318   4                                              if(SETUPDAT[1] == VR_RAM)
 319   4                                              {
 320   5                                                      for(i=0; i<bc; i++)
 321   5                                                              *(EP0BUF+i) = *((BYTE xdata *)addr+i);
 322   5                                              }
 323   4                                              else
 324   4                                              {
 325   5                                                      for(i=0; i<bc; i++)
 326   5                                                              *(EP0BUF+i) = 0xcd;
 327   5                                                      EEPROMRead(addr,(WORD)bc,(WORD)EP0BUF);
 328   5                                              }
 329   4      
 330   4                                              EP0BCH = 0;
 331   4                                              EP0BCL = (BYTE)bc; // Arm endpoint with # bytes to transfer
 332   4      
 333   4                                              addr += bc;
 334   4                                              len -= bc;
 335   4      
 336   4                                      }
 337   3                              }
 338   2                              // Is this a download command ?
 339   2                              else if(SETUPDAT[0] == VR_DOWNLOAD)
 340   2                              {
 341   3                                      while(len)                                      // Move new data through EP0OUT 
 342   3                                      {                                                       // one packet at a time.
 343   4                                              // Arm endpoint - do it here to clear (after sud avail)
 344   4                                              EP0BCH = 0;
 345   4                                              EP0BCL = 0; // Clear bytecount to allow new data in; also stops NAKing
 346   4      
 347   4                                              while(EP0CS & bmEPBUSY);
 348   4      
 349   4                                              bc = EP0BCL; // Get the new bytecount
 350   4      
 351   4                                              // Is this a RAM download ?
 352   4                                              if(SETUPDAT[1] == VR_RAM)
 353   4                                              {
 354   5                                                      for(i=0; i<bc; i++)
 355   5                                                               *((BYTE xdata *)addr+i) = *(EP0BUF+i);
 356   5                                              }
 357   4                                              else
 358   4                                                      EEPROMWrite(addr,bc,(WORD)EP0BUF);
 359   4      
 360   4                                              addr += bc;
 361   4                                              len -= bc;
 362   4                                      }
 363   3                              }
 364   2                              break;
 365   2              }
C51 COMPILER V7.50   VEND_AX                                                               04/23/2009 15:18:28 PAGE 7   

 366   1              return(FALSE); // no error; command handled OK
 367   1      }
 368          
 369          //-----------------------------------------------------------------------------
 370          // USB中断处理
 371          // 由USB中断跳转表调用
 372          //-----------------------------------------------------------------------------
 373          
 374          // 设置数据有效中断处理
 375          void ISR_Sudav(void) interrupt 0
 376          {
 377   1         // enable the automatic length feature of the Setup Data Autopointer
 378   1         // in case a previous transfer disbaled it
 379   1         SUDPTRCTL |= bmSDPAUTO;
 380   1      
 381   1         GotSUD = TRUE;            // 设置表志
 382   1         EZUSB_IRQ_CLEAR();
 383   1         USBIRQ = bmSUDAV;         // 清除SUDAV IRQ
 384   1      }
 385          
 386          // 设置令牌中断处理
 387          void ISR_Sutok(void) interrupt 0
 388          {
 389   1         EZUSB_IRQ_CLEAR();
 390   1         USBIRQ = bmSUTOK;         // 清除 SUTOK IRQ
 391   1      }
 392          
 393          void ISR_Sof(void) interrupt 0
 394          {
 395   1         EZUSB_IRQ_CLEAR();
 396   1         USBIRQ = bmSOF;            //清除 SOF IRQ
 397   1      }
 398          
 399          void ISR_Ures(void) interrupt 0
 400          {
 401   1         if (EZUSB_HIGHSPEED())
 402   1         {
 403   2            pConfigDscr = pHighSpeedConfigDscr;
 404   2            pOtherConfigDscr = pFullSpeedConfigDscr;
 405   2         }
 406   1         else
 407   1         {
 408   2            pConfigDscr = pFullSpeedConfigDscr;
 409   2            pOtherConfigDscr = pHighSpeedConfigDscr;
 410   2         }
 411   1         
 412   1         EZUSB_IRQ_CLEAR();
 413   1         USBIRQ = bmURES;         // 清除URES IRQ
 414   1      }
 415          
 416          void ISR_Susp(void) interrupt 0
 417          {
 418   1         Sleep = TRUE;
 419   1         EZUSB_IRQ_CLEAR();
 420   1         USBIRQ = bmSUSP;
 421   1      }
 422          
 423          void ISR_Highspeed(void) interrupt 0
 424          {
 425   1         if (EZUSB_HIGHSPEED())
 426   1         {
 427   2            pConfigDscr = pHighSpeedConfigDscr;
C51 COMPILER V7.50   VEND_AX                                                               04/23/2009 15:18:28 PAGE 8   

 428   2            pOtherConfigDscr = pFullSpeedConfigDscr;
 429   2         }
 430   1         else
 431   1         {
 432   2            pConfigDscr = pFullSpeedConfigDscr;
 433   2            pOtherConfigDscr = pHighSpeedConfigDscr;
 434   2         }
 435   1      
 436   1         EZUSB_IRQ_CLEAR();
 437   1         USBIRQ = bmHSGRANT;
 438   1      }
 439          
 440          void ISR_Ep0ack(void) interrupt 0
 441          {
 442   1      }
 443          void ISR_Stub(void) interrupt 0
 444          {
 445   1      }
 446          void ISR_Ep0in(void) interrupt 0
 447          {
 448   1      }
 449          void ISR_Ep0out(void) interrupt 0
 450          {
 451   1      }
 452          void ISR_Ep1in(void) interrupt 0
 453          {
 454   1      }
 455          void ISR_Ep1out(void) interrupt 0
 456          {
 457   1      }
 458          void ISR_Ep2inout(void) interrupt 0
 459          {
 460   1      }
 461          void ISR_Ep4inout(void) interrupt 0
 462          {
 463   1      }
 464          void ISR_Ep6inout(void) interrupt 0
 465          {
 466   1      }
 467          void ISR_Ep8inout(void) interrupt 0
 468          {
 469   1      }
 470          void ISR_Ibn(void) interrupt 0
 471          {
 472   1      }
 473          void ISR_Ep0pingnak(void) interrupt 0
 474          {
 475   1      }
 476          void ISR_Ep1pingnak(void) interrupt 0
 477          {
 478   1      }
 479          void ISR_Ep2pingnak(void) interrupt 0
 480          {
 481   1      }
 482          void ISR_Ep4pingnak(void) interrupt 0
 483          {
 484   1      }
 485          void ISR_Ep6pingnak(void) interrupt 0
 486          {
 487   1      }
 488          void ISR_Ep8pingnak(void) interrupt 0
 489          {
C51 COMPILER V7.50   VEND_AX                                                               04/23/2009 15:18:28 PAGE 9   

 490   1      }
 491          void ISR_Errorlimit(void) interrupt 0
 492          {
 493   1      }
 494          void ISR_Ep2piderror(void) interrupt 0
 495          {
 496   1      }
 497          void ISR_Ep4piderror(void) interrupt 0
 498          {
 499   1      }
 500          void ISR_Ep6piderror(void) interrupt 0
 501          {
 502   1      }
 503          void ISR_Ep8piderror(void) interrupt 0
 504          {
 505   1      }
 506          void ISR_Ep2pflag(void) interrupt 0
 507          {
 508   1      }
 509          void ISR_Ep4pflag(void) interrupt 0
 510          {
 511   1      }
 512          void ISR_Ep6pflag(void) interrupt 0
 513          {
 514   1      }
 515          void ISR_Ep8pflag(void) interrupt 0
 516          {
 517   1      }
 518          void ISR_Ep2eflag(void) interrupt 0
 519          {
 520   1      }
 521          void ISR_Ep4eflag(void) interrupt 0
 522          {
 523   1      }
 524          void ISR_Ep6eflag(void) interrupt 0
 525          {
 526   1      }
 527          void ISR_Ep8eflag(void) interrupt 0
 528          {
 529   1      }
 530          void ISR_Ep2fflag(void) interrupt 0
 531          {
 532   1      }
 533          void ISR_Ep4fflag(void) interrupt 0
 534          {
 535   1      }
 536          void ISR_Ep6fflag(void) interrupt 0
 537          {
 538   1      }
 539          void ISR_Ep8fflag(void) interrupt 0
 540          {
 541   1      }
 542          void ISR_GpifComplete(void) interrupt 0
 543          {
 544   1      }
 545          void ISR_GpifWaveform(void) interrupt 0
 546          {
 547   1      }
 548          
 549          void EEPROMWriteByte(WORD addr, BYTE value)
 550          {
 551   1              BYTE            i = 0;
C51 COMPILER V7.50   VEND_AX                                                               04/23/2009 15:18:28 PAGE 10  

 552   1              BYTE xdata      ee_str[3];
 553   1      
 554   1              if(DB_Addr)
 555   1                      ee_str[i++] = MSB(addr);
 556   1      
 557   1              ee_str[i++] = LSB(addr);
 558   1              ee_str[i++] = value;
 559   1      
 560   1              EZUSB_WriteI2C(I2C_Addr, i, ee_str);
 561   1         EZUSB_WaitForEEPROMWrite(I2C_Addr);
 562   1      }
 563          
 564          
 565          void EEPROMWrite(WORD addr, BYTE length, BYTE xdata *buf)
 566          {
 567   1              BYTE    i;
 568   1              for(i=0;i<length;++i)
 569   1                      EEPROMWriteByte(addr++,buf[i]);
 570   1      }
 571          
 572          void EEPROMRead(WORD addr, BYTE length, BYTE xdata *buf)
 573          {
 574   1              BYTE            i = 0;
 575   1              BYTE            j = 0;
 576   1              BYTE xdata      ee_str[2];
 577   1      
 578   1              if(DB_Addr)
 579   1                      ee_str[i++] = MSB(addr);
 580   1      
 581   1              ee_str[i++] = LSB(addr);
 582   1      
 583   1              EZUSB_WriteI2C(I2C_Addr, i, ee_str);
 584   1      
 585   1      //      for(j=0; j < length; j++)
 586   1      //              *(buf+j) = 0xcd;
 587   1      
 588   1              EZUSB_ReadI2C(I2C_Addr, length, buf);
 589   1      }
 590          



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1304    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----       5
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      4      20
   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 + -