Update Studio Integration DLL, to include package logging.
[pub/USBasp.git] / Demos / Host / ClassDriver / AndroidAccessoryHost / AndroidAccessoryHost.c
index c2010e6..78a5bed 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2012.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2012  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
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   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
   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
@@ -53,7 +53,7 @@ USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface =
                                        {
                                                .Address        = (PIPE_DIR_OUT | 2),
                                                .Banks          = 1,
                                        {
                                                .Address        = (PIPE_DIR_OUT | 2),
                                                .Banks          = 1,
-                                       },                              
+                                       },
                                .PropertyStrings =
                                        {
                                                [AOA_STRING_Manufacturer] = "Dean Camera",
                                .PropertyStrings =
                                        {
                                                [AOA_STRING_Manufacturer] = "Dean Camera",
@@ -73,7 +73,7 @@ USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface =
 int main(void)
 {
        SetupHardware();
 int main(void)
 {
        SetupHardware();
-       
+
        puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
        puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
@@ -91,12 +91,14 @@ int main(void)
 /** Configures the board hardware and chip peripherals for the demo's functionality. */
 void SetupHardware(void)
 {
 /** 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);
        /* 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);
 
        /* Hardware Initialization */
        Serial_Init(9600, false);
@@ -120,7 +122,12 @@ void AOAHost_Task(void)
                /* Echo received bytes from the attached device through the USART */
                int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface);
                if (!(ReceivedByte < 0))
                /* Echo received bytes from the attached device through the USART */
                int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface);
                if (!(ReceivedByte < 0))
-                 putchar(ReceivedByte);
+               {
+                       /* Turn on and off LED1 based on the bytes received */
+                       LEDs_ChangeLEDs(LEDS_LED1, ReceivedByte ? LEDS_LED1 : LEDS_NO_LEDS);
+
+                       putchar(ReceivedByte);
+               }
        }
 }
 
        }
 }
 
@@ -155,7 +162,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
        {
                puts_P(PSTR("Error Retrieving Device Descriptor.\r\n"));
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
        {
                puts_P(PSTR("Error Retrieving Device Descriptor.\r\n"));
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
-               return; 
+               return;
        }
 
        bool NeedModeSwitch;
        }
 
        bool NeedModeSwitch;
@@ -165,7 +172,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                return;
        }
                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
                return;
        }
-       
+
        if (NeedModeSwitch)
        {
                puts_P(PSTR("Not in Accessory mode, switching...\r\n"));
        if (NeedModeSwitch)
        {
                puts_P(PSTR("Not in Accessory mode, switching...\r\n"));