贵公司老师,您好! 参考你们技术资料CH374HF.PDF,同时读写USB接口键盘U盘参考资料EXAM14改写程序 改写后调试遇到问题: 1、获取配置描述符返回值是正确的,但是到分配地址时程序无法走出来 s = SetUsbAddress( index + ( (PUSB_SETUP_REQ)SetupSetUsbAddr ) -> wValueL ); 无法跳出 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 ); } 经过观察,程序停留在memcpy( DatBuf, pDISK_BASE_BUF, *RetLen ); 出不来,单独调试U盘,键盘都基本没问题,不知这里咋回事? 读写U盘键盘等前面枚举一样吗?从单独的程序看感觉差别挺大的,可是EXAM14里面好像任何usb设备都要进行“获取设备描述符、分配地址、获取配置描述符....” UploadImages/2010631517832.rar