Add explicit guards to all device mode tasks to ensure the device is connected and configured before running the task, to prevent any user tasks from locking up the main USB task if the device has not been properly configured.

This commit is contained in:
Dean Camera 2009-07-21 02:48:41 +00:00
parent bf50959b80
commit 67f390fe74
19 changed files with 245 additions and 216 deletions

View file

@ -229,6 +229,10 @@ void CDC1_Task(void)
uint8_t JoyStatus_LCL = Joystick_GetStatus();
static bool ActionSent = false;
/* Device must be connected and configured for the task to run */
if (!(USB_IsConnected) || !(USB_ConfigurationNumber))
return;
char* JoystickStrings[] =
{
"Joystick Up\r\n",
@ -288,6 +292,10 @@ void CDC1_Task(void)
*/
void CDC2_Task(void)
{
/* Device must be connected and configured for the task to run */
if (!(USB_IsConnected) || !(USB_ConfigurationNumber))
return;
/* Select the Serial Rx Endpoint */
Endpoint_SelectEndpoint(CDC2_RX_EPNUM);