Removed new Start of Frame event from the library; performance suffered far too much...
[pub/USBasp.git] / Demos / Device / Mouse / Mouse.c
index 57c1aa1..01ead00 100644 (file)
@@ -37,7 +37,7 @@ USB_ClassInfo_HID_t Mouse_HID_Interface =
                .ReportINEndpointNumber  = MOUSE_EPNUM,\r
                .ReportINEndpointSize    = MOUSE_EPSIZE,\r
 \r
-               .ReportBufferSize        = sizeof(USB_MouseReport_Data_t),\r
+               .ReportINBufferSize      = sizeof(USB_MouseReport_Data_t),\r
        };\r
 \r
 int main(void)\r
@@ -67,6 +67,12 @@ void SetupHardware(void)
        LEDs_Init();\r
        Buttons_Init();\r
        USB_Init();\r
+\r
+       /* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */\r
+       OCR0A  = ((F_CPU / 64) / 1000);\r
+       TCCR0A = (1 << WGM01);\r
+       TCCR0B = ((1 << CS01) | (1 << CS00));\r
+       TIMSK0 = (1 << OCIE0A);\r
 }\r
 \r
 void EVENT_USB_Connect(void)\r
@@ -92,9 +98,10 @@ void EVENT_USB_UnhandledControlPacket(void)
        USB_HID_ProcessControlPacket(&Mouse_HID_Interface);\r
 }\r
 \r
-void EVENT_USB_StartOfFrame(void)\r
+ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       USB_HID_RegisterStartOfFrame(&Mouse_HID_Interface);\r
+       if (Mouse_HID_Interface.IdleMSRemaining)\r
+         Mouse_HID_Interface.IdleMSRemaining--;\r
 }\r
 \r
 uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r