diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-08-22 03:26:20 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-08-22 03:26:20 +0000 |
commit | 4cc7f5200beef90c39c8c8310ed7c8b849afb4d9 (patch) | |
tree | a8e2e56961f7e39b888e4ded0c38c5ab9cf6f5b6 /LUFA/Drivers/USB/Class/Device/HID.c | |
parent | 1be3436e895c9937dcd4ebbec33ea199f3e26db2 (diff) | |
download | lufa-4cc7f5200beef90c39c8c8310ed7c8b849afb4d9.tar.gz lufa-4cc7f5200beef90c39c8c8310ed7c8b849afb4d9.tar.bz2 lufa-4cc7f5200beef90c39c8c8310ed7c8b849afb4d9.zip |
Changed all Device mode LowLevel demos and Device Class drivers so that the control request is acknowledged and any data transferred as quickly as possible without any processing inbetween sections, so that long callbacks or event handlers will not break communications with the host by exceeding the maximum control request stage timeout period.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device/HID.c')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 203023142..e38d35a5a 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -48,8 +48,6 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter case REQ_GetReport: if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { - Endpoint_ClearSETUP(); - uint16_t ReportSize = 0; uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; @@ -62,6 +60,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, HIDInterfaceInfo->Config.PrevReportINBufferSize); + Endpoint_ClearSETUP(); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); Endpoint_ClearOUT(); @@ -71,16 +70,16 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter case REQ_SetReport: if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { - Endpoint_ClearSETUP(); - uint16_t ReportSize = USB_ControlRequest.wLength; uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; uint8_t ReportData[ReportSize]; + Endpoint_ClearSETUP(); Endpoint_Read_Control_Stream_LE(ReportData, ReportSize); - CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize); Endpoint_ClearIN(); + + CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize); } break; @@ -88,10 +87,8 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); - Endpoint_Write_Byte(HIDInterfaceInfo->State.UsingReportProtocol); Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); } @@ -100,10 +97,9 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); - - HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); - Endpoint_ClearStatusStage(); + + HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); } break; @@ -111,10 +107,9 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); - - HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); - Endpoint_ClearStatusStage(); + + HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); } break; @@ -122,10 +117,8 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); - Endpoint_Write_Byte(HIDInterfaceInfo->State.IdleCount >> 2); Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); } |