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

📄 gpif.lst

📁 一个有关EZ-USB FX2 系列CY7C68013的应用实例
💻 LST
📖 第 1 页 / 共 3 页
字号:
 356   1        EP8GPIFTCH = xfrcnt >> 8;  // setup transaction count
 357   1        SYNCDELAY;                    // 
 358   1        EP8GPIFTCL = ( BYTE )xfrcnt;
 359   1      }
 360          
 361          #define GPIF_FLGSELPF 0         //端点EPxGPIFFLGSEL     最后两位FS1:FS0的值
C51 COMPILER V7.10   GPIF                                                                  10/25/2005 20:26:41 PAGE 7   

 362          #define GPIF_FLGSELEF 1         //00=PF 01=EF 10=FF
 363          #define GPIF_FLGSELFF 2
 364          
 365          // Set EP2GPIF Decision Point FIFO Flag Select (PF, EF, FF) 设置端点2的FIFO标志。
 366          void SetEP2GPIFFLGSEL( WORD DP_FIFOFlag )
 367          {
 368   1        EP2GPIFFLGSEL = DP_FIFOFlag;
 369   1      }
 370          
 371          // Set EP4GPIF Decision Point FIFO Flag Select (PF, EF, FF)     设置端点4的FIFO标志
 372          void SetEP4GPIFFLGSEL( WORD DP_FIFOFlag )
 373          {
 374   1        EP4GPIFFLGSEL = DP_FIFOFlag;
 375   1      }
 376          
 377          // Set EP6GPIF Decision Point FIFO Flag Select (PF, EF, FF)     设置端点6的FIFO标志
 378          void SetEP6GPIFFLGSEL( WORD DP_FIFOFlag )
 379          {
 380   1        EP6GPIFFLGSEL = DP_FIFOFlag;
 381   1      }
 382          
 383          // Set EP8GPIF Decision Point FIFO Flag Select (PF, EF, FF)     设置端点8的FIFO标志
 384          void SetEP8GPIFFLGSEL( WORD DP_FIFOFlag )
 385          {
 386   1        EP8GPIFFLGSEL = DP_FIFOFlag;
 387   1      }
 388          //设置PFstop 不管传送计数器的值 当被选则的EF,PF,FF产生的时候怎直接将DONE=1结束GPIF.
 389          // Set EP2GPIF Programmable Flag STOP, overrides Transaction Count  
 390          void SetEP2GPIFPFSTOP( void )
 391          {
 392   1        EP2GPIFPFSTOP = 0x01;
 393   1      }
 394          
 395          // Set EP4GPIF Programmable Flag STOP, overrides Transaction Count
 396          void SetEP4GPIFPFSTOP( void )
 397          {
 398   1        EP4GPIFPFSTOP = 0x01;
 399   1      }
 400          
 401          // Set EP6GPIF Programmable Flag STOP, overrides Transaction Count
 402          void SetEP6GPIFPFSTOP( void )
 403          {
 404   1        EP6GPIFPFSTOP = 0x01;
 405   1      }
 406          
 407          // Set EP8GPIF Programmable Flag STOP, overrides Transaction Count
 408          void SetEP8GPIFPFSTOP( void )
 409          {
 410   1        EP8GPIFPFSTOP = 0x01;
 411   1      }
 412          
 413          // write single byte to PERIPHERAL, using GPIF 使用GPIF写一个字节到外部设备
 414          void Peripheral_SingleByteWrite( BYTE gdata )
 415          {
 416   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit 获取done位
 417   1        {
 418   2           ;
 419   2        }
 420   1      
 421   1        XGPIFSGLDATLX = gdata;        // trigger GPIF    把数据送到XGPIFSGLDATLX并触发GPIF
 422   1                                      // ...single byte write transaction
 423   1      }
