/** * Handles HID-specific SETUP request sent by the host. * \param request Pointer to a USBGenericRequest instance. * \return USBRC_SUCCESS if request is handled. */ uint32_t HIDDKeyboard_RequestHandler(const USBGenericRequest *request) { HIDDKeyboard *pKbd = &hiddKeyboard; HIDDFunction *pHidd = &pKbd->hidDrv; TRACE_INFO_WP("Kbd "); /* Process HID requests */ return HIDDFunction_RequestHandler(pHidd, request); }
/** * Handles HID-specific SETUP request sent by the host. * \param request Pointer to a USBGenericRequest instance */ void HIDDMouseDriver_RequestHandler(const USBGenericRequest *request) { HIDDMouseDriver * pMouse = &hiddMouseDriver; HIDDFunction * pHidd = &pMouse->hidDrv; USBDDriver * pUsbd = pHidd->pUsbd; TRACE_INFO("NewReq "); /* Process HID requests */ if (USBRC_SUCCESS == HIDDFunction_RequestHandler(pHidd, request)) { return; } /* Process STD requests */ else { USBDDriver_RequestHandler(pUsbd, request); } }
/** * Handles HID-specific SETUP request sent by the host. * \param request Pointer to a USBGenericRequest instance */ void HIDDTransferDriver_RequestHandler(const USBGenericRequest *request) { HIDDTransferDriver *pDrv = &hiddTransferDriver; HIDDFunction *pHidd = &pDrv->hidFunction; TRACE_INFO("NewReq "); /* Check if this is a standard request */ if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) { /* This is a standard request */ switch (USBGenericRequest_GetRequest(request)) { case USBGenericRequest_GETDESCRIPTOR: /* Check if this is a HID descriptor, otherwise forward it to the standard driver */ if (!HIDDTransferDriver_GetDescriptor( USBGetDescriptorRequest_GetDescriptorType(request), USBGenericRequest_GetLength(request))) { USBDDriver_RequestHandler(pHidd->pUsbd, request); } return; /* Handled, no need to do others */ case USBGenericRequest_CLEARFEATURE: /* Check which is the requested feature */ switch (USBFeatureRequest_GetFeatureSelector(request)) { case USBFeatureRequest_ENDPOINTHALT: { uint8_t ep = USBGenericRequest_GetEndpointNumber(request); if (USBD_IsHalted(ep)) { /* Unhalt endpoint restart OUT EP */ USBD_Unhalt(ep); if (ep == pHidd->bPipeOUT) { HIDDFunction_StartPollingOutputs(pHidd); } } /* and send a zero-length packet */ USBD_Write(0, 0, 0, 0, 0); return; /* Handled, no need to do others */ } } break; } } /* We use different buffer for SetReport */ else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) { switch (USBGenericRequest_GetRequest(request)) { case HIDGenericRequest_SETREPORT: { uint16_t length = USBGenericRequest_GetLength(request); uint8_t type = HIDReportRequest_GetReportType(request); if (type == HIDReportRequest_OUTPUT) { if (length > HIDDTransferDriver_REPORTSIZE) length = HIDDTransferDriver_REPORTSIZE; USBD_Read(0, pDrv->iReportBuf, length, HIDDTransferDriver_ReportReceived, 0); /* No argument to the callback function */ } else { USBD_Stall(0); } } return; /* Handled, no need do others */ } } /* Process HID requests */ if (USBRC_SUCCESS == HIDDFunction_RequestHandler(pHidd, request)) { return; } else USBDDriver_RequestHandler(pHidd->pUsbd, request); }