X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/d860e9e842c05e759214f5170f78783decae9956..d0db78432fc02bacbd57cc9f15eb05b4e56981cb:/Demos/OTG/TestApp/TestEvents.c?ds=sidebyside diff --git a/Demos/OTG/TestApp/TestEvents.c b/Demos/OTG/TestApp/TestEvents.c index 17514774f..d0bc805db 100644 --- a/Demos/OTG/TestApp/TestEvents.c +++ b/Demos/OTG/TestApp/TestEvents.c @@ -31,7 +31,7 @@ /** \file * * This file contains dummy handlers for all the possible USB events passed to the - * application by the library (see Events.h documentation for more details on USB events). + * application by the library (see library documentation for more details on USB events). * * Each event is caught and printed to the USART so that they may be monitored. */ @@ -50,78 +50,70 @@ static void Abort_Program(void) LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED3); - puts_P(PSTR(ESC_INVERSE_ON "\r\n**PROGRAM ABORT**")); + puts_P(PSTR(ESC_FG_RED ESC_INVERSE_ON "\r\n**PROGRAM ABORT**" ESC_FG_WHITE)); for (;;); } /** Event handler for the USB_VBUSChange event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_VBUSChange) +void EVENT_USB_VBUSChange(void) { - puts_P(PSTR(EVENT_PREFIX "VBUS Change\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS Change\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_VBUSConnect event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_VBUSConnect) +void EVENT_USB_VBUSConnect(void) { - puts_P(PSTR(EVENT_PREFIX "VBUS +\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS +\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_VBUSDisconnect event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_VBUSDisconnect) +void EVENT_USB_VBUSDisconnect(void) { - puts_P(PSTR(EVENT_PREFIX "VBUS -\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "VBUS -\r\n" ESC_FG_WHITE)); } /** * Event handler for the USB_Connect event. When fired, the event is logged to the USART and the * USB task started. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { - puts_P(PSTR(EVENT_PREFIX "USB +\r\n")); - LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED3 | LEDS_LED4); - - Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB +\r\n" ESC_FG_WHITE)); } /** * Event handler for the USB_Disconnect event. When fired, the event is logged to the USART and the * USB task stopped. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { - Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); - - puts_P(PSTR(EVENT_PREFIX "USB -\r\n")); - LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED3 | LEDS_LED3); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB -\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_Suspend event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_Suspend) +void EVENT_USB_Suspend(void) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_YELLOW "USB Sleep\r\n")); - LEDs_SetAllLEDs(LEDS_ALL_LEDS); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Sleep\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_WakeUp event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_WakeUp) +void EVENT_USB_WakeUp(void) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_GREEN "USB Wakeup\r\n")); - LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED4); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Wakeup\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_Reset event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_Reset) +void EVENT_USB_Reset(void) { - puts_P(PSTR(EVENT_PREFIX "USB Reset\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "USB Reset\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_UIDChange event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_UIDChange) +void EVENT_USB_UIDChange(void) { char* ModeStrPtr; - puts_P(PSTR(EVENT_PREFIX "UID Change\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "UID Change\r\n")); if (USB_CurrentMode == USB_MODE_DEVICE) ModeStrPtr = PSTR("HOST"); @@ -129,21 +121,19 @@ EVENT_HANDLER(USB_UIDChange) ModeStrPtr = PSTR("DEVICE"); else ModeStrPtr = PSTR("N/A"); - - LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED3); - printf_P(PSTR(" -- New Mode %S\r\n"), ModeStrPtr); + printf_P(PSTR(" -- New Mode %S\r\n" ESC_FG_WHITE), ModeStrPtr); } /** * Event handler for the USB_PowerOnFail event. When fired, the event is logged to the USART and the program * execution aborted. */ -EVENT_HANDLER(USB_PowerOnFail) +void EVENT_USB_InitFailure(const uint8_t ErrorCode) { char* ModeStrPtr; - puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Power On Fail\r\n")); + puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "Power On Fail\r\n")); if (USB_CurrentMode == USB_MODE_DEVICE) ModeStrPtr = PSTR("DEVICE"); @@ -153,7 +143,7 @@ EVENT_HANDLER(USB_PowerOnFail) ModeStrPtr = PSTR("N/A"); printf_P(PSTR(" -- Mode %S\r\n"), ModeStrPtr); - printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); + printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode); Abort_Program(); } @@ -162,66 +152,52 @@ EVENT_HANDLER(USB_PowerOnFail) * Event handler for the USB_HostError event. When fired, the event is logged to the USART and the program * execution aborted. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Host Mode Error\r\n")); - printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); + puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "Host Mode Error\r\n")); + printf_P(PSTR(" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode); Abort_Program(); } /** Event handler for the USB_DeviceEnumerationFailed event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_DeviceEnumerationFailed) -{ - puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n")); - printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); -} - -/** - * Event handler for the USB_DeviceError event. When fired, the event is logged to the USART and the program - * execution aborted. - */ -EVENT_HANDLER(USB_DeviceError) +void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Device Mode Error\r\n")); + puts_P(PSTR(ESC_FG_RED EVENT_PREFIX "Dev Enum Error\r\n")); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); - - Abort_Program(); + printf_P(PSTR(" -- Sub Error Code %d\r\n"), SubErrorCode); + printf_P(PSTR(" -- In State %d\r\n" ESC_FG_WHITE), USB_HostState); } /** Event handler for the USB_UnhandledControlPacket event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { - puts_P(PSTR(EVENT_PREFIX "Ctrl Request\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Ctrl Request\r\n")); printf_P(PSTR(" -- Req Data %d\r\n"), USB_ControlRequest.bRequest); printf_P(PSTR(" -- Req Type %d\r\n"), USB_ControlRequest.bmRequestType); - printf_P(PSTR(" -- Req Length %d\r\n"), USB_ControlRequest.wLength); + printf_P(PSTR(" -- Req Length %d\r\n" ESC_FG_WHITE), USB_ControlRequest.wLength); } /** Event handler for the USB_ConfigurationChanged event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { - puts_P(PSTR(EVENT_PREFIX "Configuration Number Changed\r\n")); - - LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED4); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Configuration Number Changed\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_DeviceAttached event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_GREEN "Device +\r\n")); - - Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); + puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device +\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_DeviceUnattached event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { - puts_P(PSTR(EVENT_PREFIX ESC_BG_YELLOW "Device -\r\n")); + puts_P(PSTR(ESC_FG_GREEN EVENT_PREFIX "Device -\r\n" ESC_FG_WHITE)); } /** Event handler for the USB_DeviceEnumerationComplete event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { - puts_P(PSTR(EVENT_PREFIX "Device Enumeration Complete\r\n")); + puts_P(PSTR(ESC_FG_YELLOW EVENT_PREFIX "Device Enumeration Complete\r\n" ESC_FG_WHITE)); }