/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and\r
* starts the library USB task to begin the enumeration and USB management process.\r
*/\r
-void EVENT_USB_Connect(void)\r
+void EVENT_USB_Device_Connect(void)\r
{\r
/* Indicate USB enumerating */\r
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via\r
* the status LEDs and stops the USB management task.\r
*/\r
-void EVENT_USB_Disconnect(void)\r
+void EVENT_USB_Device_Disconnect(void)\r
{\r
/* Indicate USB not ready */\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
/** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration\r
* of the USB device after enumeration, and configures the keyboard and mouse device endpoints.\r
*/\r
-void EVENT_USB_ConfigurationChanged(void)\r
+void EVENT_USB_Device_ConfigurationChanged(void)\r
{\r
/* Indicate USB connected and ready */\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
* control requests that are not handled internally by the USB library (including the HID commands, which are\r
* all issued via the control endpoint), so that they can be handled appropriately for the application.\r
*/\r
-void EVENT_USB_UnhandledControlPacket(void)\r
+void EVENT_USB_Device_UnhandledControlRequest(void)\r
{\r
uint8_t* ReportData;\r
uint8_t ReportSize;\r
Endpoint_ClearSETUP();\r
\r
/* Wait until the LED report has been sent by the host */\r
- while (!(Endpoint_IsOUTReceived()));\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
\r
/* Read in the LED report from the host */\r
uint8_t LEDStatus = Endpoint_Read_Byte();\r
/* Clear the endpoint data */\r
Endpoint_ClearOUT();\r
\r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
}\r
\r
break;\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
/* Device must be connected and configured for the task to run */\r
- if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
return;\r
\r
/* Check if board button is not pressed, if so mouse mode enabled */\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
\r
/* Device must be connected and configured for the task to run */\r
- if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
return;\r
\r
/* Check if board button is pressed, if so mouse mode enabled */\r