|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我按照里面的GPIF的FIFO的例子
《ez_usb_fx2_gpif_primer___an1197_12.pdf》,
里面有段不明白是什么意思?
TD_Poll()
Code that handles USB OUT Transfers
if( GPIFTRIG & 0x80 ) // if GPIF interface IDLE
{
if ( ! ( EP24FIFOFLGS & 0x02 ) ) // if there's a packet in the peripheral domain for EP2
{
if ( EXTFIFONOTFULL ) // if the external FIFO is not full
{
if(enum_high_speed)
{
SYNCDELAY;
GPIFTCB1 = 0x01; // setup transaction count (512 bytes/2 for word wide -> 0x0100)
SYNCDELAY;
GPIFTCB0 = 0x00;//为什么要设置成这样?不是应该设置成我具体发多少个Byte的吗??迷惑……
SYNCDELAY;
}
else
{
SYNCDELAY;
GPIFTCB1 = 0x00; // setup transaction count (64 bytes/2 for word wide -> 0x20)
SYNCDELAY;
GPIFTCB0 = 0x20;
SYNCDELAY;
}
Setup_FLOWSTATE_Write(); // setup FLOWSTATE registers for FIFO Write operation
SYNCDELAY;
GPIFTRIG = GPIF_EP2; // launch GPIF FIFO WRITE Transaction from EP2 FIFO
SYNCDELAY;
while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 GPIF Done bit
{
;
}
SYNCDELAY;
}
}
}
The first thing the OUT handling code does is it checks to see if the GPIF is IDLE. If so, it checks to see if there is at least one packet in the peripheral domain for EP2. Since EP2 is placed into auto mode, the firmware does not need to check if the host sent a USB packet. The USB packets are automatically committed to be used by the GPIF engine. Therefore, the firmware’s job is to check if at least one packet has been committed to the peripheral domain.
Then, if the external FIFO is not full, the TC value is set up for word-wide operation. The TC value is a 32-bit register field, but for this application only the lower 16-bit fields are necessary. Since each GPIF FIFO Write transaction sends 512 bytes to the external FIFO over a 16-bit interface, the number of transactions is always half the number of bytes actually contained within the endpoint buffer. The appropriate TC value is set up for either high-speed (256) or full-speed (32) operation.
The appropriate flow state registers are then set up for the FIFO Write transaction, and a write to the GPIFTRIG register with the appropriate bits triggers the transaction from EP2OUT. The code then waits for the transaction to complete before exiting out of the “if” nest.
最最迷惑的就是:不是工作在autoout方式的吗?为什么还要写代码呢?这段代码究竟是干嘛的呢?
我发现一个问题:
当我写数据到ep2的时候,如果是写512Byte,很正常,PE1没变化,再来个vendor也成功;
但是当我写10Byte的时候,我发现PE1变成低电平了,我再来个vendor就不成功了。
不知道问题出在哪里?? |
|