Skip to main content
RobG
Associate III
Mar 13, 2020 5:14 PM UTC
Solved

My USB HID is processing reports one report behind - any thoughts?

IN the function USBD_HID_setup for a class requese I added a case for send report.

					case HID_REQ_SET_REPORT:
						Debug::Instance()->printf(Debug::ALLWAYS, (char *) "Set report %X\n", req->wValue);
						Debug::Instance()->printf(Debug::ALLWAYS, (char *) "Received: ");
						for (int ii = 0; ii < req->wLength; ii++)
							Debug::Instance()->printf(Debug::ALLWAYS, (char *) "%02X ", CtlEP0OutData[ii]);
						Debug::Instance()->printf(Debug::ALLWAYS, (char *) "\n");
						Report::Instance()->ProcessReport(CtlEP0OutData);
						USBD_CtlPrepareRx(pdev, CtlEP0OutData, sizeof(CtlEP0OutData));
							
						return USBD_OK; 
						break;

The first time I get here the buffer is empty, the second time is shows data from 1st transfer. Bus analysis says the data is being transferred as exepected. Moving USBD_CtlPrepareRx before the print (even with a delay) does not change the behavior.

Thanks for looking,

Rob

This topic has been closed for replies.
RobG
RobGBest answer
Associate III
Mar 13, 2020 7:07 PM UTC

SOLVED

That part was just fine. You need to add an EP0 Rx Ready handler in the ClassTypeDef declaration. This is much clearer in the custom HID example.

1 reply

RobG
RobGAuthorBest answer
Associate III
Mar 13, 2020 7:07 PM UTC

SOLVED

That part was just fine. You need to add an EP0 Rx Ready handler in the ClassTypeDef declaration. This is much clearer in the custom HID example.