From f85a53a31b00190ad726f509ad275079fc6eb994 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 15 Jul 2009 05:49:19 +0000 Subject: Fix HID class device driver -- if a SetIDle request is issued with the LSB of wValue set to zero, the idle period must be set for all HID interfaces. Fix Keyboard and Mouse demos, Idle period is now multiplied by 4 as the period is read into and sent out of the device to ensure it is always stored as a multiple of 1ms. Fixes Keyboard demo using an initial Idle period of 2s rather than 500ms (thanks to Brian Dickman). Move out the internal device serial descriptor reading routine into a seperate static function, rather than being part of USB_Device_GetDescriptor. --- Demos/Device/LowLevel/Mouse/Mouse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Demos/Device/LowLevel/Mouse/Mouse.c') diff --git a/Demos/Device/LowLevel/Mouse/Mouse.c b/Demos/Device/LowLevel/Mouse/Mouse.c index c0989c5db..60eb7fad7 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.c +++ b/Demos/Device/LowLevel/Mouse/Mouse.c @@ -197,8 +197,8 @@ void EVENT_USB_UnhandledControlPacket(void) { Endpoint_ClearSETUP(); - /* Get idle period in MSB */ - IdleCount = (USB_ControlRequest.wValue >> 8); + /* Get idle period in MSB, must multiply by 4 to get the duration in milliseconds */ + IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); @@ -211,8 +211,8 @@ void EVENT_USB_UnhandledControlPacket(void) { Endpoint_ClearSETUP(); - /* Write the current idle duration to the host */ - Endpoint_Write_Byte(IdleCount); + /* Write the current idle duration to the host, must be divided by 4 before sent to host */ + Endpoint_Write_Byte(IdleCount >> 2); /* Send the flag to the host */ Endpoint_ClearIN(); @@ -289,8 +289,8 @@ void SendNextReport(void) /* Check if the idle period is set and has elapsed */ if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining))) { - /* Reset the idle time remaining counter, must multiply by 4 to get the duration in milliseconds */ - IdleMSRemaining = (IdleCount << 2); + /* Reset the idle time remaining counter */ + IdleMSRemaining = IdleCount; /* Idle period is set and has elapsed, must send a report to the host */ SendReport = true; -- cgit v1.2.3