X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7f8dbb4908abd33b5ee8bfba7cc3870fa14f7366..3642ea0b9715cdf0196b10c9fc97898940eaefa6:/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c?ds=inline diff --git a/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c b/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c index 7b2b79604..a6d7c4cfa 100644 --- a/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c +++ b/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c @@ -1,13 +1,13 @@ /* 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 @@ -18,7 +18,7 @@ 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 @@ -46,7 +46,7 @@ int main(void) puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE)); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - sei(); + GlobalInterruptEnable(); for (;;) { @@ -58,12 +58,14 @@ int main(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); +#endif /* Hardware Initialization */ Serial_Init(9600, false); @@ -78,7 +80,7 @@ void SetupHardware(void) void AndroidHost_Task(void) { if (USB_HostState != HOST_STATE_Configured) - return; + return; /* Select the data IN pipe */ Pipe_SelectPipe(ANDROID_DATA_IN_PIPE); @@ -148,7 +150,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) /* Get and process the configuration descriptor data */ uint8_t ErrorCode = ProcessDeviceDescriptor(); - + bool RequiresModeSwitch = (ErrorCode == NonAccessoryModeAndroidDevice); /* Error out if the device is not an Android device or an error occurred */ @@ -166,12 +168,12 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) } printf_P(PSTR("Android Device Detected - %sAccessory mode.\r\n"), (RequiresModeSwitch ? "Non-" : "")); - + /* Check if a valid Android device was attached, but it is not current in Accessory mode */ if (RequiresModeSwitch) { uint16_t AndroidProtocol; - + /* Fetch the version of the Android Accessory Protocol supported by the device */ if ((ErrorCode = Android_GetAccessoryProtocol(&AndroidProtocol)) != HOST_SENDCONTROL_Successful) { @@ -181,7 +183,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR); return; } - + /* Validate the returned protocol version */ if (AndroidProtocol != AOA_PROTOCOL_AccessoryV1) { @@ -190,7 +192,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) LEDs_SetAllLEDs(LEDMASK_USB_ERROR); return; } - + /* Send the device strings and start the Android Accessory Mode */ Android_SendString(AOA_STRING_Manufacturer, "Dean Camera"); Android_SendString(AOA_STRING_Model, "LUFA Android Demo"); @@ -199,7 +201,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void) Android_SendString(AOA_STRING_URI, "http://www.lufa-lib.org"); Android_SendString(AOA_STRING_Serial, "0000000012345678"); - Android_StartAccessoryMode(); + Android_StartAccessoryMode(); return; }