Added V2Protocol handlers to the AVRISP project to enter/exit programming mode, and...
[pub/USBasp.git] / Demos / Device / Incomplete / Sideshow / Sideshow.c
index 41e36cc..fdf4265 100644 (file)
@@ -82,17 +82,17 @@ void SetupHardware(void)
        SerialStream_Init(9600, false);\r
 }\r
 \r
-void EVENT_USB_Connect(void)\r
+void EVENT_USB_Device_Connect(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
 }\r
 \r
-void EVENT_USB_Disconnect(void)\r
+void EVENT_USB_Device_Disconnect(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 }\r
 \r
-void EVENT_USB_ConfigurationChanged(void)\r
+void EVENT_USB_Device_ConfigurationChanged(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
 \r
@@ -112,7 +112,7 @@ void EVENT_USB_ConfigurationChanged(void)
        }\r
 }\r
 \r
-void EVENT_USB_UnhandledControlPacket(void)\r
+void EVENT_USB_Device_UnhandledControlRequest(void)\r
 {\r
        /* Process UFI specific control requests */\r
        switch (USB_ControlRequest.bRequest)\r
@@ -141,17 +141,17 @@ void EVENT_USB_UnhandledControlPacket(void)
        \r
 void SideShow_Task(void)\r
 {\r
-       /* Check if the USB System is connected to a Host */\r
-       if (USB_IsConnected)\r
+       /* Device must be connected and configured for the task to run */\r
+       if (USB_DeviceState != DEVICE_STATE_Configured)\r
+         return;\r
+\r
+       /* Select the SideShow data out endpoint */\r
+       Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM);\r
+       \r
+       /* Check to see if a new SideShow message has been received */\r
+       if (Endpoint_IsReadWriteAllowed())\r
        {\r
-               /* Select the SideShow data out endpoint */\r
-               Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM);\r
-               \r
-               /* Check to see if a new SideShow message has been received */\r
-               if (Endpoint_IsReadWriteAllowed())\r
-               {\r
-                       /* Process the received SideShow message */\r
-                       Sideshow_ProcessCommandPacket();\r
-               }\r
+               /* Process the received SideShow message */\r
+               Sideshow_ProcessCommandPacket();\r
        }\r
 }\r