貴公司老師,您好! 參考你們技術(shù)資料CH374HF.PDF,同時(shí)讀寫USB接口鍵盤U盤參考資料EXAM14改寫程序 改寫后調(diào)試遇到問(wèn)題: 1、獲取配置描述符返回值是正確的,但是到分配地址時(shí)程序無(wú)法走出來(lái) s = SetUsbAddress( index + ( (PUSB_SETUP_REQ)SetupSetUsbAddr ) -> wValueL ); 無(wú)法跳出 UINT8 SetUsbAddress( UINT8 addr ) { UINT8 s; UINT8 BufSetAddr[ sizeof( SetupSetUsbAddr ) ] ; memcpy ( BufSetAddr, SetupSetUsbAddr, sizeof( SetupSetUsbAddr ) ); ( (PUSB_SETUP_REQ)BufSetAddr ) -> wValueL = addr; s = HostCtrlTransfer374( BufSetAddr, NULL, NULL ); if ( s == USB_INT_SUCCESS ) { SetHostUsbAddr( addr ); } CH374DelaymS( 2 ); return( s ); }
UINT8 HostCtrlTransfer374( PUINT8 ReqBuf, PUINT8 DatBuf, PUINT8 RetLen ) { UINT8 s; for ( s = 0; s != 8; s ++ ) CH374_WRITE_REGISTER( RAM_HOST_TRAN + s, *( ReqBuf + s ) ); CH374DirtyBuffer( ); s = CH374CtrlTransfer( ); if ( s == ERR_SUCCESS ) { *RetLen = *(ReqBuf+6); memcpy( DatBuf, pDISK_BASE_BUF, *RetLen ); return( USB_INT_SUCCESS ); } return( s ); } 經(jīng)過(guò)觀察,程序停留在memcpy( DatBuf, pDISK_BASE_BUF, *RetLen ); 出不來(lái),單獨(dú)調(diào)試U盤,鍵盤都基本沒(méi)問(wèn)題,不知這里咋回事? 讀寫U盤鍵盤等前面枚舉一樣嗎?從單獨(dú)的程序看感覺(jué)差別挺大的,可是EXAM14里面好像任何usb設(shè)備都要進(jìn)行“獲取設(shè)備描述符、分配地址、獲取配置描述符....” UploadImages/2010631517832.rar