C51 COMPILER V7.10   GPIF                                                                  10/25/2005 20:26:41 PAGE 8   

 424          
 425          // write single word to PERIPHERAL, using GPIF  使用GPIF写一个字到外部设备
 426          void Peripheral_SingleWordWrite( WORD gdata )  
 427          {
 428   1        while( !( GPIFTRIG & 0x80 ) )  // poll GPIFTRIG.7 Done bit
 429   1        {
 430   2          ;
 431   2        }
 432   1      
 433   1      // using register(s) in XDATA space
 434   1        XGPIFSGLDATH = gdata >> 8;              
 435   1        XGPIFSGLDATLX = gdata;        // trigger GPIF  把数据字写到XGPIFSGLGATLX和XGPIFSGLGATH中触发GPIF
 436   1                                      // ...single word write transaction
 437   1      }
 438          
 439          // read single byte from PERIPHERAL, using GPIF     使用GPIF从外部设备读单个字节
 440          void Peripheral_SingleByteRead( BYTE xdata *gdata )  //与写不同,这里需要给的就是数据要存储的数据地址指针
 441          {
 442   1        static BYTE g_data = 0x00;  
 443   1      
 444   1        while( !( GPIFTRIG & 0x80 ) )  // poll GPIFTRIG.7 Done bit
 445   1        {
 446   2           ;
 447   2        }
 448   1      
 449   1      // using register(s) in XDATA space, dummy read  首先要一个虚读来启动GPIF
 450   1        g_data = XGPIFSGLDATLX;       // trigger GPIF 
 451   1                                      // ...single byte read transaction
 452   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 453   1        {
 454   2           ;
 455   2        }
 456   1      
 457   1      // using register(s) in XDATA space,  从B口pin读取外设的数据
 458   1        *gdata = XGPIFSGLDATLNOX;     // ...GPIF reads byte from PERIPHERAL
 459   1      }
 460          
 461          // read single word from PERIPHERAL, using GPIF    使用GPIF从外部设备的读取单个字
 462          void Peripheral_SingleWordRead( WORD xdata *gdata )
 463          {
 464   1        BYTE g_data = 0x00;
 465   1      
 466   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 467   1        {
 468   2           ;
 469   2        }
 470   1      
 471   1      // using register(s) in XDATA space, dummy read   虚读操作,启动GPIF
 472   1        g_data = XGPIFSGLDATLX;       // trigger GPIF 
 473   1                                      // ...single word read transaction
 474   1      
 475   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 476   1        {
 477   2           ;
 478   2        }
 479   1      
 480   1      // using register(s) in XDATA space, GPIF reads word from PERIPHERAL
 481   1        *gdata = ( ( WORD )XGPIFSGLDATH << 8 ) | ( WORD )XGPIFSGLDATLNOX;
 482   1      }
 483          
 484          #define GPIFTRIGWR 0
 485          #define GPIFTRIGRD 4
C51 COMPILER V7.10   GPIF                                                                  10/25/2005 20:26:41 PAGE 9   

 486          
 487          #define GPIF_EP2 0                //EP1:EP0=00
 488          #define GPIF_EP4 1                //EP1:EP0=01
 489          #define GPIF_EP6 2                //EP1:EP0=10
 490          #define GPIF_EP8 3                //EP1:EP0=11
 491          
 492          // write byte(s)/word(s) to PERIPHERAL, using GPIF and EPxFIFO
 493          // if EPx WORDWIDE=0 then write byte(s)   
 494          // if EPx WORDWIDE=1 then write word(s)
 495          void Peripheral_FIFOWrite( BYTE FIFO_EpNum )
 496          {
 497   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit 获取done位。当为0在这里等待为1就跳出
 498   1        {
 499   2           ;
 500   2        }
 501   1      
 502   1        // trigger FIFO write transaction(s), using SFR     通过sfr, 触发FIFO写处理
 503   1        GPIFTRIG = FIFO_EpNum;  // R/W=0, EP[1:0]=FIFO_EpNum for EPx write(s) 设定写和FIFO通道
 504   1      }
 505          
 506          // read byte(s)/word(s) from PERIPHERAL, using GPIF and EPxFIFO
 507          // if EPx WORDWIDE=0 then read byte(s)
 508          // if EPx WORDWIDE=1 then read word(s)
 509          void Peripheral_FIFORead( BYTE FIFO_EpNum )
 510          {
 511   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 GPIF Done bit 获取done位,0等待,1跳出
 512   1        {
 513   2           ;
 514   2        }
 515   1      
 516   1        // trigger FIFO read transaction(s), using SFR  使用sfr触发FIFO读操作
 517   1        GPIFTRIG = GPIFTRIGRD | FIFO_EpNum; // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
 518   1      }
 519          
 520          
 521          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    454    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    171    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1    ----
   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 + -