From 2ee9fc707784e115d744dbc229bdc893f4bb6bc1 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 18 May 2009 10:05:21 +0000 Subject: Rewritten event system to remove all macros, to make user code clearer. Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley). Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code. Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code. --- Demos/OTG/TestApp/TestEvents.c | 36 ++++++++++----------- Demos/OTG/TestApp/TestEvents.h | 71 +++++++++++------------------------------- Demos/OTG/TestApp/makefile | 2 +- 3 files changed, 38 insertions(+), 71 deletions(-) (limited to 'Demos/OTG') diff --git a/Demos/OTG/TestApp/TestEvents.c b/Demos/OTG/TestApp/TestEvents.c index b542bfc24..a444cc6a6 100644 --- a/Demos/OTG/TestApp/TestEvents.c +++ b/Demos/OTG/TestApp/TestEvents.c @@ -55,19 +55,19 @@ static void Abort_Program(void) } /** 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")); } /** 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")); } /** 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")); } @@ -76,7 +76,7 @@ EVENT_HANDLER(USB_VBUSDisconnect) * 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); @@ -88,7 +88,7 @@ EVENT_HANDLER(USB_Connect) * 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); @@ -97,27 +97,27 @@ EVENT_HANDLER(USB_Disconnect) } /** 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); } /** 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); } /** 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")); } /** 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; @@ -139,7 +139,7 @@ EVENT_HANDLER(USB_UIDChange) * Event handler for the USB_PowerOnFail event. When fired, the event is logged to the USART and the program * execution aborted. */ -EVENT_HANDLER(USB_InitFailure) +void EVENT_USB_InitFailure(const uint8_t ErrorCode) { char* ModeStrPtr; @@ -162,7 +162,7 @@ EVENT_HANDLER(USB_InitFailure) * 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); @@ -171,7 +171,7 @@ EVENT_HANDLER(USB_HostError) } /** Event handler for the USB_DeviceEnumerationFailed event. When fired, the event is logged to the USART. */ -EVENT_HANDLER(USB_DeviceEnumerationFailed) +void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) { puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n")); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); @@ -183,7 +183,7 @@ EVENT_HANDLER(USB_DeviceEnumerationFailed) * 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_DeviceError(const uint8_t ErrorCode) { puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Device Mode Error\r\n")); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); @@ -192,7 +192,7 @@ EVENT_HANDLER(USB_DeviceError) } /** 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")); printf_P(PSTR(" -- Req Data %d\r\n"), USB_ControlRequest.bRequest); @@ -201,7 +201,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) } /** 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")); @@ -209,7 +209,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) } /** 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")); @@ -217,13 +217,13 @@ EVENT_HANDLER(USB_DeviceAttached) } /** 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")); } /** 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")); } diff --git a/Demos/OTG/TestApp/TestEvents.h b/Demos/OTG/TestApp/TestEvents.h index a1f149f47..656c070ea 100644 --- a/Demos/OTG/TestApp/TestEvents.h +++ b/Demos/OTG/TestApp/TestEvents.h @@ -46,58 +46,6 @@ #include // ANSI Terminal Escape Codes #include // Simple scheduler for task management - /* Event Catch List: */ - /** Indicates that this module will catch the USB_VBUSChange event when thrown by the library. */ - HANDLES_EVENT(USB_VBUSChange); - - /** Indicates that this module will catch the USB_VBUSConnect event when thrown by the library. */ - HANDLES_EVENT(USB_VBUSConnect); - - /** Indicates that this module will catch the USB_VBUSDisconnect event when thrown by the library. */ - HANDLES_EVENT(USB_VBUSDisconnect); - - /** Indicates that this module will catch the USB_Connect event when thrown by the library. */ - HANDLES_EVENT(USB_Connect); - - /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ - HANDLES_EVENT(USB_Disconnect); - - /** Indicates that this module will catch the USB_Suspend event when thrown by the library. */ - HANDLES_EVENT(USB_Suspend); - - /** Indicates that this module will catch the USB_WakeUp event when thrown by the library. */ - HANDLES_EVENT(USB_WakeUp); - - /** Indicates that this module will catch the USB_Reset event when thrown by the library. */ - HANDLES_EVENT(USB_Reset); - - /** Indicates that this module will catch the USB_UIDChange event when thrown by the library. */ - HANDLES_EVENT(USB_UIDChange); - - /** Indicates that this module will catch the USB_InitFailure event when thrown by the library. */ - HANDLES_EVENT(USB_InitFailure); - - /** Indicates that this module will catch the USB_HostError event when thrown by the library. */ - HANDLES_EVENT(USB_HostError); - - /** Indicates that this module will catch the USB_DeviceEnumerationFailed event when thrown by the library. */ - HANDLES_EVENT(USB_DeviceEnumerationFailed); - - /** Indicates that this module will catch the USB_DeviceError event when thrown by the library. */ - HANDLES_EVENT(USB_DeviceError); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - - /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_DeviceAttached event when thrown by the library. */ - HANDLES_EVENT(USB_DeviceAttached); - - /** Indicates that this module will catch the USB_DeviceUnattached event when thrown by the library. */ - HANDLES_EVENT(USB_DeviceUnattached); - /* Macros: */ /** Prefix sent through the USART when an even fires before the actual event message. */ #define EVENT_PREFIX ESC_INVERSE_ON "EVENT:" ESC_INVERSE_OFF " " @@ -107,4 +55,23 @@ static void Abort_Program(void) ATTR_NO_RETURN; #endif + void EVENT_USB_VBUSChange(void); + void EVENT_USB_VBUSConnect(void); + void EVENT_USB_VBUSDisconnect(void); + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_InitFailure(const uint8_t ErrorCode); + void EVENT_USB_UIDChange(void); + void EVENT_USB_HostError(const uint8_t ErrorCode); + void EVENT_USB_DeviceAttached(void); + void EVENT_USB_DeviceUnattached(void); + void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); + void EVENT_USB_DeviceEnumerationComplete(void); + void EVENT_USB_UnhandledControlPacket(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_Suspend(void); + void EVENT_USB_WakeUp(void); + void EVENT_USB_Reset(void); + void EVENT_USB_DeviceError(const uint8_t ErrorCode); + #endif diff --git a/Demos/OTG/TestApp/makefile b/Demos/OTG/TestApp/makefile index 0ff49b6b9..3c34d5563 100644 --- a/Demos/OTG/TestApp/makefile +++ b/Demos/OTG/TestApp/makefile @@ -509,7 +509,7 @@ sizeafter: checkhooks: build @echo @echo ------- Unhooked LUFA Events ------- - @$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \ + @$(shell) (grep -s '^EVENT_.*LUFA/.*\\.o' $(TARGET).map | \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \ echo "(None)" @echo ------------------------------------ -- cgit v1.2.3