USB_HostRequest renamed to USB_ControlRequest, entire control request header is now...
[pub/USBasp.git] / Demos / Device / Keyboard / Keyboard.c
index 6d7ee3f..088943b 100644 (file)
@@ -193,33 +193,20 @@ 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
                                USB_KeyboardReport_Data_t KeyboardReportData;\r
 \r
                                /* Create the next keyboard report for transmission to the host */\r
                                CreateKeyboardReport(&KeyboardReportData);\r
 \r
-                               /* Ignore report type and ID number value */\r
-                               Endpoint_Discard_Word();\r
-                               \r
-                               /* Ignore unused Interface number value */\r
-                               Endpoint_Discard_Word();\r
-\r
-                               /* Read in the number of bytes in the report to send to the host */\r
-                               uint16_t wLength = Endpoint_Read_Word_LE();\r
-                               \r
-                               /* If trying to send more bytes than exist to the host, clamp the value at the report size */\r
-                               if (wLength > sizeof(KeyboardReportData))\r
-                                 wLength = sizeof(KeyboardReportData);\r
-\r
                                Endpoint_ClearSETUP();\r
        \r
                                /* Write the report data to the control endpoint */\r
-                               Endpoint_Write_Control_Stream_LE(&KeyboardReportData, wLength);\r
+                               Endpoint_Write_Control_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
                                \r
                                /* Finalize the stream transfer to send the last packet or clear the host abort */\r
                                Endpoint_ClearOUT();\r
@@ -227,7 +214,7 @@ 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
                                Endpoint_ClearSETUP();\r
                                \r
@@ -250,7 +237,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        \r
                        break;\r
                case REQ_GetProtocol:\r
-                       if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
                                Endpoint_ClearSETUP();\r
                                \r
@@ -267,15 +254,12 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        \r
                        break;\r
                case REQ_SetProtocol:\r
-                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Read in the wValue parameter containing the new protocol mode */\r
-                               uint16_t wValue = Endpoint_Read_Word_LE();\r
-                                                               \r
                                Endpoint_ClearSETUP();\r
 \r
                                /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
-                               UsingReportProtocol = (wValue != 0x0000);\r
+                               UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000);\r
 \r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
@@ -284,15 +268,12 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        \r
                        break;\r
                case REQ_SetIdle:\r
-                       if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {\r
-                               /* Read in the wValue parameter containing the idle period */\r
-                               uint16_t wValue = Endpoint_Read_Word_LE();\r
-                               \r
                                Endpoint_ClearSETUP();\r
                                \r
                                /* Get idle period in MSB */\r
-                               IdleCount = (wValue >> 8);\r
+                               IdleCount = (USB_ControlRequest.wValue >> 8);\r
                                \r
                                /* Acknowledge status stage */\r
                                while (!(Endpoint_IsINReady()));\r
@@ -301,7 +282,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
                        \r
                        break;\r
                case REQ_GetIdle:\r
-                       if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+                       if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
                        {               \r
                                Endpoint_ClearSETUP();\r
                                \r