Add explicit guards to all device mode tasks to ensure the device is connected and...
[pub/USBasp.git] / Demos / Device / LowLevel / CDC / CDC.c
index ac0623a..d8263b1 100644 (file)
@@ -254,6 +254,10 @@ void CDC_Task(void)
                        "Joystick Pressed\r\n",\r
                };\r
        \r
+       /* Device must be connected and configured for the task to run */\r
+       if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+         return;\r
+         \r
 #if 0\r
        /* NOTE: Here you can use the notification endpoint to send back line state changes to the host, for the special RS-232\r
         *       handshake signal lines (and some error states), via the CONTROL_LINE_IN_* masks and the following code:\r