TASK_LIST\r
{\r
#if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
- { Task: USB_USBTask , TaskStatus: TASK_STOP },\r
+ { .Task = USB_USBTask , .TaskStatus = TASK_STOP },\r
#endif\r
\r
#if !defined(INTERRUPT_DATA_ENDPOINT)\r
- { Task: USB_Mouse_Report , TaskStatus: TASK_STOP },\r
+ { .Task = USB_Mouse_Report , .TaskStatus = TASK_STOP },\r
#endif\r
};\r
\r
/* Hardware Initialization */\r
Joystick_Init();\r
LEDs_Init();\r
- HWB_Init();\r
+ Buttons_Init();\r
\r
/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */\r
OCR0A = 0x7D;\r
EVENT_HANDLER(USB_UnhandledControlPacket)\r
{\r
/* Handle HID Class specific requests */\r
- switch (bRequest)\r
+ switch (USB_ControlRequest.bRequest)\r
{\r
case REQ_GetReport:\r
- if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
USB_MouseReport_Data_t MouseReportData;\r
\r
+ Endpoint_ClearSETUP();\r
+\r
/* Create the next mouse report for transmission to the host */\r
CreateMouseReport(&MouseReportData);\r
-\r
- /* Ignore report type and ID number value */\r
- Endpoint_Discard_Word();\r
- \r
- /* Ignore unused Interface number value */\r
- Endpoint_Discard_Word();\r
-\r
- /* Read in the number of bytes in the report to send to the host */\r
- uint16_t wLength = Endpoint_Read_Word_LE();\r
- \r
- /* If trying to send more bytes than exist to the host, clamp the value at the report size */\r
- if (wLength > sizeof(MouseReportData))\r
- wLength = sizeof(MouseReportData);\r
-\r
- Endpoint_ClearControlSETUP();\r
\r
/* Write the report data to the control endpoint */\r
- Endpoint_Write_Control_Stream_LE(&MouseReportData, wLength);\r
+ Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
\r
/* Clear the report data afterwards */\r
memset(&MouseReportData, 0, sizeof(MouseReportData));\r
\r
/* Finalize the stream transfer to send the last packet or clear the host abort */\r
- Endpoint_ClearControlOUT();\r
+ Endpoint_ClearOUT();\r
}\r
\r
break;\r
case REQ_GetProtocol:\r
- if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
- Endpoint_ClearControlSETUP();\r
+ Endpoint_ClearSETUP();\r
\r
/* Write the current protocol flag to the host */\r
Endpoint_Write_Byte(UsingReportProtocol);\r
\r
/* Send the flag to the host */\r
- Endpoint_ClearControlIN();\r
+ Endpoint_ClearIN();\r
\r
/* Acknowledge status stage */\r
while (!(Endpoint_IsOUTReceived()));\r
- Endpoint_ClearControlOUT();\r
+ Endpoint_ClearOUT();\r
}\r
\r
break;\r
case REQ_SetProtocol:\r
- if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
- /* Read in the wValue parameter containing the new protocol mode */\r
- uint16_t wValue = Endpoint_Read_Word_LE();\r
- \r
- Endpoint_ClearControlSETUP();\r
+ Endpoint_ClearSETUP();\r
\r
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
- UsingReportProtocol = (wValue != 0x0000);\r
+ UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000);\r
\r
/* Acknowledge status stage */\r
while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearControlIN();\r
+ Endpoint_ClearIN();\r
}\r
\r
break;\r
case REQ_SetIdle:\r
- if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
- /* Read in the wValue parameter containing the idle period */\r
- uint16_t wValue = Endpoint_Read_Word_LE();\r
- \r
- Endpoint_ClearControlSETUP();\r
+ Endpoint_ClearSETUP();\r
\r
/* Get idle period in MSB */\r
- IdleCount = (wValue >> 8);\r
+ IdleCount = (USB_ControlRequest.wValue >> 8);\r
\r
/* Acknowledge status stage */\r
while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearControlIN();\r
+ Endpoint_ClearIN();\r
}\r
\r
break;\r
case REQ_GetIdle:\r
- if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
{ \r
- Endpoint_ClearControlSETUP();\r
+ Endpoint_ClearSETUP();\r
\r
/* Write the current idle duration to the host */\r
Endpoint_Write_Byte(IdleCount);\r
\r
/* Send the flag to the host */\r
- Endpoint_ClearControlIN();\r
+ Endpoint_ClearIN();\r
\r
/* Acknowledge status stage */\r
while (!(Endpoint_IsOUTReceived()));\r
- Endpoint_ClearControlOUT();\r
+ Endpoint_ClearOUT();\r
}\r
\r
break;\r
*/\r
void CreateMouseReport(USB_MouseReport_Data_t* ReportData)\r
{\r
- uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
+ uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
+ uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
\r
/* Clear the report contents */\r
memset(ReportData, 0, sizeof(USB_MouseReport_Data_t));\r
if (JoyStatus_LCL & JOY_PRESS)\r
ReportData->Button = (1 << 0);\r
\r
- if (HWB_GetStatus())\r
+ if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
ReportData->Button |= (1 << 1);\r
}\r
\r