Add new HID_Device_MillisecondElapsed() function to the HID device Class driver,...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 30 Jul 2009 14:59:57 +0000 (14:59 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 30 Jul 2009 14:59:57 +0000 (14:59 +0000)
Demos/Device/ClassDriver/DualCDC/DualCDC.c
Demos/Device/ClassDriver/GenericHID/GenericHID.c
Demos/Device/ClassDriver/Joystick/Joystick.c
Demos/Device/ClassDriver/Keyboard/Keyboard.c
Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
Demos/Device/ClassDriver/Mouse/Mouse.c
LUFA/Drivers/USB/Class/Device/HID.c
LUFA/Drivers/USB/Class/Device/HID.h
Projects/Magstripe/Magstripe.c

index 9e3217c..82ed59d 100644 (file)
@@ -78,11 +78,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface =
                                .NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,\r
                                .NotificationEndpointSize   = CDC_NOTIFICATION_EPSIZE,\r
                        },\r
                                .NotificationEndpointNumber = CDC2_NOTIFICATION_EPNUM,\r
                                .NotificationEndpointSize   = CDC_NOTIFICATION_EPSIZE,\r
                        },\r
-                       \r
-               .State =\r
-                       {\r
-                               // Leave all state values to their defaults\r
-                       }\r
        };\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
        };\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
index b04f7af..4315723 100644 (file)
@@ -118,8 +118,7 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Generic_HID_Interface.State.IdleMSRemaining)\r
-         Generic_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Generic_HID_Interface);\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
index d9ff6ca..ffd167e 100644 (file)
@@ -120,8 +120,7 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Joystick_HID_Interface.State.IdleMSRemaining)\r
-         Joystick_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Joystick_HID_Interface);\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
index cd8c3e6..fb19d02 100644 (file)
@@ -121,8 +121,7 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Keyboard_HID_Interface.State.IdleMSRemaining)\r
-         Keyboard_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
index 45a2c52..418ccba 100644 (file)
@@ -66,12 +66,7 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
 \r
                                .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
                                .ReportINEndpointSize    = HID_EPSIZE,\r
 \r
                                .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
                                .ReportINEndpointSize    = HID_EPSIZE,\r
-                       },\r
-                       \r
-               .State =\r
-                       {\r
-                               // Leave all state values to their defaults\r
-                       }                       \r
+                       },              \r
        };\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
        };\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
@@ -147,11 +142,8 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Keyboard_HID_Interface.State.IdleMSRemaining)\r
-         Keyboard_HID_Interface.State.IdleMSRemaining--;\r
-\r
-       if (Mouse_HID_Interface.State.IdleMSRemaining)\r
-         Mouse_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);\r
+       HID_Device_MillisecondElapsed(&Mouse_HID_Interface);\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
index 4489434..51021c0 100644 (file)
@@ -120,8 +120,7 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Mouse_HID_Interface.State.IdleMSRemaining)\r
-         Mouse_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Mouse_HID_Interface);\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
index bfe97ff..eef15f2 100644 (file)
@@ -184,4 +184,10 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo)\r
+{\r
+       if (HIDInterfaceInfo->State.IdleMSRemaining)\r
+         HIDInterfaceInfo->State.IdleMSRemaining--;\r
+}\r
+\r
 #endif\r
 #endif\r
index ae68134..06456cf 100644 (file)
                         */\r
                        void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);\r
                        \r
                         */\r
                        void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);\r
                        \r
+                       /** Indicates that a millisecond of idle time has elapsed on the given HID interface, and the interface's idle count should be\r
+                        *  decremented. This should be called once per millisecond so that hardware key-repeats function correctly.\r
+                        *\r
+                        *  \param[in,out] HIDInterfaceInfo  Pointer to a structure containing a HID Class configuration and state.\r
+                        */\r
+                       void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo);\r
+                       \r
                        /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either\r
                         *  HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the\r
                         *  user is responsible for the creation of the next HID input report to be sent to the host.\r
                        /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either\r
                         *  HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the\r
                         *  user is responsible for the creation of the next HID input report to be sent to the host.\r
index 898ad3c..6d463d6 100644 (file)
@@ -153,8 +153,7 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** Timer 0 CTC ISR, firing once each millisecond to keep track of elapsed idle time in the HID interface. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
 /** Timer 0 CTC ISR, firing once each millisecond to keep track of elapsed idle time in the HID interface. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Keyboard_HID_Interface.State.IdleMSRemaining)\r
-         Keyboard_HID_Interface.State.IdleMSRemaining--;\r
+       HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);\r
 }\r
 \r
 /** HID Class driver callback function for the creation of a HID report for the host.\r
 }\r
 \r
 /** HID Class driver callback function for the creation of a HID report for the host.\r