Fixed interrupt driven HID device demos not clearing the interrupt flags in all circu...
[pub/USBasp.git] / Demos / MouseViaInt / MouseViaInt.c
index 77e4c56..a4b863c 100644 (file)
@@ -345,6 +345,15 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
                USB_MouseReport_Data_t MouseReportData;\r
                bool                   SendReport = true;\r
                \r
+               /* Select the Mouse Report Endpoint */\r
+               Endpoint_SelectEndpoint(MOUSE_EPNUM);\r
+\r
+               /* Clear the endpoint IN interrupt flag */\r
+               USB_INT_Clear(ENDPOINT_INT_IN);\r
+\r
+               /* Clear the Mouse Report endpoint interrupt and select the endpoint */\r
+               Endpoint_ClearEndpointInterrupt(MOUSE_EPNUM);\r
+\r
                /* Create the next mouse report for transmission to the host */\r
                GetNextReport(&MouseReportData);\r
                \r
@@ -367,15 +376,6 @@ ISR(ENDPOINT_PIPE_vect, ISR_BLOCK)
                /* Check to see if a report should be issued */\r
                if (SendReport)\r
                {\r
-                       /* Select the Mouse Report Endpoint */\r
-                       Endpoint_SelectEndpoint(MOUSE_EPNUM);\r
-\r
-                       /* Clear the endpoint IN interrupt flag */\r
-                       USB_INT_Clear(ENDPOINT_INT_IN);\r
-\r
-                       /* Clear the Mouse Report endpoint interrupt and select the endpoint */\r
-                       Endpoint_ClearEndpointInterrupt(MOUSE_EPNUM);\r
-\r
                        /* Write Mouse Report Data */\r
                        Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
                }\r