Fixed interrupt driven HID device demos not clearing the interrupt flags in all circu...
[pub/USBasp.git] / Demos / KeyboardViaInt / KeyboardViaInt.c
index 7f6fcd8..7916506 100644 (file)
@@ -391,7 +391,16 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
        {\r
                USB_KeyboardReport_Data_t KeyboardReportData;\r
                bool                      SendReport;\r
-       \r
+\r
+               /* Select the Keyboard Report Endpoint */\r
+               Endpoint_SelectEndpoint(KEYBOARD_EPNUM);\r
+\r
+               /* Clear the endpoint IN interrupt flag */\r
+               USB_INT_Clear(ENDPOINT_INT_IN);\r
+\r
+               /* Clear the Keyboard Report endpoint interrupt */\r
+               Endpoint_ClearEndpointInterrupt(KEYBOARD_EPNUM);\r
+\r
                /* Create the next keyboard report for transmission to the host */\r
                SendReport = GetNextReport(&KeyboardReportData);\r
        \r
@@ -408,15 +417,6 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
                /* Check to see if a report should be issued */\r
                if (SendReport)\r
                {\r
-                       /* Select the Keyboard Report Endpoint */\r
-                       Endpoint_SelectEndpoint(KEYBOARD_EPNUM);\r
-\r
-                       /* Clear the endpoint IN interrupt flag */\r
-                       USB_INT_Clear(ENDPOINT_INT_IN);\r
-\r
-                       /* Clear the Keyboard Report endpoint interrupt */\r
-                       Endpoint_ClearEndpointInterrupt(KEYBOARD_EPNUM);\r
-\r
                        /* Write Keyboard Report Data */\r
                        Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));\r
                }\r