Add explicit guards to all device mode tasks to ensure the device is connected and...
[pub/USBasp.git] / Demos / Device / LowLevel / Mouse / Mouse.c
index 60eb7fa..febb364 100644 (file)
@@ -313,10 +313,10 @@ void SendNextReport(void)
 /** Task to manage HID report generation and transmission to the host, when in report mode. */\r
 void Mouse_Task(void)\r
 {\r
-       /* Check if the USB system is connected to a host */\r
-       if (USB_IsConnected)\r
-       {\r
-               /* Send the next mouse report to the host */\r
-               SendNextReport();\r
-       }\r
+       /* Device must be connected and configured for the task to run */\r
+       if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+         return;\r
+         \r
+       /* Send the next mouse report to the host */\r
+       SendNextReport();\r
 }\r