这是让 CH567 USB0 Host 支持 Boot Protocol 的鼠标,需要对设备发送 Get_Protocol 和 Set_Protocol。
基于之前的USB0_HOSTMS ,代码改动如下:
1.声明使用的 COMMAND
const UINT8 SetupClrFeature[] = { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; //Clear feature
//LabzDebug_Start
const UINT8 SetupGetProtocol[] = { 0xA1, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; //GET Protocol
const UINT8 SetupSetProtocol[] = { 0x21, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //SET Protocol
//LabzDebug_End
__attribute__ ((aligned(4))) UINT8 UHBuffer0[U0H_MAXPACKET_LEN]; //数据发送缓存区
2.在EnumDevice( PUSBDEV pusbdev )函数中加入:
//LabzDebug_Start
//GET_PROTOCOL
printf("Get Protocol..\n");
CopySetupReqPkg( (PUINT8)SetupGetProtocol);
printf("setup: "); for(i=0; i<8; i++) printf("%02x ", ((PUINT8)pSetupReq)[i]); printf("\n");
s = U0HCtrlTransfer( pusbdev, NULL, NULL, NULL ); // Ö´ÐпØÖÆ´«Êä
if ( s != USB_INT_SUCCESS ) return( s );
printf("in: "); for(i=0; i<len; i++) printf("%02x ", UHRecvBuf[i]); printf("\n");
//SET_PROTOCOL
printf("Set Protocol\n");
CopySetupReqPkg( (PUINT8)SetupSetProtocol );
printf("setup: "); for(i=0; i<8; i++) printf("%02x ", ((PUINT8)pSetupReq)[i]); printf("\n");
s = U0HCtrlTransfer( pusbdev, NULL, NULL, NULL ); // Ö´ÐпØÖÆ´«Êä
if ( s != USB_INT_SUCCESS ) return( s );
//LabZDebug_End