aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/LowLevel
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-15 05:49:19 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-15 05:49:19 +0000
commitf85a53a31b00190ad726f509ad275079fc6eb994 (patch)
tree63e7020319026cab9cc6e1e49a11f13a024462a8 /Demos/Device/LowLevel
parentda138684e428a40f7f5a0c32617e5c62c9e3a664 (diff)
downloadlufa-f85a53a31b00190ad726f509ad275079fc6eb994.tar.gz
lufa-f85a53a31b00190ad726f509ad275079fc6eb994.tar.bz2
lufa-f85a53a31b00190ad726f509ad275079fc6eb994.zip
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.
Diffstat (limited to 'Demos/Device/LowLevel')
-rw-r--r--Demos/Device/LowLevel/Keyboard/Keyboard.c12
-rw-r--r--Demos/Device/LowLevel/Mouse/Mouse.c12
2 files changed, 12 insertions, 12 deletions
diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.c b/Demos/Device/LowLevel/Keyboard/Keyboard.c
index 185d968d7..252714808 100644
--- a/Demos/Device/LowLevel/Keyboard/Keyboard.c
+++ b/Demos/Device/LowLevel/Keyboard/Keyboard.c
@@ -225,8 +225,8 @@ void EVENT_USB_UnhandledControlPacket(void)
{
Endpoint_ClearSETUP();
- /* Get idle period in MSB */
- IdleCount = (USB_ControlRequest.wValue >> 8);
+ /* Get idle period in MSB, IdleCount must be multiplied by 4 to get number of milliseconds */
+ IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6);
/* Acknowledge status stage */
while (!(Endpoint_IsINReady()));
@@ -239,8 +239,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();
@@ -329,8 +329,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;
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;