Skip to main content
Visitor II
March 13, 2020
Solved

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

  • March 13, 2020
  • 1 reply
  • 872 views

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.
    Best answer by RobG

    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

    RobGAuthorAnswer
    Visitor II
    March 13, 2020

    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.