*/\r
void EVENT_USB_ConfigurationChanged(void)\r
{\r
- /* Setup audio stream endpoint */\r
- Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS,\r
- ENDPOINT_DIR_IN, AUDIO_STREAM_EPSIZE,\r
- ENDPOINT_BANK_DOUBLE);\r
-\r
/* Indicate USB connected and ready */\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+\r
+ /* Setup audio stream endpoint */\r
+ if (!(Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS,\r
+ ENDPOINT_DIR_IN, AUDIO_STREAM_EPSIZE,\r
+ ENDPOINT_BANK_DOUBLE)))\r
+ {\r
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ }\r
}\r
\r
/** Event handler for the USB_UnhandledControlPacket event. This is used to catch standard and class specific\r
/* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */\r
StreamingAudioInterfaceSelected = ((USB_ControlRequest.wValue) != 0);\r
\r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
}\r
\r
break;\r
/** Task to manage the Audio interface, reading in ADC samples from the microphone, and them to the host. */\r
void USB_Audio_Task(void)\r
{\r
+ /* Device must be connected and configured for the task to run */\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return;\r
+\r
/* Check to see if the streaming interface is selected, if not the host is not receiving audio */\r
if (!(StreamingAudioInterfaceSelected))\r
return;\r