\r
#include "GenericHID.h"\r
\r
-/* Project Tags, for reading out using the ButtLoad project */\r
-BUTTLOADTAG(ProjName, "LUFA GenHID App");\r
-BUTTLOADTAG(BuildTime, __TIME__);\r
-BUTTLOADTAG(BuildDate, __DATE__);\r
-BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);\r
-\r
/* Scheduler Task List */\r
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_HID_Report , TaskStatus: TASK_STOP },\r
+ { .Task = USB_HID_Report , .TaskStatus = TASK_STOP },\r
#endif\r
};\r
\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
- Endpoint_ClearSetupReceived();\r
- \r
uint8_t GenericData[GENERIC_REPORT_SIZE];\r
- \r
+\r
+ Endpoint_ClearSETUP();\r
+ \r
CreateGenericHIDReport(GenericData);\r
\r
/* Write the report data to the control endpoint */\r
Endpoint_Write_Control_Stream_LE(&GenericData, sizeof(GenericData));\r
\r
/* Finalize the stream transfer to send the last packet or clear the host abort */\r
- Endpoint_ClearSetupOUT();\r
+ Endpoint_ClearOUT();\r
}\r
\r
break;\r
case REQ_SetReport:\r
- if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
- Endpoint_ClearSetupReceived();\r
+ uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+\r
+ Endpoint_ClearSETUP();\r
\r
/* Wait until the generic report has been sent by the host */\r
- while (!(Endpoint_IsSetupOUTReceived()));\r
-\r
- uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+ while (!(Endpoint_IsOUTReceived()));\r
\r
- Endpoint_Read_Control_Stream(&GenericData, sizeof(GenericData));\r
+ Endpoint_Read_Control_Stream_LE(&GenericData, sizeof(GenericData));\r
\r
ProcessGenericHIDReport(GenericData);\r
\r
/* Clear the endpoint data */\r
- Endpoint_ClearSetupOUT();\r
+ Endpoint_ClearOUT();\r
\r
/* Wait until the host is ready to receive the request confirmation */\r
- while (!(Endpoint_IsSetupINReady()));\r
+ while (!(Endpoint_IsINReady()));\r
\r
/* Handshake the request by sending an empty IN packet */\r
- Endpoint_ClearSetupIN();\r
+ Endpoint_ClearIN();\r
}\r
\r
break;\r
{\r
Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM);\r
\r
- if (Endpoint_ReadWriteAllowed())\r
+ /* Check to see if a packet has been sent from the host */\r
+ if (Endpoint_IsOUTReceived())\r
{\r
- /* Create a temporary buffer to hold the read in report from the host */\r
- uint8_t GenericData[GENERIC_REPORT_SIZE];\r
- \r
- /* Read Generic Report Data */\r
- Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));\r
- \r
- /* Process Generic Report Data */\r
- ProcessGenericHIDReport(GenericData);\r
+ /* Check to see if the packet contains data */\r
+ if (Endpoint_IsReadWriteAllowed())\r
+ {\r
+ /* Create a temporary buffer to hold the read in report from the host */\r
+ uint8_t GenericData[GENERIC_REPORT_SIZE];\r
+ \r
+ /* Read Generic Report Data */\r
+ Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));\r
+ \r
+ /* Process Generic Report Data */\r
+ ProcessGenericHIDReport(GenericData);\r
+ }\r
\r
/* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearOUT();\r
} \r
\r
Endpoint_SelectEndpoint(GENERIC_IN_EPNUM);\r
\r
- if (Endpoint_ReadWriteAllowed())\r
+ /* Check to see if the host is ready to accept another packet */\r
+ if (Endpoint_IsINReady())\r
{\r
/* Create a temporary buffer to hold the report to send to the host */\r
uint8_t GenericData[GENERIC_REPORT_SIZE];\r
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));\r
\r
/* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearIN();\r
}\r
}\r
}\r
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));\r
\r
/* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearIN();\r
}\r
\r
/* Check if Generic OUT endpoint has interrupted */\r
ProcessGenericHIDReport(GenericData);\r
\r
/* Finalize the stream transfer to send the last packet */\r
- Endpoint_ClearCurrentBank();\r
+ Endpoint_ClearOUT();\r
}\r
#endif\r
\r