香版主,你好,请帮忙看一下,问题是在pc机在发送完成SET_REPORT后无法进入CustomHID_Status_In这个函数,后查看pInformation->ControlStat值为STALLED,不清楚是怎么会产生STALLED的值。程序代码如下:
RESULT CustomHID_Data_Setup(uint8_t RequestNo)
{
uint8_t *(*CopyRoutine)(uint16_t);
CopyRoutine = NULL;
if ((RequestNo == GET_DESCRIPTOR)
&& (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
&& (pInformation->USBwIndex0 == 0))
{
if (pInformation->USBwValue1 == REPORT_DESCRIPTOR)
{
CopyRoutine = CustomHID_GetReportDescriptor;
}
else if (pInformation->USBwValue1 == HID_DESCRIPTOR_TYPE)
{
CopyRoutine = CustomHID_GetHIDDescriptor;
}
} /* End of GET_DESCRIPTOR */
if (pInformation->USBbmRequestType == CLASS_REQUEST|INTERFACE_RECIPIENT//处理SET_REPORT请求
&& RequestNo == SET_REPORT)
{
CopyRoutine = CustomHID_SetReport;
}
else if((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))//处理GET_REPORT请求
&& RequestNo == GET_REPORT)
{
CopyRoutine = CustomHID_GetReport;
}
if (CopyRoutine == NULL)
{
return USB_UNSUPPORT;
}
pInformation->Ctrl_Info.CopyData = CopyRoutine;
pInformation->Ctrl_Info.Usb_wOffset = 0;
(*CopyRoutine)(0);
return USB_SUCCESS;
}
回调函数代码如下:
uint8_t *CustomHID_SetReport(uint16_t length)
{
if (length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = 1024-pInformation->Ctrl_Info.Usb_wOffset;
return NULL;
}
return &My_Buffer[pInformation->Ctrl_Info.Usb_wOffset];
}
uint8_t *CustomHID_GetReport(uint16_t Length)
{
if (Length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = 1024-pInformation->Ctrl_Info.Usb_wOffset
return NULL;
}
return &My_Buffer[pInformation->Ctrl_Info.Usb_wOffset
}
包的大小为16个字节。
如果按照你的说法,在CustomHID_Data_Setup函数RETURN之前将(*CopyRoutine)(0)改成pInformation->Usb_wLength = (*CopyRoutine)(0);
但是编译后,报错该成员不存在,不知是笔误,还是另有其它的结构体。
谢谢,请帮忙解决一下 |