Vendor Defined HID - command and response
Posted: Mon Nov 06, 2017 12:02 pm
Hi Everyone,
We have added the vendor defined HID profile with the UAC2.0 audio reference design. Our requirement is to respond to every command received in the HID and will not provide any response unless it is processed. Below is the code snipped I am using to receive the HID data , process and respond back in case of GET and SET HID report in HID class requests
case HID_GET_REPORT:
// Not - Used
/* Mandatory. Allows sending of report over control pipe */
result = XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char []), 64, sp.wLength);
break;
case HID_SET_REPORT:
if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D)
{
// Host to device - Copy data into the buffer
if (sp.wLength)
result = XUD_GetBuffer(ep0_out, (buffer_hid, unsigned char[]), datalength_hid);
}
//Acknowlwdge set request
if(result == XUD_RES_OKAY)
result = XUD_DoSetRequestStatus(ep0_in);
if(result == XUD_RES_OKAY)
{
//command Parser
cmdsParser();
//Initiate response
result = XUD_SetReady_In(ep_hid_in,buffer_hid,64);
// Wait till data is sent
while(1)
{
select
{
case XUD_SetData_Select ( c_hid , ep_hid_in , result ):
return result;
break ;
}
}
}
break;
The problem I am seeing the PC gets a HID response before even we process it. Meaning the command process takes roughly 10ms but PC receives a response with all zeros immediately. If I read the HID Packet after 10 ms I get the actual response.
Any thought on how it make it synchronous such that I get HID response only after the processing is complete.
Many Thanks for any help in this regards.
Thanks
Uthrakumar
We have added the vendor defined HID profile with the UAC2.0 audio reference design. Our requirement is to respond to every command received in the HID and will not provide any response unless it is processed. Below is the code snipped I am using to receive the HID data , process and respond back in case of GET and SET HID report in HID class requests
case HID_GET_REPORT:
// Not - Used
/* Mandatory. Allows sending of report over control pipe */
result = XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char []), 64, sp.wLength);
break;
case HID_SET_REPORT:
if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D)
{
// Host to device - Copy data into the buffer
if (sp.wLength)
result = XUD_GetBuffer(ep0_out, (buffer_hid, unsigned char[]), datalength_hid);
}
//Acknowlwdge set request
if(result == XUD_RES_OKAY)
result = XUD_DoSetRequestStatus(ep0_in);
if(result == XUD_RES_OKAY)
{
//command Parser
cmdsParser();
//Initiate response
result = XUD_SetReady_In(ep_hid_in,buffer_hid,64);
// Wait till data is sent
while(1)
{
select
{
case XUD_SetData_Select ( c_hid , ep_hid_in , result ):
return result;
break ;
}
}
}
break;
The problem I am seeing the PC gets a HID response before even we process it. Meaning the command process takes roughly 10ms but PC receives a response with all zeros immediately. If I read the HID Packet after 10 ms I get the actual response.
Any thought on how it make it synchronous such that I get HID response only after the processing is complete.
Many Thanks for any help in this regards.
Thanks
Uthrakumar