diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2012-02-09 20:30:27 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2012-02-09 20:30:27 +0000 |
| commit | 8f7bf45fb31bb3488176e1c9075bb58895520803 (patch) | |
| tree | 7b77dd0aea677621d885febca71948520c5f5da4 /LUFA/Drivers/USB/Class/Device | |
| parent | 64227d2bd66b5a87e318b196089c0d1622551ef0 (diff) | |
Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@2043 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device')
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/HIDClassDevice.c | 5 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Class/Device/HIDClassDevice.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c index d756b092..5c8d878e 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c @@ -156,6 +156,9 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) if (USB_DeviceState != DEVICE_STATE_Configured) return; + if (HIDInterfaceInfo->State.PrevFrameNum == USB_Device_GetFrameNumber()) + return; + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber); if (Endpoint_IsReadWriteAllowed()) @@ -190,6 +193,8 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) Endpoint_ClearIN(); } + + HIDInterfaceInfo->State.PrevFrameNum = USB_Device_GetFrameNumber(); } } diff --git a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h index ab86da45..95389f37 100644 --- a/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h +++ b/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h @@ -113,6 +113,7 @@ struct { bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode. */ + uint16_t PrevFrameNum; /**< Frame number of the previous HID report packet opportunity. */ uint16_t IdleCount; /**< Report idle period, in milliseconds, set by the host. */ uint16_t IdleMSRemaining; /**< Total number of milliseconds remaining before the idle period elapsed - this * should be decremented by the user application if non-zero each millisecond. */ |
