Renamed all library events to properly seperate out Device and Host mode events....
[pub/lufa.git] / Demos / OTG / TestApp / TestEvents.c
index d0bc805..aee2b16 100644 (file)
@@ -54,71 +54,17 @@ static void Abort_Program(void)
        for (;;);\r
 }\r
 \r
        for (;;);\r
 }\r
 \r
-/** Event handler for the USB_VBUSChange event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_VBUSChange(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS Change\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/** Event handler for the USB_VBUSConnect event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_VBUSConnect(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS +\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/** Event handler for the USB_VBUSDisconnect event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_VBUSDisconnect(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS -\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/**\r
- *  Event handler for the USB_Connect event. When fired, the event is logged to the USART and the\r
- *  USB task started.\r
- */\r
-void EVENT_USB_Connect(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB  +\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/**\r
- *  Event handler for the USB_Disconnect event. When fired, the event is logged to the USART and the\r
- *  USB task stopped.\r
- */\r
-void EVENT_USB_Disconnect(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB  -\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/** Event handler for the USB_Suspend event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_Suspend(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Sleep\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/** Event handler for the USB_WakeUp event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_WakeUp(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Wakeup\r\n" ESC_FG_WHITE));\r
-}\r
-\r
-/** Event handler for the USB_Reset event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_Reset(void)\r
-{\r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Reset\r\n" ESC_FG_WHITE));\r
-}\r
-\r
 /** Event handler for the USB_UIDChange event. When fired, the event is logged to the USART. */\r
 void EVENT_USB_UIDChange(void)\r
 {\r
        char* ModeStrPtr;\r
 \r
 /** Event handler for the USB_UIDChange event. When fired, the event is logged to the USART. */\r
 void EVENT_USB_UIDChange(void)\r
 {\r
        char* ModeStrPtr;\r
 \r
-       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "UID Change\r\n"));\r
+       puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "UID Change\r\n"));\r
 \r
        if (USB_CurrentMode == USB_MODE_DEVICE)\r
 \r
        if (USB_CurrentMode == USB_MODE_DEVICE)\r
-         ModeStrPtr = PSTR("HOST");\r
-       else if (USB_CurrentMode == USB_MODE_HOST)\r
          ModeStrPtr = PSTR("DEVICE");\r
          ModeStrPtr = PSTR("DEVICE");\r
+       else if (USB_CurrentMode == USB_MODE_HOST)\r
+         ModeStrPtr = PSTR("HOST");\r
        else\r
          ModeStrPtr = PSTR("N/A");\r
 \r
        else\r
          ModeStrPtr = PSTR("N/A");\r
 \r
@@ -126,7 +72,7 @@ void EVENT_USB_UIDChange(void)
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
- *  Event handler for the USB_PowerOnFail event. When fired, the event is logged to the USART and the program\r
+ *  Event handler for the USB_InitFailure event. When fired, the event is logged to the USART and the program\r
  *  execution aborted.\r
  */\r
 void EVENT_USB_InitFailure(const uint8_t ErrorCode)\r
  *  execution aborted.\r
  */\r
 void EVENT_USB_InitFailure(const uint8_t ErrorCode)\r
@@ -148,29 +94,38 @@ void EVENT_USB_InitFailure(const uint8_t ErrorCode)
        Abort_Program();\r
 }\r
 \r
        Abort_Program();\r
 }\r
 \r
