EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),\r
Attributes: EP_TYPE_INTERRUPT,\r
EndpointSize: KEYBOARD_EPSIZE,\r
- PollingIntervalMS: 0x02\r
+ PollingIntervalMS: 0x04\r
},\r
\r
KeyboardLEDsEndpoint:\r
EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_LEDS_EPNUM),\r
Attributes: EP_TYPE_INTERRUPT,\r
EndpointSize: KEYBOARD_EPSIZE,\r
- PollingIntervalMS: 0x02\r
+ PollingIntervalMS: 0x04\r
}\r
};\r
\r
*/\r
EVENT_HANDLER(USB_Connect)\r
{\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ /* Start USB management task */\r
+ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);\r
+ #endif\r
+\r
/* Indicate USB enumerating */\r
UpdateStatus(Status_USBEnumerating);\r
\r
/** Fills the given HID report data structure with the next HID report to send to the host.\r
*\r
* \param ReportData Pointer to a HID report data structure to be filled\r
- *\r
- * \return Boolean true if the new report differs from the last report, false otherwise\r
*/\r
-bool CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData)\r
+void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData)\r
{\r
- static uint8_t PrevJoyStatus = 0;\r
- uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
- bool InputChanged = false;\r
+ uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
/* Clear the report contents */\r
memset(ReportData, 0, sizeof(USB_KeyboardReport_Data_t));\r
\r
if (JoyStatus_LCL & JOY_PRESS)\r
ReportData->KeyCode[0] = 0x08; // E\r
- \r
- /* Check if the new report is different to the previous report */\r
- InputChanged = (uint8_t)(PrevJoyStatus ^ JoyStatus_LCL);\r
-\r
- /* Save the current joystick status for later comparison */\r
- PrevJoyStatus = JoyStatus_LCL;\r
-\r
- /* Return whether the new report is different to the previous report or not */\r
- return InputChanged;\r
}\r
\r
/** Processes a received LED report, and updates the board LEDs states to match.\r
static inline void SendNextReport(void)\r
{\r
USB_KeyboardReport_Data_t KeyboardReportData;\r
- bool SendReport;\r
+ bool SendReport = true;\r
\r
/* Create the next keyboard report for transmission to the host */\r
- SendReport = CreateKeyboardReport(&KeyboardReportData);\r
+ CreateKeyboardReport(&KeyboardReportData);\r
\r
- /* Check if the idle period is set and has elapsed */\r
- if (IdleCount && !(IdleMSRemaining))\r
+ /* Check if the idle period is set */\r
+ if (IdleCount)\r
{\r
- /* Idle period elapsed, indicate that a report must be sent */\r
- SendReport = true;\r
- \r
- /* Reset the idle time remaining counter, must multiply by 4 to get the duration in milliseconds */\r
- IdleMSRemaining = (IdleCount << 2);\r
+ /* Check if idle period has elapsed */\r
+ if (!(IdleMSRemaining))\r
+ {\r
+ /* Reset the idle time remaining counter, must multiply by 4 to get the duration in milliseconds */\r
+ IdleMSRemaining = (IdleCount << 2);\r
+ }\r
+ else\r
+ {\r
+ /* Idle period not elapsed, indicate that a report must not be sent */\r
+ SendReport = false; \r
+ }\r
}\r
\r
/* Select the Keyboard Report Endpoint */\r
HANDLES_EVENT(USB_UnhandledControlPacket);\r
\r
/* Function Prototypes: */\r
- bool CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData);\r
+ void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData);\r
void ProcessLEDReport(uint8_t LEDReport);\r
static inline void SendNextReport(void);\r
static inline void ReceiveNextReport(void);\r
*/\r
EVENT_HANDLER(USB_Connect)\r
{\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
/* Start USB management task */\r
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);\r
-\r
+ #endif\r
+ \r
/* Indicate USB enumerating */\r
UpdateStatus(Status_USBEnumerating);\r
\r
/** Fills the given HID report data structure with the next HID report to send to the host.\r
*\r
* \param ReportData Pointer to a HID report data structure to be filled\r
- *\r
- * \return Boolean true if the new report differs from the last report, false otherwise\r
*/\r
-bool CreateMouseReport(USB_MouseReport_Data_t* ReportData)\r
+void CreateMouseReport(USB_MouseReport_Data_t* ReportData)\r
{\r
- static uint8_t PrevJoyStatus = 0;\r
- static bool PrevHWBStatus = false;\r
- uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
- bool InputChanged = false;\r
+ uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
/* Clear the report contents */\r
memset(ReportData, 0, sizeof(USB_MouseReport_Data_t));\r
\r
if (HWB_GetStatus())\r
ReportData->Button |= (1 << 1);\r
-\r
- /* Check if the new report is different to the previous report */\r
- InputChanged = ((uint8_t)(PrevJoyStatus ^ JoyStatus_LCL) | (uint8_t)(HWB_GetStatus() ^ PrevHWBStatus));\r
-\r
- /* Save the current joystick and HWB status for later comparison */\r
- PrevJoyStatus = JoyStatus_LCL;\r
- PrevHWBStatus = HWB_GetStatus();\r
-\r
- /* Return whether the new report is different to the previous report or not */\r
- return InputChanged;\r
}\r
\r
/** Sends the next HID report to the host, via the keyboard data endpoint. */\r
HANDLES_EVENT(USB_UnhandledControlPacket);\r
\r
/* Function Prototypes: */\r
- bool CreateMouseReport(USB_MouseReport_Data_t* ReportData);\r
+ void CreateMouseReport(USB_MouseReport_Data_t* ReportData);\r
void UpdateStatus(uint8_t CurrentStatus);\r
\r
#endif\r