Fixed inability to enumerate any devices while in host mode (broken in a previous...
[pub/USBasp.git] / Demos / Device / GenericHID / GenericHID.c
index 207f63c..695342d 100644 (file)
@@ -160,15 +160,15 @@ EVENT_HANDLER(USB_ConfigurationChanged)
 EVENT_HANDLER(USB_UnhandledControlPacket)\r
 {\r
        /* Handle HID Class specific requests */\r
-       switch (bRequest)\r
+       switch (USB_ControlRequest.bRequest)\r
        {\r
                case REQ_GetReport:\r
-                       if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+\r
                                Endpoint_ClearSETUP();\r
        \r
-                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
-                               \r
                                CreateGenericHIDReport(GenericData);\r
 \r
                                /* Write the report data to the control endpoint */\r
@@ -180,15 +180,15 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                \r
                        break;\r
                case REQ_SetReport:\r
-                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
+                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+\r
                                Endpoint_ClearSETUP();\r
                                \r
                                /* Wait until the generic report has been sent by the host */\r
                                while (!(Endpoint_IsOUTReceived()));\r
 \r
-                               uint8_t GenericData[GENERIC_REPORT_SIZE];\r
-\r
                                Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));\r
 \r
                                ProcessGenericHIDReport(GenericData);\r