-/**\r
- *  Event handler for the USB_HostError event. When fired, the event is logged to the USART and the program\r
- *  execution aborted.\r
- */\r
-void EVENT_USB_HostError(const uint8_t ErrorCode)\r
+/** Event handler for the USB_Device_Connect event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_Connect(void)\r
 {\r
 {\r
-       puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "Host Mode Error\r\n"));\r
-       printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "USB Connect\r\n" ESC_FG_WHITE));\r
+}\r
 \r
 \r
-       Abort_Program();\r
+/** Event handler for the USB_Device_Disconnect event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_Disconnect(void)\r
+{\r
+       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "USB Disconnect\r\n" ESC_FG_WHITE));\r
 }\r
 \r
 }\r
 \r
-/** Event handler for the USB_DeviceEnumerationFailed event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)\r
+/** Event handler for the USB_Device_Suspend event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_Suspend(void)\r
 {\r
 {\r
-       puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "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
+       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Sleep\r\n" ESC_FG_WHITE));\r
+}\r
+\r
+/** Event handler for the USB_Device_WakeUp event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_WakeUp(void)\r
+{\r
+       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Wakeup\r\n" ESC_FG_WHITE));\r
+}\r
+\r
+/** Event handler for the USB_Device_Reset event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_Reset(void)\r
+{\r
+       puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Reset\r\n" ESC_FG_WHITE));\r
 }\r
 \r
 }\r
 \r
-/** Event handler for the USB_UnhandledControlPacket event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_UnhandledControlPacket(void)\r
+/** Event handler for the USB_Device_UnhandledControlRequest event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_UnhandledControlRequest(void)\r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Ctrl Request\r\n"));\r
        printf_P(PSTR(" -- Req Data %d\r\n"), USB_ControlRequest.bRequest);\r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Ctrl Request\r\n"));\r
        printf_P(PSTR(" -- Req Data %d\r\n"), USB_ControlRequest.bRequest);\r
@@ -178,26 +133,47 @@ void EVENT_USB_UnhandledControlPacket(void)
        printf_P(PSTR(" -- Req Length %d\r\n" ESC_FG_WHITE), USB_ControlRequest.wLength);\r
 }\r
 \r
        printf_P(PSTR(" -- Req Length %d\r\n" ESC_FG_WHITE), USB_ControlRequest.wLength);\r
 }\r
 \r
-/** Event handler for the USB_ConfigurationChanged event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_ConfigurationChanged(void)\r
+/** Event handler for the USB_Device_ConfigurationChanged event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Device_ConfigurationChanged(void)\r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Configuration Number Changed\r\n" ESC_FG_WHITE));\r
 }\r
 \r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Configuration Number Changed\r\n" ESC_FG_WHITE));\r
 }\r
 \r
-/** Event handler for the USB_DeviceAttached event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_DeviceAttached(void)\r
+/**\r
+ *  Event handler for the USB_Host_HostError event. When fired, the event is logged to the USART and the program\r
+ *  execution aborted.\r
+ */\r
+void EVENT_USB_Host_HostError(const uint8_t ErrorCode)\r
 {\r
 {\r
-       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device +\r\n" ESC_FG_WHITE));\r
+       puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "Host Mode Error\r\n"));\r
+       printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+\r
+       Abort_Program();\r
 }\r
 \r
 }\r
 \r
-/** Event handler for the USB_DeviceUnattached event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_DeviceUnattached(void)\r
+/** Event handler for the USB_Host_DeviceEnumerationFailed event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)\r
 {\r
 {\r
-       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device -\r\n" ESC_FG_WHITE));\r
+       puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "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
 }\r
 \r
 }\r
 \r
-/** Event handler for the USB_DeviceEnumerationComplete event. When fired, the event is logged to the USART. */\r
-void EVENT_USB_DeviceEnumerationComplete(void)\r
+/** Event handler for the USB_Host_DeviceEnumerationComplete event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Host_DeviceEnumerationComplete(void)\r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Device Enumeration Complete\r\n" ESC_FG_WHITE));\r
 }\r
 {\r
        puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Device Enumeration Complete\r\n" ESC_FG_WHITE));\r
 }\r
+\r
+/** Event handler for the USB_Host_DeviceAttached event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Host_DeviceAttached(void)\r
+{\r
+       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device Attached\r\n" ESC_FG_WHITE));\r
+}\r
+\r
+/** Event handler for the USB_Host_DeviceUnattached event. When fired, the event is logged to the USART. */\r
+void EVENT_USB_Host_DeviceUnattached(void)\r
+{\r
+       puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device Unattached\r\n" ESC_FG_WHITE));\r
+}\r