U8 ReadCapacity(void)
{ U8 err ;
U8 bBUF[256];
BlockCommand.CbwBlock.dCBW_Signature=CBW_SIGNATURE;
BlockCommand.CbwBlock.dCBW_Tag=0x60a624de;
BlockCommand.CbwBlock.bCBW_LUN=0;
BlockCommand.CbwBlock.dCBW_DataXferLen=0x08;
BlockCommand.CbwBlock.bCBW_Flag=0x80;
BlockCommand.CbwBlock.bCBW_CDBLen=12;
BlockCommand.CbwBlock.OperationCode=UFI_CMD_READCAPACITY;
//-----------------------------------------------------------------
//包含在CBWCB中的READCAPACITY命令
//------------------------------------------------------------------
Delay( 12 );
if ( err = bulk_transfer( OUT, (U8 *)&BlockCommand.CbwBlock, 31 ) )
return err;
Delay( 8000 );
if ( err = bulk_transfer( IN, bBUF, 0x08) )
{
if ( err == 4 )
{
if ( ClearEndpointSTALL ( Udev.bEpin ) )
return 4;
err = bulk_transfer( IN, (U8 *)&BlockCommand.CswBlock, 13 );
return err;
}
}
Delay( 4000 );
if ( err = bulk_transfer( IN, (U8 *)&BlockCommand.CswBlock, 13 ) )
return err;
return 0;
}
我用宇瞻的2G,前面枚举描述符都是正确的, U盘在这个函数出了问题,每次都是err =4,
其他的U盘都不会出现这个问题,楼主帮忙分析下 |