Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver...
[pub/lufa.git] / Demos / Host / KeyboardHost / KeyboardHost.c
index fe95c34..f73e568 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
               "Keyboard 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
@@ -263,7 +263,7 @@ TASK(USB_Keyboard_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
@@ -310,7 +310,7 @@ TASK(USB_Keyboard_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 Protocol).\r\n"));\r
@@ -350,6 +350,9 @@ TASK(USB_Keyboard_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 keyboard data pipe has caused the interrupt */\r
        if (Pipe_HasPipeInterrupted(KEYBOARD_DATAPIPE))\r
        {\r
@@ -366,5 +369,8 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
                        /* Read and process the next report from the device */\r
                        ReadNextReport();\r
        }\r
+       \r
+       /* Restore previously selected pipe */\r
+       Pipe_SelectPipe(PrevSelectedPipe);\r
 }\r
 #endif\r