Minor documentation enhancements.
[pub/USBasp.git] / Demos / Device / LowLevel / AudioOutput / AudioOutput.c
index db6bc3c..fbadf8d 100644 (file)
@@ -99,7 +99,7 @@ void EVENT_USB_Device_Connect(void)
        /* PWM speaker timer initialization */
        TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0)
                                | (1 << COM3B1) | (1 << COM3B0)); // Set on match, clear on TOP
-       TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, Fcpu speed
+       TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, F_CPU speed
 #endif 
 }
 
@@ -137,16 +137,14 @@ void EVENT_USB_Device_Disconnect(void)
  */
 void EVENT_USB_Device_ConfigurationChanged(void)
 {
-       /* Indicate USB connected and ready */
-       LEDs_SetAllLEDs(LEDMASK_USB_READY);
+       bool ConfigSuccess = true;
 
-       /* Setup audio stream endpoint */
-       if (!(Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS,
-                                            ENDPOINT_DIR_OUT, AUDIO_STREAM_EPSIZE,
-                                        ENDPOINT_BANK_DOUBLE)))
-       {
-               LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-       }
+       /* Setup Audio Stream Endpoint */
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, ENDPOINT_DIR_OUT,
+                                                   AUDIO_STREAM_EPSIZE, ENDPOINT_BANK_DOUBLE);
+
+       /* Indicate endpoint configuration success or failure */
+       LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
 }
 
 /** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific
@@ -163,11 +161,10 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
                        if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))
                        {
                                Endpoint_ClearSETUP();
-                               
+                               Endpoint_ClearStatusStage();
+
                                /* Check if the host is enabling the audio interface (setting AlternateSetting to 1) */
                                StreamingAudioInterfaceSelected = ((USB_ControlRequest.wValue) != 0);
-                               
-                               Endpoint_ClearStatusStage();
                        }
 
                        break;