Removed new Start of Frame event from the library; performance suffered far too much...
[pub/USBasp.git] / Demos / Device / KeyboardMouse / KeyboardMouse.c
index 8f6a573..71a8375 100644 (file)
@@ -41,7 +41,7 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
                .ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM,\r
                .ReportOUTEndpointSize   = HID_EPSIZE,\r
                \r
                .ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM,\r
                .ReportOUTEndpointSize   = HID_EPSIZE,\r
                \r
-               .ReportBufferSize        = sizeof(USB_KeyboardReport_Data_t),\r
+               .ReportINBufferSize      = sizeof(USB_KeyboardReport_Data_t),\r
 \r
                .IdleCount               = 500,\r
        };\r
 \r
                .IdleCount               = 500,\r
        };\r
@@ -53,7 +53,7 @@ USB_ClassInfo_HID_t Mouse_HID_Interface =
                .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
                .ReportINEndpointSize    = HID_EPSIZE,\r
 \r
                .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
                .ReportINEndpointSize    = HID_EPSIZE,\r
 \r
-               .ReportBufferSize        = sizeof(USB_MouseReport_Data_t),\r
+               .ReportINBufferSize      = sizeof(USB_MouseReport_Data_t),\r
 \r
                .ReportOUTEndpointNumber = 0,\r
                .ReportOUTEndpointSize   = 0,\r
 \r
                .ReportOUTEndpointNumber = 0,\r
                .ReportOUTEndpointSize   = 0,\r
@@ -85,7 +85,13 @@ void SetupHardware()
        /* Hardware Initialization */\r
        Joystick_Init();\r
        LEDs_Init();\r
        /* Hardware Initialization */\r
        Joystick_Init();\r
        LEDs_Init();\r
-       USB_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
 }\r
 \r
 void EVENT_USB_Connect(void)\r
@@ -115,10 +121,13 @@ void EVENT_USB_UnhandledControlPacket(void)
        USB_HID_ProcessControlPacket(&Mouse_HID_Interface);\r
 }\r
 \r
        USB_HID_ProcessControlPacket(&Mouse_HID_Interface);\r
 }\r
 \r
-void EVENT_USB_StartOfFrame(void)\r
+ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 {\r
-       USB_HID_RegisterStartOfFrame(&Keyboard_HID_Interface);\r
-       USB_HID_RegisterStartOfFrame(&Mouse_HID_Interface);\r
+       if (Keyboard_HID_Interface.IdleMSRemaining)\r
+         Keyboard_HID_Interface.IdleMSRemaining--;\r
+\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
 }\r
 \r
 uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r