Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver...
[pub/USBasp.git] / Demos / Host / GenericHIDHost / GenericHIDHost.c
index 625ca70..778b8f6 100644 (file)
@@ -75,7 +75,7 @@ int main(void)
        /* Initialize USB Subsystem */\r
        USB_Init();\r
 \r
-       /* Startup message */\r
+       /* Start-up message */\r
        puts_P(PSTR(ESC_RESET ESC_BG_WHITE ESC_INVERSE_ON ESC_ERASE_DISPLAY\r
               "Generic HID Host Demo running.\r\n" ESC_INVERSE_OFF));\r
                   \r
@@ -132,7 +132,7 @@ EVENT_HANDLER(USB_HostError)
        for(;;);\r
 }\r
 \r
-/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occured while\r
+/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while\r
  *  enumerating an attached USB device.\r
  */\r
 EVENT_HANDLER(USB_DeviceEnumerationFailed)\r
@@ -288,7 +288,7 @@ TASK(USB_HID_Host)
                                        wLength:       0,\r
                                };\r
 \r
-                       /* Send the request, display error and wait for device detatch if request fails */\r
+                       /* Send the request, display error and wait for device detach if request fails */\r
                        if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
                        {\r
                                puts_P(PSTR("Control Error (Set Configuration).\r\n"));\r
@@ -350,6 +350,9 @@ TASK(USB_HID_Host)
  */\r
 ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)\r
 {\r
+       /* Save previously selected pipe before selecting a new pipe */\r
+       uint8_t PrevSelectedPipe = Pipe_GetCurrentPipe();\r
+\r
        /* Check to see if the HID data IN pipe has caused the interrupt */\r
        if (Pipe_HasPipeInterrupted(HID_DATA_IN_PIPE))\r
        {\r
@@ -367,5 +370,8 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
                        ReadNextReport();\r
                }\r
        }\r
+\r
+       /* Restore previously selected pipe */\r
+       Pipe_SelectPipe(PrevSelectedPipe);\r
 }\r
 #endif\r