📄 gpif.lst
字号:
244 1
245 1 // source
246 1 APTR1H = MSB( &WaveData );
247 1 APTR1L = LSB( &WaveData );
248 1
249 1 // destination
250 1 AUTOPTRH2 = 0xE4;
251 1 AUTOPTRL2 = 0x00;
252 1
253 1 // transfer
254 1 for ( i = 0x00; i < 128; i++ )
255 1 {
256 2 EXTAUTODAT2 = EXTAUTODAT1;
257 2 }
258 1
259 1 // Configure GPIF Address pins, output initial value,
260 1 PORTCCFG = 0xFF; // [7:0] as alt. func. GPIFADR[7:0]
261 1 OEC = 0xFF; // and as outputs
262 1 PORTECFG |= 0x80; // [8] as alt. func. GPIFADR[8]
263 1 OEE |= 0x9F; // and as output
264 1 //端口A设置为IO端口
265 1 PORTACFG=0x00;
266 1 OEA=0x0F;
267 1 //确保端口D为IO口,将WORDWIDE清零
268 1 EP2FIFOCFG &= 0xFF;
269 1 EP4FIFOCFG &= 0xFF;
270 1 EP6FIFOCFG &= 0xFF;
271 1 EP8FIFOCFG &= 0xFF;
272 1
273 1 // ...OR... tri-state GPIFADR[8:0] pins
274 1 // PORTCCFG = 0x00; // [7:0] as port I/O
275 1 // OEC = 0x00; // and as inputs
276 1 // PORTECFG &= 0x7F; // [8] as port I/O
277 1 // OEC &= 0x7F; // and as input
278 1 OED=0xFF;
279 1 IOD=0x00;
280 1 IOE=0x00;
281 1
282 1 // GPIF address pins update when GPIFADRH/L written
283 1 SYNCDELAY; //
284 1 GPIFADRH = 0x00; // bits[7:1] always 0
285 1 SYNCDELAY; //
286 1 GPIFADRL = 0x00; // point to PERIPHERAL address 0x0000
287 1 SYNCDELAY;
288 1 GPIFCTLCFG=0x00;
289 1 }
C51 COMPILER V6.10 GPIF 07/07/2005 13:31:07 PAGE 9
290
291 #ifdef TESTING_GPIF
// TODO: You may add additional code below.
void OtherInit( void )
{ // interface initialization
// ...see TD_Init( );
}
// Set Address GPIFADR[8:0] to PERIPHERAL
void Peripheral_SetAddress( WORD gaddr )
{
SYNCDELAY; //
GPIFADRH = gaddr >> 8;
SYNCDELAY; //
GPIFADRL = ( BYTE )gaddr; // setup GPIF address
}
// Set EP2GPIF Transaction Count
void Peripheral_SetEP2GPIFTC( WORD xfrcnt )
{
SYNCDELAY; //
EP2GPIFTCH = xfrcnt >> 8; // setup transaction count
SYNCDELAY; //
EP2GPIFTCL = ( BYTE )xfrcnt;
}
// Set EP4GPIF Transaction Count
void Peripheral_SetEP4GPIFTC( WORD xfrcnt )
{
SYNCDELAY; //
EP4GPIFTCH = xfrcnt >> 8; // setup transaction count
SYNCDELAY; //
EP4GPIFTCL = ( BYTE )xfrcnt;
}
// Set EP6GPIF Transaction Count
void Peripheral_SetEP6GPIFTC( WORD xfrcnt )
{
SYNCDELAY; //
EP6GPIFTCH = xfrcnt >> 8; // setup transaction count
SYNCDELAY; //
EP6GPIFTCL = ( BYTE )xfrcnt;
}
// Set EP8GPIF Transaction Count
void Peripheral_SetEP8GPIFTC( WORD xfrcnt )
{
SYNCDELAY; //
EP8GPIFTCH = xfrcnt >> 8; // setup transaction count
SYNCDELAY; //
EP8GPIFTCL = ( BYTE )xfrcnt;
}
#define GPIF_FLGSELPF 0
#define GPIF_FLGSELEF 1
#define GPIF_FLGSELFF 2
// Set EP2GPIF Decision Point FIFO Flag Select (PF, EF, FF)
void SetEP2GPIFFLGSEL( WORD DP_FIFOFlag )
{
EP2GPIFFLGSEL = DP_FIFOFlag;
C51 COMPILER V6.10 GPIF 07/07/2005 13:31:07 PAGE 10
}
// Set EP4GPIF Decision Point FIFO Flag Select (PF, EF, FF)
void SetEP4GPIFFLGSEL( WORD DP_FIFOFlag )
{
EP4GPIFFLGSEL = DP_FIFOFlag;
}
// Set EP6GPIF Decision Point FIFO Flag Select (PF, EF, FF)
void SetEP6GPIFFLGSEL( WORD DP_FIFOFlag )
{
EP6GPIFFLGSEL = DP_FIFOFlag;
}
// Set EP8GPIF Decision Point FIFO Flag Select (PF, EF, FF)
void SetEP8GPIFFLGSEL( WORD DP_FIFOFlag )
{
EP8GPIFFLGSEL = DP_FIFOFlag;
}
// Set EP2GPIF Programmable Flag STOP, overrides Transaction Count
void SetEP2GPIFPFSTOP( void )
{
EP2GPIFPFSTOP = 0x01;
}
// Set EP4GPIF Programmable Flag STOP, overrides Transaction Count
void SetEP4GPIFPFSTOP( void )
{
EP4GPIFPFSTOP = 0x01;
}
// Set EP6GPIF Programmable Flag STOP, overrides Transaction Count
void SetEP6GPIFPFSTOP( void )
{
EP6GPIFPFSTOP = 0x01;
}
// Set EP8GPIF Programmable Flag STOP, overrides Transaction Count
void SetEP8GPIFPFSTOP( void )
{
EP8GPIFPFSTOP = 0x01;
}
// write single byte to PERIPHERAL, using GPIF
void Peripheral_SingleByteWrite( BYTE gdata )
{
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
XGPIFSGLDATLX = gdata; // trigger GPIF
// ...single byte write transactio
-n
}
// write single word to PERIPHERAL, using GPIF
void Peripheral_SingleWordWrite( WORD gdata )
{
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
C51 COMPILER V6.10 GPIF 07/07/2005 13:31:07 PAGE 11
;
}
// using register(s) in XDATA space
XGPIFSGLDATH = gdata >> 8;
XGPIFSGLDATLX = gdata; // trigger GPIF
// ...single word write transactio
-n
}
// read single byte from PERIPHERAL, using GPIF
void Peripheral_SingleByteRead( BYTE xdata *gdata )
{
static BYTE g_data = 0x00;
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register(s) in XDATA space, dummy read
g_data = XGPIFSGLDATLX; // trigger GPIF
// ...single byte read transaction
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register(s) in XDATA space,
*gdata = XGPIFSGLDATLNOX; // ...GPIF reads byte from PERIPHE
-RAL
}
// read single word from PERIPHERAL, using GPIF
void Peripheral_SingleWordRead( WORD xdata *gdata )
{
BYTE g_data = 0x00;
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register(s) in XDATA space, dummy read
g_data = XGPIFSGLDATLX; // trigger GPIF
// ...single word read transaction
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register(s) in XDATA space, GPIF reads word from PERIPHER
-AL
*gdata = ( ( WORD )XGPIFSGLDATH << 8 ) | ( WORD )XGPIFSGLDATLNOX
-;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -