00 00 80 00 c1 40 c0 03 00 40 e8 00 00 91 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 a1 4b 2d 34 00 a8 06 26 25 4c 58 03 60 2c 12 53 12 60 72 cc 20 5e 4a 1d 10 96 0e 3c 2d 54 c0 Start CH374 Host
Reset Device Start Low- Speed Device GetDeviceDescr: device_status=14 12 01 10 01 00 00 00 08 D9 04 03 15 10 03 01 02 00 01 a ddress_status=14 config_status=14 SetUsbConfig_success Set_Idle Set_idle success Get_Hid_Des HID_Desc: 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 95 01 7 5 08 81 01 95 03 75 01 05 08 19 01 29 03 91 02 95 05 75 01 91 01 95 06 75 08 26 ff 00 05 07 19 00 29 91 81 00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Set_Report Set_Report success
s:2a
s:14 00 00 1f 00 00 00 00 00 s:14 00 00 00 00 00 00 00 00
s:14 00 00 1f 00 00 00 00 00 s:14 00 00 00 00 00 00 00 00
s:2a
s:14 00 00 1e 00 00 00 00 00 s:14 00 00 00 00 00 00 00 00
s:14 00 00 29 00 00 00 00 00 s:14 00 00 00 00 00 00 00 00
s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 s:20 然后就一直是s:20了,請(qǐng)問(wèn)這是怎么個(gè)情況?。?
那個(gè)20是從這里返回的: UINT8 HostTransact374( UINT8 endp_addr, UINT8 pid, BOOL tog ) { // 本子程序著重于易理解,而在實(shí)際應(yīng)用中,為了提供運(yùn)行速度,應(yīng)該對(duì)本子程序代碼進(jìn)行優(yōu)化 UINT8 retry; UINT8 s, r, u; for ( retry = 0; retry < 3; retry ++ ) {//原來(lái)是3 Write374Byte( REG_USB_H_PID, M_MK_HOST_PID_ENDP( pid, endp_addr ) ); // 指定令牌PID和目的端點(diǎn)號(hào) //Write374Byte( REG_USB_H_CTRL, BIT_HOST_START | ( tog ? ( BIT_HOST_TRAN_TOG | BIT_HOST_RECV_TOG ) : 0x00 ) ); // 設(shè)置同步標(biāo)志并啟動(dòng)傳輸 Write374Byte( REG_USB_H_CTRL, ( tog ? ( BIT_HOST_START | BIT_HOST_TRAN_TOG | BIT_HOST_RECV_TOG ) : BIT_HOST_START ) ); // 設(shè)置同步標(biāo)志并啟動(dòng)傳輸 //Write374Byte( REG_INTER_FLAG, BIT_IF_USB_PAUSE ); // 取消暫停 //delay_us( 200 ); s = Wait374Interrupt( ); if ( s == ERR_USB_UNKNOWN ) return( s ); // 中斷超時(shí),可能是硬件異常 s = Read374Byte( REG_INTER_FLAG ); // 獲取中斷狀態(tài) if ( s & BIT_IF_DEV_DETECT ) { // USB設(shè)備插拔事件 delay_us( 200 ); // 等待傳輸完成 Write374Byte( REG_INTER_FLAG, BIT_IF_USB_PAUSE | BIT_IF_DEV_DETECT | BIT_IF_TRANSFER ); // 清中斷標(biāo)志 if ( s & BIT_IF_DEV_ATTACH ) { // USB設(shè)備連接事件 u = Read374Byte( REG_USB_SETUP ); if ( s & BIT_IF_USB_DX_IN ) { // 速度匹配,不需要切換速度 if ( u & BIT_SETP_USB_SPEED ) return( USB_INT_CONNECT_LS ); // 低速USB設(shè)備 return( USB_INT_CONNECT ); // 全速USB設(shè)備 } else { // 速度失配,需要切換速度 if ( u & BIT_SETP_USB_SPEED ) return( USB_INT_CONNECT ); // 全速USB設(shè)備 return( USB_INT_CONNECT_LS ); // 低速USB設(shè)備 } } else return( USB_INT_DISCONNECT ); // USB設(shè)備斷開(kāi)事件 } else if ( s & BIT_IF_TRANSFER ) { // 傳輸完成///////////////////////////////// Write374Byte( REG_INTER_FLAG, BIT_IF_USB_PAUSE | BIT_IF_TRANSFER ); // 清中斷標(biāo)志 s = Read374Byte( REG_USB_STATUS ); // USB狀態(tài)s為0x0a寄存器的狀態(tài) r = s & BIT_STAT_DEV_RESP; // USB設(shè)備應(yīng)答狀態(tài)s&0x0f switch ( pid ) { case DEF_USB_PID_SETUP: case DEF_USB_PID_OUT: if ( r == DEF_USB_PID_ACK ) return( USB_INT_SUCCESS ); else if ( r == DEF_USB_PID_STALL || r == DEF_USB_PID_NAK ) return( r | 0x20 ); else if ( ! M_IS_HOST_TIMEOUT( s ) ) return( r | 0x20 ); // 不是超時(shí)/出錯(cuò),意外應(yīng)答 break; case DEF_USB_PID_IN: if ( M_IS_HOST_IN_DATA( s ) )//是否返回DATA0或者DATA1 { // DEF_USB_PID_DATA0 or DEF_USB_PID_DATA1 if ( s & BIT_STAT_TOG_MATCH ) return( USB_INT_SUCCESS ); // 數(shù)據(jù)包同步則返回,不同步則需丟棄后重試 } else if ( r == DEF_USB_PID_STALL || r == DEF_USB_PID_NAK ) return( r | 0x20 );//其他標(biāo)志位為1 else if ( !M_IS_HOST_TIMEOUT( s ) ) return( r | 0x20 ); // 不是超時(shí)/出錯(cuò),意外應(yīng)答 break; default: return( ERR_USB_UNKNOWN ); // 不可能的情況 } } else { // 其它中斷,不應(yīng)該發(fā)生的情況 delay_us( 200 ); // 等待傳輸完成 Write374Byte( REG_INTER_FLAG, BIT_IF_USB_PAUSE | BIT_IF_INTER_FLAG ); /* 清中斷標(biāo)志 */ if ( retry ) return( ERR_USB_UNKNOWN ); // 不是第一次檢測(cè)到則返回錯(cuò)誤 } } //Write374Byte( REG_INTER_FLAG, BIT_IF_USB_PAUSE | BIT_IF_INTER_FLAG ); /* 清中斷標(biāo)志 */ return( 0x20 ); // 0x20應(yīng)答超時(shí) s=0x88 }