- /* Stop running audio and USB management tasks */\r
- Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP);\r
- Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);\r
-\r
- /* Indicate USB not ready */\r
- UpdateStatus(Status_USBNotReady);\r
-}\r
-\r
-/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration\r
- * of the USB device after enumeration - the device endpoints are configured.\r
- */\r
-EVENT_HANDLER(USB_ConfigurationChanged)\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
- UpdateStatus(Status_USBReady);\r
-}\r
-\r
-/** Event handler for the USB_UnhandledControlPacket event. This is used to catch standard and class specific\r
- * control requests that are not handled internally by the USB library (including the Audio class-specific\r
- * requests) so that they can be handled appropriately for the application.\r
- */\r
-EVENT_HANDLER(USB_UnhandledControlPacket)\r
-{\r
- /* Process General and Audio specific control requests */\r
- switch (bRequest)\r
- {\r
- case REQ_SetInterface:\r
- /* Set Interface is not handled by the library, as its function is application-specific */\r
- if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))\r
- {\r
- uint16_t wValue = Endpoint_Read_Word_LE();\r
- \r
- Endpoint_ClearSetupReceived();\r
- \r
- /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */\r
- if (wValue)\r
- {\r
- /* Start audio task */\r
- Scheduler_SetTaskMode(USB_Audio_Task, TASK_RUN);\r
- }\r
- else\r
- {\r
- /* Stop audio task */\r
- Scheduler_SetTaskMode(USB_Audio_Task, TASK_STOP); \r
- }\r
- \r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsSetupINReady()));\r
- Endpoint_ClearSetupIN();\r
- }\r
-\r
- break;\r
- }\r