/*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  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
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  The author disclaims all warranties with regard to this
   software, including all implied warranties of merchantability
   and fitness.  In no event shall the author be liable for any
   special, indirect or consequential damages or any damages
        puts_P(PSTR(ESC_FG_CYAN "Audio Input Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
-       sei();
+       GlobalInterruptEnable();
 
        for (;;)
        {
 /** Configures the board hardware and chip peripherals for the demo's functionality. */
 void SetupHardware(void)
 {
+#if (ARCH == ARCH_AVR8)
        /* Disable watchdog if enabled by bootloader/fuses */
        MCUSR &= ~(1 << WDRF);
        wdt_disable();
 
        /* Disable clock division */
        clock_prescale_set(clock_div_1);
+#endif
 
        /* Hardware Initialization */
        Serial_Init(9600, false);
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                return;
        }
-       
+
        if ((ErrorCode = USB_Host_SetInterfaceAltSetting(StreamingInterfaceIndex,
                                                         StreamingInterfaceAltSetting)) != HOST_SENDCONTROL_Successful)
        {
                        .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 */
        /* 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);
-               USB_Host_SetDeviceConfiguration(0);             
+               USB_Host_SetDeviceConfiguration(0);
                return;
        }
 
        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);
        /* 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);
 }
 
                LEDs_SetAllLEDs(LEDMask);
        }
-       
+
        Pipe_Freeze();
        Pipe_SelectPipe(PrevPipe);
 }
+