1、本人使用光盤中CH374\EVT\PUB\EXAM\HOST\下的HOST.C想完成U盤的讀,請(qǐng)問IN事務(wù)是不是可以直接調(diào)用函數(shù)WaitHostTransact374(in_endp_addr, DEF_USB_PID_IN,FALSE, 1000 );來(lái)完成?有哪些注意點(diǎn)? 2、枚舉成功了,現(xiàn)發(fā)送CWB,其中31BYTE的CBW是(out事務(wù))發(fā)送成功,但是接下來(lái)的IN的事務(wù)都沒成功,錯(cuò)誤號(hào),0x2a,或者0x20,給點(diǎn)建議。
cbw.dCBWSignature=0x43425355;//我用的是小端點(diǎn)的 cbw.dCBWTag=0X81c33b60; cbw.dCBWDataTransgerLength=0X00000012; cbw.bmCBWFlags=0x80; cbw.bCBWLUN=0x00; cbw.bCBWCBLength=0x0c; cbw.CBWCB[0]=0x03; cbw.CBWCB[1]=0; cbw.CBWCB[2]=0; cbw.CBWCB[3]=0; cbw.CBWCB[4]=0x12; cbw.CBWCB[5]=0; cbw.CBWCB[6]=0; for(i=7;i<31;i++) { cbw.CBWCB[i]=0; } len = 31;//out_endp_size; Write374Block( RAM_HOST_TRAN, len, (UINT8)cbw.v ); Write374Byte( REG_USB_LENGTH, len ); s = WaitHostTransact374(out_endp_addr, DEF_USB_PID_OUT, FALSE, 1000 ); ///////////////// 發(fā)送成功。 if(s!=USB_INT_SUCCESS) printf( "cbw cmd ERROR = %02X\n", (UINT16)s ); else { printf( "cbw cmd ok\n"); } s1 = WaitHostTransact374(in_endp_addr, DEF_USB_PID_IN,FALSE, 1000 ); //////////////// 失敗了。 if(s1!=USB_INT_SUCCESS) printf( "cbw read read ERROR = %02X\n", (UINT16)s1 ); else { printf( "cbw read ok,len:"); len = Read374Byte( REG_USB_LENGTH ); printf( "%02X data:",(UINT16)(len)); Read374Block( RAM_HOST_RECV, len, allbuf ); for ( i = 0; i < len; i ++ ) printf( "%02X ", (UINT16)(allbuf[i] ) ); printf( "\n"); } s3 =WaitHostTransact374( in_endp_addr, DEF_USB_PID_IN, TRUE, 1000 );//(UINT8)csw.dCSWSignature); if(s3!=USB_INT_SUCCESS) printf( "csw read ERROR = %02X\n", (UINT16)s3 ); else { printf( "csw ok,len:"); len = Read374Byte( REG_USB_LENGTH ); printf( "%02X data:",(UINT16)(len)); Read374Block( RAM_HOST_RECV, len, allbuf ); for ( i = 0; i < len; i ++ ) printf( "%02X ",(UINT16)( allbuf[i] ) );// (UINT16)(csw++) ); printf( "\n"); }