FPGA循环16进制数向CY7C68013A 发送数据,在MASTER端以GPIF方式读取数据,其读数据函数是:
void GPIF_SingleWordRead( WORD xdata *gdata )
{
static BYTE g_data = 0x00; // dummy variable
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register in XDATA space
g_data = XGPIFSGLDATLX; // dummy read to trigger GPIF
// Single Word Read transaction
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
{
;
}
// using register(s) in XDATA space, retrieve word just read from ext. FIFO
*gdata = ( ( WORD )XGPIFSGLDATLNOX << 8 ) | ( WORD )XGPIFSGLDATH;
//*gdata = ( ( WORD )XGPIFSGLDATH << 8 ) | ( WORD )XGPIFSGLDATLNOX;
}
在poll函数中循环取数据:
if(in_enable) // if IN transfers are enabled,
{
if(!(EP2468STAT & bmEP6FULL) && (EXTFIFONOTEMPTY))
{
// if EP6IN is not full AND there is data in the external FIFO,
Destination = (WORD *)(&EP6FIFOBUF);
for( i = 0x0000; i < Tcount; i++ )
{
// transfer data from external FIFO to EP6IN buffer
GPIF_SingleWordRead (Destination);
Destination++;
}
Tcount *= 2; // multiply by 2 to obtain byte count value
EP6BCH = MSB(Tcount);
SYNCDELAY;
EP6BCL = LSB(Tcount); // arm EP6IN to send data to the host
SYNCDELAY;
}
自己写了个应用程序从pc端读取usb数据,发现读取的数据全都是0,那位大侠能给我分析一下,万分感谢! |