- /* Process General and Audio specific control requests */\r
- switch (USB_ControlRequest.bRequest)\r
- {\r
- case REQ_SetInterface:\r
- /* Set Interface is not handled by the library, as its function is application-specific */\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))\r
- {\r
- Endpoint_ClearSETUP();\r
- \r
- /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */\r
- if (USB_ControlRequest.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_IsINReady()));\r
- Endpoint_ClearIN();\r
- }\r
-\r
- break;\r
- }\r
-}\r
-\r
-/** Function to manage status updates to the user. This is done via LEDs on the given board, if available, but may be changed to\r
- * log to a serial port, or anything else that is suitable for status updates.\r
- *\r
- * \param CurrentStatus Current status of the system, from the AudioOutput_StatusCodes_t enum\r
- */\r
-void UpdateStatus(uint8_t CurrentStatus)\r
-{\r
- uint8_t LEDMask = LEDS_NO_LEDS;\r
- \r
- /* Set the LED mask to the appropriate LED mask based on the given status code */\r
- switch (CurrentStatus)\r
- {\r
- case Status_USBNotReady:\r
- LEDMask = (LEDS_LED1);\r
- break;\r
- case Status_USBEnumerating:\r
- LEDMask = (LEDS_LED1 | LEDS_LED2);\r
- break;\r
- case Status_USBReady:\r
- LEDMask = (LEDS_LED2 | LEDS_LED4);\r
- break;\r
- }\r
- \r
- /* Set the board LEDs to the new LED mask */\r
- LEDs_SetAllLEDs(LEDMask);\r
-}\r
-\r
-/** Task to manage the Audio interface, reading in audio samples from the host, and outputting them to the speakers/LEDs as\r
- * desired.\r
- */\r
-TASK(USB_Audio_Task)\r
-{\r
- /* Select the audio stream endpoint */\r
- Endpoint_SelectEndpoint(AUDIO_STREAM_EPNUM);\r
- \r
- /* Check if the current endpoint can be read from (contains a packet) and that the next sample should be read */\r
- if (Endpoint_IsOUTReceived() && (TIFR0 & (1 << OCF0A)))\r