Minor documentation improvements. Remove AS4 project generator script as it is buggy...
[pub/USBasp.git] / Demos / Host / LowLevel / AudioInputHost / AudioInputHost.c
index 97a18a0..f98a443 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -46,7 +46,7 @@ int main(void)
        puts_P(PSTR(ESC_FG_CYAN "Audio Input Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
        puts_P(PSTR(ESC_FG_CYAN "Audio Input Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
-       sei();
+       GlobalInterruptEnable();
 
        for (;;)
        {
 
        for (;;)
        {
@@ -123,7 +123,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                return;
        }
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                return;
        }
-       
+
        if ((ErrorCode = USB_Host_SetInterfaceAltSetting(StreamingInterfaceIndex,
                                                         StreamingInterfaceAltSetting)) != HOST_SENDCONTROL_Successful)
        {
        if ((ErrorCode = USB_Host_SetInterfaceAltSetting(StreamingInterfaceIndex,
                                                         StreamingInterfaceAltSetting)) != HOST_SENDCONTROL_Successful)
        {
@@ -143,7 +143,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
                        .wIndex        = StreamingEndpointAddress,
                        .wLength       = sizeof(USB_Audio_SampleFreq_t),
                };
                        .wIndex        = StreamingEndpointAddress,
                        .wLength       = sizeof(USB_Audio_SampleFreq_t),
                };
-               
+
        USB_Audio_SampleFreq_t SampleRate = AUDIO_SAMPLE_FREQ(48000);
 
        /* Select the control pipe for the request transfer */
        USB_Audio_SampleFreq_t SampleRate = AUDIO_SAMPLE_FREQ(48000);
 
        /* Select the control pipe for the request transfer */
@@ -152,8 +152,11 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
        /* Set the sample rate on the streaming interface endpoint */
        if ((ErrorCode = USB_Host_SendControlRequest(&SampleRate)) != HOST_SENDCONTROL_Successful)
        {
        /* Set the sample rate on the streaming interface endpoint */
        if ((ErrorCode = USB_Host_SendControlRequest(&SampleRate)) != HOST_SENDCONTROL_Successful)
        {
+               printf_P(PSTR(ESC_FG_RED "Could not set requested Audio sample rate.\r\n"
+                                        " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
+
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-               USB_Host_SetDeviceConfiguration(0);             
+               USB_Host_SetDeviceConfiguration(0);
                return;
        }
 
                return;
        }
 
@@ -161,7 +164,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
        TIMSK0  = (1 << OCIE0A);
        OCR0A   = ((F_CPU / 8 / 48000) - 1);
        TCCR0A  = (1 << WGM01);  // CTC mode
        TIMSK0  = (1 << OCIE0A);
        OCR0A   = ((F_CPU / 8 / 48000) - 1);
        TCCR0A  = (1 << WGM01);  // CTC mode
-       TCCR0B  = (1 << CS01);   // Fcpu/8 speed        
+       TCCR0B  = (1 << CS01);   // Fcpu/8 speed
 
        /* Set speaker as output */
        DDRC   |= (1 << 6);
 
        /* Set speaker as output */
        DDRC   |= (1 << 6);
@@ -169,7 +172,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
        /* PWM speaker timer initialization */
        TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0)); // Set on match, clear on TOP
        TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, F_CPU speed
        /* PWM speaker timer initialization */
        TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0)); // Set on match, clear on TOP
        TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, F_CPU speed
-       
+
        puts_P(PSTR("Microphone Enumerated.\r\n"));
        LEDs_SetAllLEDs(LEDMASK_USB_READY);
 }
        puts_P(PSTR("Microphone Enumerated.\r\n"));
        LEDs_SetAllLEDs(LEDMASK_USB_READY);
 }
@@ -238,7 +241,8 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
 
                LEDs_SetAllLEDs(LEDMask);
        }
 
                LEDs_SetAllLEDs(LEDMask);
        }
-       
+
        Pipe_Freeze();
        Pipe_SelectPipe(PrevPipe);
 }
        Pipe_Freeze();
        Pipe_SelectPipe(PrevPipe);
 }
+