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

📄 gpif.lst

📁 实现了ez-usb fx2的GPIF单字节读写功能
💻 LST
📖 第 1 页 / 共 3 页
字号:
 340          void SetEP2GPIFFLGSEL( WORD DP_FIFOFlag )
 341          {
 342   1        EP2GPIFFLGSEL = DP_FIFOFlag;
 343   1      }
 344          
 345          // Set EP4GPIF Decision Point FIFO Flag Select (PF, EF, FF)
 346          void SetEP4GPIFFLGSEL( WORD DP_FIFOFlag )
 347          {
 348   1        EP4GPIFFLGSEL = DP_FIFOFlag;
 349   1      }
 350          
 351          // Set EP6GPIF Decision Point FIFO Flag Select (PF, EF, FF)
 352          void SetEP6GPIFFLGSEL( WORD DP_FIFOFlag )
 353          {
 354   1        EP6GPIFFLGSEL = DP_FIFOFlag;
 355   1      }
 356          
 357          // Set EP8GPIF Decision Point FIFO Flag Select (PF, EF, FF)
 358          void SetEP8GPIFFLGSEL( WORD DP_FIFOFlag )
 359          {
 360   1        EP8GPIFFLGSEL = DP_FIFOFlag;
 361   1      }
 362          
 363          // Set EP2GPIF Programmable Flag STOP, overrides Transaction Count
 364          void SetEP2GPIFPFSTOP( void )
 365          {
C51 COMPILER V7.02b   GPIF                                                                 07/11/2004 12:05:28 PAGE 7   

 366   1        EP2GPIFPFSTOP = 0x01;
 367   1      }
 368          
 369          // Set EP4GPIF Programmable Flag STOP, overrides Transaction Count
 370          void SetEP4GPIFPFSTOP( void )
 371          {
 372   1        EP4GPIFPFSTOP = 0x01;
 373   1      }
 374          
 375          // Set EP6GPIF Programmable Flag STOP, overrides Transaction Count
 376          void SetEP6GPIFPFSTOP( void )
 377          {
 378   1        EP6GPIFPFSTOP = 0x01;
 379   1      }
 380          
 381          // Set EP8GPIF Programmable Flag STOP, overrides Transaction Count
 382          void SetEP8GPIFPFSTOP( void )
 383          {
 384   1        EP8GPIFPFSTOP = 0x01;
 385   1      }
 386          
 387          // write single byte to PERIPHERAL, using GPIF
 388          void Peripheral_SingleByteWrite( BYTE gdata )
 389          {
 390   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 391   1        {
 392   2           ;
 393   2        }
 394   1      
 395   1        XGPIFSGLDATLX = gdata;        // trigger GPIF 
 396   1                                      // ...single byte write transaction
 397   1      }
 398          
 399          // write single word to PERIPHERAL, using GPIF
 400          void Peripheral_SingleWordWrite( WORD gdata )
 401          {
 402   1        while( !( GPIFTRIG & 0x80 ) )  // poll GPIFTRIG.7 Done bit
 403   1        {
 404   2          ;
 405   2        }
 406   1      
 407   1      // using register(s) in XDATA space
 408   1        XGPIFSGLDATH = gdata >> 8;              
 409   1        XGPIFSGLDATLX = gdata;        // trigger GPIF 
 410   1                                      // ...single word write transaction
 411   1      }
 412          
 413          // read single byte from PERIPHERAL, using GPIF
 414          void Peripheral_SingleByteRead( BYTE xdata *gdata )
 415          {
 416   1        static BYTE g_data = 0x00;
 417   1      
 418   1        while( !( GPIFTRIG & 0x80 ) )  // poll GPIFTRIG.7 Done bit
 419   1        {
 420   2           ;
 421   2        }
 422   1      
 423   1      // using register(s) in XDATA space, dummy read
 424   1        g_data = XGPIFSGLDATLX;       // trigger GPIF 
 425   1                                      // ...single byte read transaction
 426   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 427   1        {
C51 COMPILER V7.02b   GPIF                                                                 07/11/2004 12:05:28 PAGE 8   

 428   2           ;
 429   2        }
 430   1      
 431   1      // using register(s) in XDATA space, 
 432   1        *gdata = XGPIFSGLDATLNOX;     // ...GPIF reads byte from PERIPHERAL
 433   1      }
 434          
 435          // read single word from PERIPHERAL, using GPIF
 436          void Peripheral_SingleWordRead( WORD xdata *gdata )
 437          {
 438   1        BYTE g_data = 0x00;
 439   1      
 440   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 441   1        {
 442   2           ;
 443   2        }
 444   1      
 445   1      // using register(s) in XDATA space, dummy read
 446   1        g_data = XGPIFSGLDATLX;       // trigger GPIF 
 447   1                                      // ...single word read transaction
 448   1      
 449   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 450   1        {
 451   2           ;
 452   2        }
 453   1      
 454   1      // using register(s) in XDATA space, GPIF reads word from PERIPHERAL
 455   1        *gdata = ( ( WORD )XGPIFSGLDATH << 8 ) | ( WORD )XGPIFSGLDATLNOX;
 456   1      }
 457          
 458          #define GPIFTRIGWR 0
 459          #define GPIFTRIGRD 4
 460          
 461          #define GPIF_EP2 0
 462          #define GPIF_EP4 1
 463          #define GPIF_EP6 2
 464          #define GPIF_EP8 3
 465          
 466          // write byte(s)/word(s) to PERIPHERAL, using GPIF and EPxFIFO
 467          // if EPx WORDWIDE=0 then write byte(s)
 468          // if EPx WORDWIDE=1 then write word(s)
 469          void Peripheral_FIFOWrite( BYTE FIFO_EpNum )
 470          {
 471   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
 472   1        {
 473   2           ;
 474   2        }
 475   1      
 476   1        // trigger FIFO write transaction(s), using SFR
 477   1        GPIFTRIG = FIFO_EpNum;  // R/W=0, EP[1:0]=FIFO_EpNum for EPx write(s)
 478   1      }
 479          
 480          // read byte(s)/word(s) from PERIPHERAL, using GPIF and EPxFIFO
 481          // if EPx WORDWIDE=0 then read byte(s)
 482          // if EPx WORDWIDE=1 then read word(s)
 483          void Peripheral_FIFORead( BYTE FIFO_EpNum )
 484          {
 485   1        while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 GPIF Done bit
 486   1        {
 487   2           ;
 488   2        }
 489   1      
C51 COMPILER V7.02b   GPIF                                                                 07/11/2004 12:05:28 PAGE 9   

 490   1        // trigger FIFO read transaction(s), using SFR
 491   1        GPIFTRIG = GPIFTRIGRD | FIFO_EpNum; // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
 492   1      }
 493          
 494          
 495          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    390    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    135    ----
   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 + -