Use _delay_us() function in the XPROGTarget.c file to ensure timing requirements...
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / BluetoothHost.c
index 1774786..c996af6 100644 (file)
@@ -1,21 +1,21 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, and distribute this software\r
-  and its documentation for any purpose and without fee is hereby\r
-  granted, provided that the above copyright notice appear in all\r
-  copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting\r
-  documentation, and that the name of the author not be used in\r
-  advertising or publicity pertaining to distribution of the\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+  Permission to use, copy, modify, distribute, and sell this \r
+  software and its documentation for any purpose is hereby granted\r
+  without fee, provided that the above copyright notice appear in \r
+  all copies and that both that the copyright notice and this\r
+  permission notice and warranty disclaimer appear in supporting \r
+  documentation, and that the name of the author not be used in \r
+  advertising or publicity pertaining to distribution of the \r
   software without specific, written prior permission.\r
 \r
   The author disclaim all warranties with regard to this\r
   software without specific, written prior permission.\r
 \r
   The author disclaim all warranties with regard to this\r
@@ -50,7 +50,7 @@ int main(void)
        \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 \r
        \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 \r
-       puts_P(PSTR(ESC_RESET ESC_FG_CYAN "Bluetooth Host Demo running.\r\n" ESC_FG_WHITE));\r
+       puts_P(PSTR(ESC_FG_CYAN "Bluetooth Host Demo running.\r\n" ESC_FG_WHITE));\r
                   \r
        for (;;)\r
        {\r
                   \r
        for (;;)\r
        {\r
@@ -75,42 +75,42 @@ void SetupHardware(void)
        USB_Init();\r
 }\r
 \r
        USB_Init();\r
 }\r
 \r
-void EVENT_USB_DeviceAttached(void)\r
+void EVENT_USB_Host_DeviceAttached(void)\r
 {\r
        puts_P(PSTR(ESC_FG_GREEN "Device Attached.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
 }\r
 \r
 {\r
        puts_P(PSTR(ESC_FG_GREEN "Device Attached.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
 }\r
 \r
-void EVENT_USB_DeviceUnattached(void)\r
+void EVENT_USB_Host_DeviceUnattached(void)\r
 {\r
        puts_P(PSTR(ESC_FG_GREEN "\r\nDevice Unattached.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 }\r
 \r
 {\r
        puts_P(PSTR(ESC_FG_GREEN "\r\nDevice Unattached.\r\n" ESC_FG_WHITE));\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 }\r
 \r
-void EVENT_USB_DeviceEnumerationComplete(void)\r
+void EVENT_USB_Host_DeviceEnumerationComplete(void)\r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
 }\r
 \r
 {\r
        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
 }\r
 \r
-void EVENT_USB_HostError(uint8_t ErrorCode)\r
+void EVENT_USB_Host_HostError(uint8_t ErrorCode)\r
 {\r
        USB_ShutDown();\r
 \r
 {\r
        USB_ShutDown();\r
 \r
-       puts_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"));\r
-       printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+       printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"\r
+                                " -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
        for(;;);\r
 }\r
 \r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
        for(;;);\r
 }\r
 \r
-void EVENT_USB_DeviceEnumerationFailed(uint8_t ErrorCode, uint8_t SubErrorCode)\r
+void EVENT_USB_Host_DeviceEnumerationFailed(uint8_t ErrorCode, uint8_t SubErrorCode)\r
 {\r
 {\r
-       puts_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"));\r
-       printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);\r
-       printf_P(PSTR(" -- Sub Error Code %d\r\n"), SubErrorCode);\r
-       printf_P(PSTR(" -- In State %d\r\n" ESC_FG_WHITE), USB_HostState);\r
+       printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"\r
+                                " -- Error Code %d\r\n"\r
+                                " -- Sub Error Code %d\r\n"\r
+                                " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);\r
        \r
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
 }\r
        \r
        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
 }\r
@@ -147,8 +147,8 @@ void Bluetooth_Management_Task(void)
                        /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */\r
                        if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)\r
                        {\r
                        /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */\r
                        if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)\r
                        {\r
-                               puts_P(PSTR(ESC_FG_RED "Control Error (Set Configuration).\r\n"));\r
-                               printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+                               printf_P(PSTR(ESC_FG_RED "Control Error (Set Configuration).\r\n"\r
+                                                        " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
 \r
                                /* Indicate error via status LEDs */\r
                                LEDs_SetAllLEDs(LEDS_LED1);\r
 \r
                                /* Indicate error via status LEDs */\r
                                LEDs_SetAllLEDs(LEDS_LED1);\r
@@ -158,9 +158,6 @@ void Bluetooth_Management_Task(void)
                                break;\r
                        }\r
                                \r
                                break;\r
                        }\r
                                \r
-                       USB_HostState = HOST_STATE_Configured;\r
-                       break;\r
-               case HOST_STATE_Configured:\r
                        puts_P(PSTR("Getting Config Data.\r\n"));\r
                \r
                        /* Get and process the configuration descriptor data */\r
                        puts_P(PSTR("Getting Config Data.\r\n"));\r
                \r
                        /* Get and process the configuration descriptor data */\r
@@ -183,7 +180,7 @@ void Bluetooth_Management_Task(void)
 \r
                        puts_P(PSTR("Bluetooth Dongle Enumerated.\r\n"));\r
 \r
 \r
                        puts_P(PSTR("Bluetooth Dongle Enumerated.\r\n"));\r
 \r
-                       USB_HostState = HOST_STATE_Ready;\r
+                       USB_HostState = HOST_STATE_Configured;\r
                        break;\r
        }\r
 }\r
                        break;\r
        }\r
 }\r