{\r
Endpoint_ClearSETUP();\r
\r
- /* Get idle period in MSB */\r
- IdleCount = (USB_ControlRequest.wValue >> 8);\r
+ /* Get idle period in MSB, must multiply by 4 to get the duration in milliseconds */\r
+ IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6);\r
\r
/* Acknowledge status stage */\r
while (!(Endpoint_IsINReady()));\r
{ \r
Endpoint_ClearSETUP();\r
\r
- /* Write the current idle duration to the host */\r
- Endpoint_Write_Byte(IdleCount);\r
+ /* Write the current idle duration to the host, must be divided by 4 before sent to host */\r
+ Endpoint_Write_Byte(IdleCount >> 2);\r
\r
/* Send the flag to the host */\r
Endpoint_ClearIN();\r
/* Check if the idle period is set and has elapsed */\r
if ((IdleCount != HID_IDLE_CHANGESONLY) && (!(IdleMSRemaining)))\r
{\r
- /* Reset the idle time remaining counter, must multiply by 4 to get the duration in milliseconds */\r
- IdleMSRemaining = (IdleCount << 2);\r
+ /* Reset the idle time remaining counter */\r
+ IdleMSRemaining = IdleCount;\r
\r
/* Idle period is set and has elapsed, must send a report to the host */\r
SendReport = true;\r