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/Device/AudioInput/AudioInput.c | 8 +-- Demos/Device/AudioInput/AudioInput.h | 18 ++---- Demos/Device/AudioInput/makefile | 2 +- Demos/Device/AudioOutput/AudioOutput.c | 8 +-- Demos/Device/AudioOutput/AudioOutput.h | 18 ++---- Demos/Device/AudioOutput/makefile | 2 +- Demos/Device/CDC/CDC.c | 8 +-- Demos/Device/CDC/CDC.h | 18 ++---- Demos/Device/CDC/makefile | 2 +- Demos/Device/DualCDC/DualCDC.c | 8 +-- Demos/Device/DualCDC/DualCDC.h | 18 ++---- Demos/Device/DualCDC/makefile | 2 +- Demos/Device/GenericHID/GenericHID.c | 8 +-- Demos/Device/GenericHID/GenericHID.h | 15 ++--- Demos/Device/GenericHID/makefile | 2 +- Demos/Device/Joystick/Joystick.c | 8 +-- Demos/Device/Joystick/Joystick.h | 18 ++---- Demos/Device/Joystick/makefile | 2 +- Demos/Device/Keyboard/Keyboard.c | 10 +-- Demos/Device/Keyboard/Keyboard.h | 34 ++++------- Demos/Device/Keyboard/makefile | 2 +- Demos/Device/KeyboardMouse/KeyboardMouse.c | 8 +-- Demos/Device/KeyboardMouse/KeyboardMouse.h | 18 ++---- Demos/Device/KeyboardMouse/makefile | 2 +- Demos/Device/MIDI/MIDI.c | 6 +- Demos/Device/MIDI/MIDI.h | 14 ++--- Demos/Device/MIDI/makefile | 2 +- Demos/Device/MassStorage/MassStorage.c | 16 ++--- Demos/Device/MassStorage/MassStorage.h | 23 +++---- Demos/Device/MassStorage/SCSI.c | 8 +-- Demos/Device/MassStorage/makefile | 2 +- Demos/Device/Mouse/Mouse.c | 10 +-- Demos/Device/Mouse/Mouse.h | 18 ++---- Demos/Device/Mouse/makefile | 2 +- Demos/Device/RNDISEthernet/RNDISEthernet.c | 8 +-- Demos/Device/RNDISEthernet/RNDISEthernet.h | 18 ++---- Demos/Device/RNDISEthernet/makefile | 2 +- Demos/Device/USBtoSerial/USBtoSerial.c | 8 +-- Demos/Device/USBtoSerial/USBtoSerial.h | 18 ++---- Demos/Device/USBtoSerial/makefile | 2 +- Demos/Host/CDCHost/CDCHost.c | 10 +-- Demos/Host/CDCHost/CDCHost.h | 13 ++-- Demos/Host/CDCHost/ConfigDescriptor.c | 16 ++--- Demos/Host/CDCHost/ConfigDescriptor.h | 11 ++-- Demos/Host/CDCHost/makefile | 2 +- Demos/Host/GenericHIDHost/ConfigDescriptor.c | 8 +-- Demos/Host/GenericHIDHost/ConfigDescriptor.h | 9 ++- Demos/Host/GenericHIDHost/GenericHIDHost.c | 10 +-- Demos/Host/GenericHIDHost/GenericHIDHost.h | 13 ++-- Demos/Host/GenericHIDHost/makefile | 2 +- Demos/Host/KeyboardHost/ConfigDescriptor.c | 8 +-- Demos/Host/KeyboardHost/ConfigDescriptor.h | 9 ++- Demos/Host/KeyboardHost/KeyboardHost.c | 10 +-- Demos/Host/KeyboardHost/KeyboardHost.h | 13 ++-- Demos/Host/KeyboardHost/makefile | 2 +- .../Host/KeyboardHostWithParser/ConfigDescriptor.c | 12 ++-- .../Host/KeyboardHostWithParser/ConfigDescriptor.h | 11 ++-- .../KeyboardHostWithParser.c | 10 +-- .../KeyboardHostWithParser.h | 13 ++-- Demos/Host/KeyboardHostWithParser/makefile | 2 +- Demos/Host/MassStorageHost/ConfigDescriptor.c | 8 +-- Demos/Host/MassStorageHost/ConfigDescriptor.h | 9 ++- Demos/Host/MassStorageHost/MassStorageHost.c | 10 +-- Demos/Host/MassStorageHost/MassStorageHost.h | 13 ++-- Demos/Host/MassStorageHost/makefile | 2 +- Demos/Host/MouseHost/ConfigDescriptor.c | 8 +-- Demos/Host/MouseHost/ConfigDescriptor.h | 11 ++-- Demos/Host/MouseHost/MouseHost.c | 10 +-- Demos/Host/MouseHost/MouseHost.h | 13 ++-- Demos/Host/MouseHost/makefile | 2 +- Demos/Host/MouseHostWithParser/ConfigDescriptor.c | 12 ++-- Demos/Host/MouseHostWithParser/ConfigDescriptor.h | 11 ++-- .../Host/MouseHostWithParser/MouseHostWithParser.c | 10 +-- .../Host/MouseHostWithParser/MouseHostWithParser.h | 13 ++-- Demos/Host/MouseHostWithParser/makefile | 2 +- Demos/Host/StillImageHost/ConfigDescriptor.c | 8 +-- Demos/Host/StillImageHost/ConfigDescriptor.h | 9 ++- Demos/Host/StillImageHost/StillImageHost.c | 10 +-- Demos/Host/StillImageHost/StillImageHost.h | 13 ++-- Demos/Host/StillImageHost/makefile | 2 +- Demos/OTG/TestApp/TestEvents.c | 36 +++++------ Demos/OTG/TestApp/TestEvents.h | 71 ++++++---------------- Demos/OTG/TestApp/makefile | 2 +- 83 files changed, 358 insertions(+), 507 deletions(-) (limited to 'Demos') diff --git a/Demos/Device/AudioInput/AudioInput.c b/Demos/Device/AudioInput/AudioInput.c index 05094c2b8..ecd8cdda8 100644 --- a/Demos/Device/AudioInput/AudioInput.c +++ b/Demos/Device/AudioInput/AudioInput.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs, and * configures the sample update and PWM timers. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -97,7 +97,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop the sample reload timer */ TCCR0B = 0; @@ -113,7 +113,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup audio stream endpoint */ Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, @@ -128,7 +128,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the Audio class-specific * requests) so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Process General and Audio specific control requests */ switch (USB_ControlRequest.bRequest) diff --git a/Demos/Device/AudioInput/AudioInput.h b/Demos/Device/AudioInput/AudioInput.h index b7174d1f8..6358c24a0 100644 --- a/Demos/Device/AudioInput/AudioInput.h +++ b/Demos/Device/AudioInput/AudioInput.h @@ -71,20 +71,12 @@ /* Task Definitions: */ TASK(USB_Audio_Task); - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/AudioInput/makefile b/Demos/Device/AudioInput/makefile index aca88cb87..7c8b7ab5a 100644 --- a/Demos/Device/AudioInput/makefile +++ b/Demos/Device/AudioInput/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/AudioOutput/AudioOutput.c b/Demos/Device/AudioOutput/AudioOutput.c index 640462da1..7ec2e3534 100644 --- a/Demos/Device/AudioOutput/AudioOutput.c +++ b/Demos/Device/AudioOutput/AudioOutput.c @@ -75,7 +75,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs, and * configures the sample update and PWM timers. */ -EVENT_HANDLER(USB_Connect) +void EventHandler_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -110,7 +110,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs, disables the sample update and PWM output timers and stops the USB and Audio management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EventHandler_USB_Disconnect(void) { /* Stop the timers */ TCCR0B = 0; @@ -140,7 +140,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EventHandler_USB_ConfigurationChanged(void) { /* Setup audio stream endpoint */ Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, @@ -155,7 +155,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the Audio class-specific * requests) so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EventHandler_USB_UnhandledControlPacket(void) { /* Process General and Audio specific control requests */ switch (USB_ControlRequest.bRequest) diff --git a/Demos/Device/AudioOutput/AudioOutput.h b/Demos/Device/AudioOutput/AudioOutput.h index 05b24ad07..d8725a07b 100644 --- a/Demos/Device/AudioOutput/AudioOutput.h +++ b/Demos/Device/AudioOutput/AudioOutput.h @@ -107,21 +107,13 @@ /* Task Definitions: */ TASK(USB_Audio_Task); - - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/AudioOutput/makefile b/Demos/Device/AudioOutput/makefile index 0a6401b70..fc200be4a 100644 --- a/Demos/Device/AudioOutput/makefile +++ b/Demos/Device/AudioOutput/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/CDC/CDC.c b/Demos/Device/CDC/CDC.c index 59aa98ceb..d7ebb9e6b 100644 --- a/Demos/Device/CDC/CDC.c +++ b/Demos/Device/CDC/CDC.c @@ -104,7 +104,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -116,7 +116,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and CDC management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running CDC and USB management tasks */ Scheduler_SetTaskMode(CDC_Task, TASK_STOP); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the CDC management task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints */ Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, @@ -155,7 +155,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the CDC control commands, * which are all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { uint8_t* LineCodingData = (uint8_t*)&LineCoding; diff --git a/Demos/Device/CDC/CDC.h b/Demos/Device/CDC/CDC.h index 1537f0ba3..4c4ca74d5 100644 --- a/Demos/Device/CDC/CDC.h +++ b/Demos/Device/CDC/CDC.h @@ -111,19 +111,6 @@ */ #define CONTROL_LINE_IN_OVERRUNERROR (1 << 6) - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Type Defines: */ /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration * as set by the host via a class specific request. @@ -185,6 +172,11 @@ TASK(CDC_Task); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/CDC/makefile b/Demos/Device/CDC/makefile index ce2436eb8..5755dda1e 100644 --- a/Demos/Device/CDC/makefile +++ b/Demos/Device/CDC/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/DualCDC/DualCDC.c b/Demos/Device/DualCDC/DualCDC.c index 9750ea23e..34d772ff0 100644 --- a/Demos/Device/DualCDC/DualCDC.c +++ b/Demos/Device/DualCDC/DualCDC.c @@ -118,7 +118,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -130,7 +130,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and CDC management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running CDC and USB management tasks */ Scheduler_SetTaskMode(CDC1_Task, TASK_STOP); @@ -144,7 +144,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the CDC management tasks are started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints for the first CDC */ Endpoint_ConfigureEndpoint(CDC1_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, @@ -184,7 +184,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the CDC control commands, * which are all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Determine which interface's Line Coding data is being set from the wIndex parameter */ uint8_t* LineCodingData = (USB_ControlRequest.wIndex == 0) ? (uint8_t*)&LineCoding1 : (uint8_t*)&LineCoding2; diff --git a/Demos/Device/DualCDC/DualCDC.h b/Demos/Device/DualCDC/DualCDC.h index 65f661f97..117af601e 100644 --- a/Demos/Device/DualCDC/DualCDC.h +++ b/Demos/Device/DualCDC/DualCDC.h @@ -60,19 +60,6 @@ /** CDC Class specific request to set the current virtual serial port handshake line states. */ #define REQ_SetControlLineState 0x22 - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Type Defines: */ /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration * as set by the host via a class specific request. @@ -121,6 +108,11 @@ TASK(CDC2_Task); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/DualCDC/makefile b/Demos/Device/DualCDC/makefile index fc0005d66..75099c533 100644 --- a/Demos/Device/DualCDC/makefile +++ b/Demos/Device/DualCDC/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/GenericHID/GenericHID.c b/Demos/Device/GenericHID/GenericHID.c index 0369f9f52..f43499a0f 100644 --- a/Demos/Device/GenericHID/GenericHID.c +++ b/Demos/Device/GenericHID/GenericHID.c @@ -75,7 +75,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -87,7 +87,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management task. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running HID reporting and USB management tasks */ Scheduler_SetTaskMode(USB_HID_Report, TASK_STOP); @@ -100,7 +100,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the generic HID device endpoints. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup Generic IN Report Endpoint */ Endpoint_ConfigureEndpoint(GENERIC_IN_EPNUM, EP_TYPE_INTERRUPT, @@ -120,7 +120,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) diff --git a/Demos/Device/GenericHID/GenericHID.h b/Demos/Device/GenericHID/GenericHID.h index 5841595e3..30354b756 100644 --- a/Demos/Device/GenericHID/GenericHID.h +++ b/Demos/Device/GenericHID/GenericHID.h @@ -67,20 +67,15 @@ Status_USBReady = 2, /**< USB interface is connected and ready */ }; - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - /* Task Definitions: */ TASK(USB_HID_Report); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); void ProcessGenericHIDReport(uint8_t* DataArray); void CreateGenericHIDReport(uint8_t* DataArray); diff --git a/Demos/Device/GenericHID/makefile b/Demos/Device/GenericHID/makefile index 23d27911c..c70c6a123 100644 --- a/Demos/Device/GenericHID/makefile +++ b/Demos/Device/GenericHID/makefile @@ -504,7 +504,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 ------------------------------------ diff --git a/Demos/Device/Joystick/Joystick.c b/Demos/Device/Joystick/Joystick.c index e1faeede7..8c50a2c16 100644 --- a/Demos/Device/Joystick/Joystick.c +++ b/Demos/Device/Joystick/Joystick.c @@ -76,7 +76,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -88,7 +88,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and joystick reporting tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running joystick reporting and USB management tasks */ Scheduler_SetTaskMode(USB_Joystick_Report, TASK_STOP); @@ -101,7 +101,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the joystick reporting task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup Joystick Report Endpoint */ Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, @@ -119,7 +119,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) diff --git a/Demos/Device/Joystick/Joystick.h b/Demos/Device/Joystick/Joystick.h index c274b5bc5..9763cada3 100644 --- a/Demos/Device/Joystick/Joystick.h +++ b/Demos/Device/Joystick/Joystick.h @@ -78,20 +78,12 @@ Status_USBReady = 2, /**< USB interface is connected and ready */ }; - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + bool GetNextReport(USB_JoystickReport_Data_t* ReportData); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Device/Joystick/makefile b/Demos/Device/Joystick/makefile index 9ab8ec274..7550ed33b 100644 --- a/Demos/Device/Joystick/makefile +++ b/Demos/Device/Joystick/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/Keyboard/Keyboard.c b/Demos/Device/Keyboard/Keyboard.c index fe041ef08..6abd193f4 100644 --- a/Demos/Device/Keyboard/Keyboard.c +++ b/Demos/Device/Keyboard/Keyboard.c @@ -100,7 +100,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running keyboard reporting and USB management tasks */ Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP); @@ -128,7 +128,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the keyboard device endpoints. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup Keyboard Keycode Report Endpoint */ Endpoint_ConfigureEndpoint(KEYBOARD_EPNUM, EP_TYPE_INTERRUPT, @@ -151,7 +151,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -220,7 +220,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) Endpoint_ClearSETUP(); /* Set or clear the flag depending on what the host indicates that the current Protocol should be */ - UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000); + UsingReportProtocol = (USB_ControlRequest.wValue != 0); /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); diff --git a/Demos/Device/Keyboard/Keyboard.h b/Demos/Device/Keyboard/Keyboard.h index 2cc9c5ca8..c4ed6e07c 100644 --- a/Demos/Device/Keyboard/Keyboard.h +++ b/Demos/Device/Keyboard/Keyboard.h @@ -55,25 +55,25 @@ /* Macros: */ /** Idle period indicating that reports should be sent only when the inputs have changed */ - #define HID_IDLE_CHANGESONLY 0 + #define HID_IDLE_CHANGESONLY 0 /** HID Class specific request to get the next HID report from the device. */ - #define REQ_GetReport 0x01 + #define REQ_GetReport 0x01 /** HID Class specific request to get the idle timeout period of the device. */ - #define REQ_GetIdle 0x02 + #define REQ_GetIdle 0x02 /** HID Class specific request to send the next HID report to the device. */ - #define REQ_SetReport 0x09 + #define REQ_SetReport 0x09 /** HID Class specific request to set the idle timeout period of the device. */ - #define REQ_SetIdle 0x0A + #define REQ_SetIdle 0x0A /** HID Class specific request to get the current HID protocol in use, either report or boot. */ - #define REQ_GetProtocol 0x03 + #define REQ_GetProtocol 0x03 /** HID Class specific request to set the current HID protocol in use, either report or boot. */ - #define REQ_SetProtocol 0x0B + #define REQ_SetProtocol 0x0B /* Task Definitions: */ TASK(USB_Keyboard_Report); @@ -97,25 +97,17 @@ Status_USBEnumerating = 1, /**< USB interface is enumerating */ Status_USBReady = 2, /**< USB interface is connected and ready */ }; - - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData); void ProcessLEDReport(uint8_t LEDReport); void SendNextReport(void); void ReceiveNextReport(void); void UpdateStatus(uint8_t CurrentStatus); - + #endif diff --git a/Demos/Device/Keyboard/makefile b/Demos/Device/Keyboard/makefile index bacf6dc57..3c597bf49 100644 --- a/Demos/Device/Keyboard/makefile +++ b/Demos/Device/Keyboard/makefile @@ -504,7 +504,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 ------------------------------------ diff --git a/Demos/Device/KeyboardMouse/KeyboardMouse.c b/Demos/Device/KeyboardMouse/KeyboardMouse.c index 5c9332849..25d633e43 100644 --- a/Demos/Device/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/KeyboardMouse/KeyboardMouse.c @@ -84,7 +84,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -96,7 +96,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management task. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running HID reporting and USB management tasks */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -108,7 +108,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the keyboard and mouse device endpoints. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup Keyboard Report Endpoint */ Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, @@ -133,7 +133,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { uint8_t* ReportData; uint8_t ReportSize; diff --git a/Demos/Device/KeyboardMouse/KeyboardMouse.h b/Demos/Device/KeyboardMouse/KeyboardMouse.h index 9a1fee1f4..e3f943402 100644 --- a/Demos/Device/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/KeyboardMouse/KeyboardMouse.h @@ -95,20 +95,12 @@ int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */ } USB_MouseReport_Data_t; - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/KeyboardMouse/makefile b/Demos/Device/KeyboardMouse/makefile index e48399877..b26bdbed6 100644 --- a/Demos/Device/KeyboardMouse/makefile +++ b/Demos/Device/KeyboardMouse/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/MIDI/MIDI.c b/Demos/Device/MIDI/MIDI.c index 1323e1163..b6b43df6a 100644 --- a/Demos/Device/MIDI/MIDI.c +++ b/Demos/Device/MIDI/MIDI.c @@ -74,7 +74,7 @@ int main(void) } /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -86,7 +86,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs, disables the sample update and PWM output timers and stops the USB and MIDI management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running audio and USB management tasks */ Scheduler_SetTaskMode(USB_MIDI_Task, TASK_STOP); @@ -99,7 +99,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the MIDI management task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup MIDI stream endpoints */ Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK, diff --git a/Demos/Device/MIDI/MIDI.h b/Demos/Device/MIDI/MIDI.h index 4d801e82f..635036ae8 100644 --- a/Demos/Device/MIDI/MIDI.h +++ b/Demos/Device/MIDI/MIDI.h @@ -80,17 +80,11 @@ /* Task Definitions: */ TASK(USB_MIDI_Task); - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t CableID, const uint8_t Channel); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Device/MIDI/makefile b/Demos/Device/MIDI/makefile index 1ad946e76..89bfc6cc0 100644 --- a/Demos/Device/MIDI/makefile +++ b/Demos/Device/MIDI/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Device/MassStorage/MassStorage.c b/Demos/Device/MassStorage/MassStorage.c index 1da8930b0..82e7e8aa2 100644 --- a/Demos/Device/MassStorage/MassStorage.c +++ b/Demos/Device/MassStorage/MassStorage.c @@ -86,7 +86,7 @@ int main(void) } /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs. */ -EVENT_HANDLER(USB_Connect) +void EventHandler_USB_Connect(void) { /* Indicate USB enumerating */ UpdateStatus(Status_USBEnumerating); @@ -98,7 +98,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the Mass Storage management task. */ -EVENT_HANDLER(USB_Disconnect) +void EventHandler_USB_Disconnect(void) { /* Stop running mass storage task */ Scheduler_SetTaskMode(USB_MassStorage, TASK_STOP); @@ -110,7 +110,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the Mass Storage management task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EventHandler_USB_ConfigurationChanged(void) { /* Setup Mass Storage In and Out Endpoints */ Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK, @@ -132,7 +132,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the Mass Storage class-specific * requests) so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EventHandler_USB_UnhandledControlPacket(void) { /* Process UFI specific control requests */ switch (USB_ControlRequest.bRequest) @@ -283,7 +283,7 @@ static bool ReadInCommandBlock(void) /* Read in command block header */ Endpoint_Read_Stream_LE(&CommandBlock, (sizeof(CommandBlock) - sizeof(CommandBlock.SCSICommandData)), - AbortOnMassStoreReset); + StreamCallback_AbortOnMassStoreReset); /* Check if the current command is being aborted by the host */ if (IsMassStoreReset) @@ -305,7 +305,7 @@ static bool ReadInCommandBlock(void) /* Read in command block command data */ Endpoint_Read_Stream_LE(&CommandBlock.SCSICommandData, CommandBlock.SCSICommandLength, - AbortOnMassStoreReset); + StreamCallback_AbortOnMassStoreReset); /* Check if the current command is being aborted by the host */ if (IsMassStoreReset) @@ -346,7 +346,7 @@ static void ReturnCommandStatus(void) /* Write the CSW to the endpoint */ Endpoint_Write_Stream_LE(&CommandStatus, sizeof(CommandStatus), - AbortOnMassStoreReset); + StreamCallback_AbortOnMassStoreReset); /* Check if the current command is being aborted by the host */ if (IsMassStoreReset) @@ -359,7 +359,7 @@ static void ReturnCommandStatus(void) /** Stream callback function for the Endpoint stream read and write functions. This callback will abort the current stream transfer * if a Mass Storage Reset request has been issued to the control endpoint. */ -STREAM_CALLBACK(AbortOnMassStoreReset) +uint8_t StreamCallback_AbortOnMassStoreReset(void) { /* Abort if a Mass Storage reset command was received */ if (IsMassStoreReset) diff --git a/Demos/Device/MassStorage/MassStorage.h b/Demos/Device/MassStorage/MassStorage.h index f0baf1461..afe9872ea 100644 --- a/Demos/Device/MassStorage/MassStorage.h +++ b/Demos/Device/MassStorage/MassStorage.h @@ -130,23 +130,12 @@ /* Task Definitions: */ TASK(USB_MassStorage); - /* Stream Callbacks: */ - STREAM_CALLBACK(AbortOnMassStoreReset); - - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #if defined(INCLUDE_FROM_MASSSTORAGE_C) @@ -154,4 +143,6 @@ static void ReturnCommandStatus(void); #endif + uint8_t StreamCallback_AbortOnMassStoreReset(void); + #endif diff --git a/Demos/Device/MassStorage/SCSI.c b/Demos/Device/MassStorage/SCSI.c index a88be515a..5993a546d 100644 --- a/Demos/Device/MassStorage/SCSI.c +++ b/Demos/Device/MassStorage/SCSI.c @@ -166,12 +166,12 @@ static bool SCSI_Command_Inquiry(void) } /* Write the INQUIRY data to the endpoint */ - Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, AbortOnMassStoreReset); + Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, StreamCallback_AbortOnMassStoreReset); uint8_t PadBytes[AllocationLength - BytesTransferred]; /* Pad out remaining bytes with 0x00 */ - Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset); + Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), StreamCallback_AbortOnMassStoreReset); /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); @@ -193,12 +193,12 @@ static bool SCSI_Command_Request_Sense(void) uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData); /* Send the SENSE data - this indicates to the host the status of the last command */ - Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, AbortOnMassStoreReset); + Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, StreamCallback_AbortOnMassStoreReset); uint8_t PadBytes[AllocationLength - BytesTransferred]; /* Pad out remaining bytes with 0x00 */ - Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), AbortOnMassStoreReset); + Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), StreamCallback_AbortOnMassStoreReset); /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); diff --git a/Demos/Device/MassStorage/makefile b/Demos/Device/MassStorage/makefile index 65a22c6a3..95c91f61d 100644 --- a/Demos/Device/MassStorage/makefile +++ b/Demos/Device/MassStorage/makefile @@ -508,7 +508,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 ------------------------------------ diff --git a/Demos/Device/Mouse/Mouse.c b/Demos/Device/Mouse/Mouse.c index 9dc2f9d04..32b12fc61 100644 --- a/Demos/Device/Mouse/Mouse.c +++ b/Demos/Device/Mouse/Mouse.c @@ -100,7 +100,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and Mouse reporting tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running mouse reporting and USB management tasks */ Scheduler_SetTaskMode(USB_Mouse_Report, TASK_STOP); @@ -128,7 +128,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration - the device endpoints are configured and the mouse reporting task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup Mouse Report Endpoint */ Endpoint_ConfigureEndpoint(MOUSE_EPNUM, EP_TYPE_INTERRUPT, @@ -146,7 +146,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are * all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Handle HID Class specific requests */ switch (USB_ControlRequest.bRequest) @@ -195,7 +195,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) Endpoint_ClearSETUP(); /* Set or clear the flag depending on what the host indicates that the current Protocol should be */ - UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000); + UsingReportProtocol = (USB_ControlRequest.wValue != 0); /* Acknowledge status stage */ while (!(Endpoint_IsINReady())); diff --git a/Demos/Device/Mouse/Mouse.h b/Demos/Device/Mouse/Mouse.h index 3bbbac234..65879da8e 100644 --- a/Demos/Device/Mouse/Mouse.h +++ b/Demos/Device/Mouse/Mouse.h @@ -98,20 +98,12 @@ Status_USBReady = 2, /**< USB interface is connected and ready */ }; - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void CreateMouseReport(USB_MouseReport_Data_t* ReportData); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Device/Mouse/makefile b/Demos/Device/Mouse/makefile index 3fa887b7b..d5ad21145 100644 --- a/Demos/Device/Mouse/makefile +++ b/Demos/Device/Mouse/makefile @@ -504,7 +504,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 ------------------------------------ diff --git a/Demos/Device/RNDISEthernet/RNDISEthernet.c b/Demos/Device/RNDISEthernet/RNDISEthernet.c index fd88ecf89..b046f7870 100644 --- a/Demos/Device/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/RNDISEthernet/RNDISEthernet.c @@ -83,7 +83,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -95,7 +95,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops all the relevant tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running TCP/IP and USB management tasks */ Scheduler_SetTaskMode(RNDIS_Task, TASK_STOP); @@ -110,7 +110,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration * of the USB device after enumeration, and configures the RNDIS device endpoints and starts the relevant tasks. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints */ Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, @@ -138,7 +138,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the RNDIS control commands, * which set up the USB RNDIS network adapter), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { /* Process RNDIS class commands */ switch (USB_ControlRequest.bRequest) diff --git a/Demos/Device/RNDISEthernet/RNDISEthernet.h b/Demos/Device/RNDISEthernet/RNDISEthernet.h index b3fd4dbd5..7c3c8dabe 100644 --- a/Demos/Device/RNDISEthernet/RNDISEthernet.h +++ b/Demos/Device/RNDISEthernet/RNDISEthernet.h @@ -60,19 +60,6 @@ /* Macros: */ /** Notification value to indicate that a frame is ready to be read by the host. */ #define NOTIF_RESPONSE_AVAILABLE 0x01 - - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); /* Type Defines: */ /** Type define for a RNDIS notification message, for transmission to the RNDIS host via the notification @@ -102,6 +89,11 @@ TASK(Ethernet_Task); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Device/RNDISEthernet/makefile b/Demos/Device/RNDISEthernet/makefile index 7a9722bbf..e46b13bf2 100644 --- a/Demos/Device/RNDISEthernet/makefile +++ b/Demos/Device/RNDISEthernet/makefile @@ -518,7 +518,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 ------------------------------------ diff --git a/Demos/Device/USBtoSerial/USBtoSerial.c b/Demos/Device/USBtoSerial/USBtoSerial.c index ea8dcd599..ef51a6eeb 100644 --- a/Demos/Device/USBtoSerial/USBtoSerial.c +++ b/Demos/Device/USBtoSerial/USBtoSerial.c @@ -93,7 +93,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_Connect) +void EVENT_USB_Connect(void) { /* Start USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via * the status LEDs and stops the USB management and CDC management tasks. */ -EVENT_HANDLER(USB_Disconnect) +void EVENT_USB_Disconnect(void) { /* Stop running CDC and USB management tasks */ Scheduler_SetTaskMode(CDC_Task, TASK_STOP); @@ -122,7 +122,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration * of the USB device after enumeration - the device endpoints are configured and the CDC management task started. */ -EVENT_HANDLER(USB_ConfigurationChanged) +void EVENT_USB_ConfigurationChanged(void) { /* Setup CDC Notification, Rx and Tx Endpoints */ Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, @@ -148,7 +148,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the CDC control commands, * which are all issued via the control endpoint), so that they can be handled appropriately for the application. */ -EVENT_HANDLER(USB_UnhandledControlPacket) +void EVENT_USB_UnhandledControlPacket(void) { uint8_t* LineCodingData = (uint8_t*)&LineCoding; diff --git a/Demos/Device/USBtoSerial/USBtoSerial.h b/Demos/Device/USBtoSerial/USBtoSerial.h index 0352f5d75..cd1f42c3f 100644 --- a/Demos/Device/USBtoSerial/USBtoSerial.h +++ b/Demos/Device/USBtoSerial/USBtoSerial.h @@ -112,19 +112,6 @@ */ #define CONTROL_LINE_IN_OVERRUNERROR (1 << 6) - /* Event Handlers: */ - /** 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_ConfigurationChanged event when thrown by the library. */ - HANDLES_EVENT(USB_ConfigurationChanged); - - /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ - HANDLES_EVENT(USB_UnhandledControlPacket); - /* Type Defines: */ /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration * as set by the host via a class specific request. @@ -186,6 +173,11 @@ TASK(CDC_Task); /* Function Prototypes: */ + void EVENT_USB_Connect(void); + void EVENT_USB_Disconnect(void); + void EVENT_USB_ConfigurationChanged(void); + void EVENT_USB_UnhandledControlPacket(void); + void ReconfigureUSART(void); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Device/USBtoSerial/makefile b/Demos/Device/USBtoSerial/makefile index 6f7f64182..8808abe2f 100644 --- a/Demos/Device/USBtoSerial/makefile +++ b/Demos/Device/USBtoSerial/makefile @@ -506,7 +506,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 ------------------------------------ diff --git a/Demos/Host/CDCHost/CDCHost.c b/Demos/Host/CDCHost/CDCHost.c index a4194090a..b83473106 100644 --- a/Demos/Host/CDCHost/CDCHost.c +++ b/Demos/Host/CDCHost/CDCHost.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop keyboard and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start CDC Host task */ Scheduler_SetTaskMode(USB_CDC_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/CDCHost/CDCHost.h b/Demos/Host/CDCHost/CDCHost.h index 3819540d6..afec780e7 100644 --- a/Demos/Host/CDCHost/CDCHost.h +++ b/Demos/Host/CDCHost/CDCHost.h @@ -76,14 +76,13 @@ /* Task Definitions: */ TASK(USB_CDC_Host); - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); - /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); #endif diff --git a/Demos/Host/CDCHost/ConfigDescriptor.c b/Demos/Host/CDCHost/ConfigDescriptor.c index faad3ccd2..baf02a216 100644 --- a/Demos/Host/CDCHost/ConfigDescriptor.c +++ b/Demos/Host/CDCHost/ConfigDescriptor.c @@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the CDC control interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoCDCInterfaceFound; @@ -82,14 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Fetch the next bulk or interrupt endpoint from the current CDC interface */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */ if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE)) { /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoCDCInterfaceFound; @@ -110,7 +110,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoCDCInterfaceFound; @@ -119,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Fetch the next bulk or interrupt endpoint from the current CDC interface */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -186,7 +186,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextCDCControlInterface) +uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -210,7 +210,7 @@ DESCRIPTOR_COMPARATOR(NextCDCControlInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextCDCDataInterface) +uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -236,7 +236,7 @@ DESCRIPTOR_COMPARATOR(NextCDCDataInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceCDCDataEndpoint) +uint8_t DComp_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { diff --git a/Demos/Host/CDCHost/ConfigDescriptor.h b/Demos/Host/CDCHost/ConfigDescriptor.h index ea00f610f..1a118cad3 100644 --- a/Demos/Host/CDCHost/ConfigDescriptor.h +++ b/Demos/Host/CDCHost/ConfigDescriptor.h @@ -75,12 +75,11 @@ NoEndpointFound = 5, /**< Compatible CDC endpoints were not found in the device's CDC interface */ }; - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextCDCControlInterface); - DESCRIPTOR_COMPARATOR(NextCDCDataInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceCDCDataEndpoint); - /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); - + + uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor); + uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor); + #endif diff --git a/Demos/Host/CDCHost/makefile b/Demos/Host/CDCHost/makefile index ecd6269de..d9c58a377 100644 --- a/Demos/Host/CDCHost/makefile +++ b/Demos/Host/CDCHost/makefile @@ -506,7 +506,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 ------------------------------------ diff --git a/Demos/Host/GenericHIDHost/ConfigDescriptor.c b/Demos/Host/GenericHIDHost/ConfigDescriptor.c index 1c0a6b291..29fa60ba3 100644 --- a/Demos/Host/GenericHIDHost/ConfigDescriptor.c +++ b/Demos/Host/GenericHIDHost/ConfigDescriptor.c @@ -72,7 +72,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the HID interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDInterfaceFound; @@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Get the next HID interface's data endpoint descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Not all HID devices have an OUT endpoint - if we've reached the end of the HID descriptor * but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */ @@ -129,7 +129,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextHIDInterface) +uint8_t DComp_NextHIDInterface(void* CurrentDescriptor) { /* Determine if the current descriptor is an interface descriptor */ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) @@ -155,7 +155,7 @@ DESCRIPTOR_COMPARATOR(NextHIDInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceHIDDataEndpoint) +uint8_t DComp_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor) { /* Determine the type of the current descriptor */ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) diff --git a/Demos/Host/GenericHIDHost/ConfigDescriptor.h b/Demos/Host/GenericHIDHost/ConfigDescriptor.h index fac772979..b58d44027 100644 --- a/Demos/Host/GenericHIDHost/ConfigDescriptor.h +++ b/Demos/Host/GenericHIDHost/ConfigDescriptor.h @@ -60,11 +60,10 @@ NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */ }; - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextHIDInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceHIDDataEndpoint); - /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + + uint8_t DComp_NextHIDInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor); #endif diff --git a/Demos/Host/GenericHIDHost/GenericHIDHost.c b/Demos/Host/GenericHIDHost/GenericHIDHost.c index 580612c97..e731f90cf 100644 --- a/Demos/Host/GenericHIDHost/GenericHIDHost.c +++ b/Demos/Host/GenericHIDHost/GenericHIDHost.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop HID and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start HID Host task */ Scheduler_SetTaskMode(USB_HID_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/GenericHIDHost/GenericHIDHost.h b/Demos/Host/GenericHIDHost/GenericHIDHost.h index 3ae473e00..7e2f8b822 100644 --- a/Demos/Host/GenericHIDHost/GenericHIDHost.h +++ b/Demos/Host/GenericHIDHost/GenericHIDHost.h @@ -82,15 +82,14 @@ Status_EnumerationError = 3, /**< Software error while enumerating the attached USB device */ Status_HardwareError = 4, /**< Hardware error while enumerating the attached USB device */ }; - - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); void ReadNextReport(void); void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t ReportType, uint16_t ReportLength); diff --git a/Demos/Host/GenericHIDHost/makefile b/Demos/Host/GenericHIDHost/makefile index d261da927..617ab7e5b 100644 --- a/Demos/Host/GenericHIDHost/makefile +++ b/Demos/Host/GenericHIDHost/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Host/KeyboardHost/ConfigDescriptor.c b/Demos/Host/KeyboardHost/ConfigDescriptor.c index b0233d98c..e586ea5d3 100644 --- a/Demos/Host/KeyboardHost/ConfigDescriptor.c +++ b/Demos/Host/KeyboardHost/ConfigDescriptor.c @@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the keyboard interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDInterfaceFound; @@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the keyboard interface's data endpoint descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -105,7 +105,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextKeyboardInterface) +uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -129,7 +129,7 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint) +uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { diff --git a/Demos/Host/KeyboardHost/ConfigDescriptor.h b/Demos/Host/KeyboardHost/ConfigDescriptor.h index 416315b97..425f0a4be 100644 --- a/Demos/Host/KeyboardHost/ConfigDescriptor.h +++ b/Demos/Host/KeyboardHost/ConfigDescriptor.h @@ -62,12 +62,11 @@ NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's Configuration Descriptor */ NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */ }; - - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextKeyboardInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint); /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + + uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor); #endif diff --git a/Demos/Host/KeyboardHost/KeyboardHost.c b/Demos/Host/KeyboardHost/KeyboardHost.c index 628a27314..2b9bb2b0b 100644 --- a/Demos/Host/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/KeyboardHost/KeyboardHost.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop Keyboard and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start Keyboard Host task */ Scheduler_SetTaskMode(USB_Keyboard_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/KeyboardHost/KeyboardHost.h b/Demos/Host/KeyboardHost/KeyboardHost.h index 6a601439a..d00b76afb 100644 --- a/Demos/Host/KeyboardHost/KeyboardHost.h +++ b/Demos/Host/KeyboardHost/KeyboardHost.h @@ -83,14 +83,13 @@ /* Task Definitions: */ TASK(USB_Keyboard_Host); - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); - /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); void ReadNextReport(void); diff --git a/Demos/Host/KeyboardHost/makefile b/Demos/Host/KeyboardHost/makefile index e304974e2..9ea163e66 100644 --- a/Demos/Host/KeyboardHost/makefile +++ b/Demos/Host/KeyboardHost/makefile @@ -506,7 +506,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 ------------------------------------ diff --git a/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.c index 9cdf6f88a..4ee3b998f 100644 --- a/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.c @@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the keyboard interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDInterfaceFound; @@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the keyboard interface's HID descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextHID) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDDescriptorFound; @@ -89,7 +89,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the keyboard interface's data endpoint descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -116,7 +116,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextKeyboardInterface) +uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -140,7 +140,7 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint) +uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { @@ -163,7 +163,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextHID) +uint8_t DComp_NextHID(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) return DESCRIPTOR_SEARCH_Found; diff --git a/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.h b/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.h index 1deff6328..338adc93b 100644 --- a/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.h +++ b/Demos/Host/KeyboardHostWithParser/ConfigDescriptor.h @@ -68,13 +68,12 @@ NoHIDDescriptorFound = 5, /**< A compatible HID descriptor was not found in the device's HID interface */ NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */ }; - - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextKeyboardInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint); - DESCRIPTOR_COMPARATOR(NextHID); /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor); + uint8_t DComp_NextHID(void* CurrentDescriptor); + #endif diff --git a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c index 9eb3d108a..840cb90cf 100644 --- a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop keyboard and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start Keyboard Host task */ Scheduler_SetTaskMode(USB_Keyboard_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.h b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.h index a0e055fa6..acb5b8b3e 100644 --- a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.h +++ b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.h @@ -67,14 +67,13 @@ /* Task Definitions: */ TASK(USB_Keyboard_Host); - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); - /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); void ProcessKeyboardReport(uint8_t* KeyboardReport); diff --git a/Demos/Host/KeyboardHostWithParser/makefile b/Demos/Host/KeyboardHostWithParser/makefile index ad8f07253..43559d8f1 100644 --- a/Demos/Host/KeyboardHostWithParser/makefile +++ b/Demos/Host/KeyboardHostWithParser/makefile @@ -507,7 +507,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 ------------------------------------ diff --git a/Demos/Host/MassStorageHost/ConfigDescriptor.c b/Demos/Host/MassStorageHost/ConfigDescriptor.c index c02f3b0de..c951c797e 100644 --- a/Demos/Host/MassStorageHost/ConfigDescriptor.c +++ b/Demos/Host/MassStorageHost/ConfigDescriptor.c @@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mass storage interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoInterfaceFound; @@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Fetch the next bulk endpoint from the current mass storage interface */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -127,7 +127,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextMassStorageInterface) +uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -152,7 +152,7 @@ DESCRIPTOR_COMPARATOR(NextMassStorageInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceBulkDataEndpoint) +uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { diff --git a/Demos/Host/MassStorageHost/ConfigDescriptor.h b/Demos/Host/MassStorageHost/ConfigDescriptor.h index b02e08828..6c0b8e6f4 100644 --- a/Demos/Host/MassStorageHost/ConfigDescriptor.h +++ b/Demos/Host/MassStorageHost/ConfigDescriptor.h @@ -65,12 +65,11 @@ NoInterfaceFound = 4, /**< A compatible MSD interface was not found in the device's Configuration Descriptor */ NoEndpointFound = 5, /**< The correct MSD endpoint descriptors were not found in the device's MSD interface */ }; - - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextMassStorageInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceBulkDataEndpoint); - + /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); + uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor); + #endif diff --git a/Demos/Host/MassStorageHost/MassStorageHost.c b/Demos/Host/MassStorageHost/MassStorageHost.c index d06e3a63a..a2e6631e2 100644 --- a/Demos/Host/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/MassStorageHost/MassStorageHost.c @@ -85,7 +85,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -97,7 +97,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop USB management and Mass Storage tasks */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -110,7 +110,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Once device is fully enumerated, start the Mass Storage Host task */ Scheduler_SetTaskMode(USB_MassStore_Host, TASK_RUN); @@ -120,7 +120,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -134,7 +134,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/MassStorageHost/MassStorageHost.h b/Demos/Host/MassStorageHost/MassStorageHost.h index 216065970..1646ad75e 100644 --- a/Demos/Host/MassStorageHost/MassStorageHost.h +++ b/Demos/Host/MassStorageHost/MassStorageHost.h @@ -70,15 +70,14 @@ /* Task Definitions: */ TASK(USB_MassStore_Host); - - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); /* Function Prototypes: */ + 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 ShowDiskReadError(char* CommandString, bool FailedAtSCSILayer, uint8_t ErrorCode); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Host/MassStorageHost/makefile b/Demos/Host/MassStorageHost/makefile index 6987794bc..5c1de65ea 100644 --- a/Demos/Host/MassStorageHost/makefile +++ b/Demos/Host/MassStorageHost/makefile @@ -508,7 +508,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 ------------------------------------ diff --git a/Demos/Host/MouseHost/ConfigDescriptor.c b/Demos/Host/MouseHost/ConfigDescriptor.c index 435a4f90c..0f6ab59ae 100644 --- a/Demos/Host/MouseHost/ConfigDescriptor.c +++ b/Demos/Host/MouseHost/ConfigDescriptor.c @@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mouse interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDInterfaceFound; @@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mouse interface's data endpoint descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -105,7 +105,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextMouseInterface) +uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) { /* Determine if the current descriptor is an interface descriptor */ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) @@ -132,7 +132,7 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint) +uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor) { /* Determine the type of the current descriptor */ if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) diff --git a/Demos/Host/MouseHost/ConfigDescriptor.h b/Demos/Host/MouseHost/ConfigDescriptor.h index 40286e546..cb1ae63ad 100644 --- a/Demos/Host/MouseHost/ConfigDescriptor.h +++ b/Demos/Host/MouseHost/ConfigDescriptor.h @@ -61,13 +61,12 @@ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's Configuration Descriptor */ NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */ - }; - - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextMouseInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint); + }; /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + + uint8_t DComp_NextMouseInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor); #endif diff --git a/Demos/Host/MouseHost/MouseHost.c b/Demos/Host/MouseHost/MouseHost.c index 77db55282..7db95808a 100644 --- a/Demos/Host/MouseHost/MouseHost.c +++ b/Demos/Host/MouseHost/MouseHost.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop mouse and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start Mouse Host task */ Scheduler_SetTaskMode(USB_Mouse_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/MouseHost/MouseHost.h b/Demos/Host/MouseHost/MouseHost.h index 81b0412c5..7111218ba 100644 --- a/Demos/Host/MouseHost/MouseHost.h +++ b/Demos/Host/MouseHost/MouseHost.h @@ -83,14 +83,13 @@ Status_HardwareError = 4, /**< Hardware error while enumerating the attached USB device */ }; - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); - /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); void ReadNextReport(void); diff --git a/Demos/Host/MouseHost/makefile b/Demos/Host/MouseHost/makefile index 1cfba959a..4987c9dde 100644 --- a/Demos/Host/MouseHost/makefile +++ b/Demos/Host/MouseHost/makefile @@ -505,7 +505,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 ------------------------------------ diff --git a/Demos/Host/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/MouseHostWithParser/ConfigDescriptor.c index c00852372..5d9d3f04e 100644 --- a/Demos/Host/MouseHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/MouseHostWithParser/ConfigDescriptor.c @@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mouse interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDInterfaceFound; @@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mouse interface's HID descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextHID) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoHIDDescriptorFound; @@ -89,7 +89,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the mouse interface's data endpoint descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -116,7 +116,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextMouseInterface) +uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -140,7 +140,7 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint) +uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { @@ -163,7 +163,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextHID) +uint8_t DComp_NextHID(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) return DESCRIPTOR_SEARCH_Found; diff --git a/Demos/Host/MouseHostWithParser/ConfigDescriptor.h b/Demos/Host/MouseHostWithParser/ConfigDescriptor.h index 7cb12dbca..08400c50f 100644 --- a/Demos/Host/MouseHostWithParser/ConfigDescriptor.h +++ b/Demos/Host/MouseHostWithParser/ConfigDescriptor.h @@ -69,13 +69,12 @@ NoHIDDescriptorFound = 5, /**< A compatible HID descriptor was not found in the device's HID interface */ NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */ }; - - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextMouseInterface); - DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint); - DESCRIPTOR_COMPARATOR(NextHID); /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + + uint8_t DComp_NextMouseInterface(void* CurrentDescriptor); + uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor); + uint8_t DComp_NextHID(void* CurrentDescriptor); #endif diff --git a/Demos/Host/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/MouseHostWithParser/MouseHostWithParser.c index 58a189f6b..f26e9e2a6 100644 --- a/Demos/Host/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/MouseHostWithParser/MouseHostWithParser.c @@ -80,7 +80,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -92,7 +92,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop mouse and USB management task */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -105,7 +105,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Start Mouse Host task */ Scheduler_SetTaskMode(USB_Mouse_Host, TASK_RUN); @@ -115,7 +115,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/MouseHostWithParser/MouseHostWithParser.h index 99970e261..f2cc2fd00 100644 --- a/Demos/Host/MouseHostWithParser/MouseHostWithParser.h +++ b/Demos/Host/MouseHostWithParser/MouseHostWithParser.h @@ -66,15 +66,14 @@ /* Task Definitions: */ TASK(USB_Mouse_Host); - - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); /* Function Prototypes: */ + 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 UpdateStatus(uint8_t CurrentStatus); void ProcessMouseReport(uint8_t* MouseReport); diff --git a/Demos/Host/MouseHostWithParser/makefile b/Demos/Host/MouseHostWithParser/makefile index 4e1aa90b4..be8f48f7d 100644 --- a/Demos/Host/MouseHostWithParser/makefile +++ b/Demos/Host/MouseHostWithParser/makefile @@ -507,7 +507,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 ------------------------------------ diff --git a/Demos/Host/StillImageHost/ConfigDescriptor.c b/Demos/Host/StillImageHost/ConfigDescriptor.c index b58dfb8bd..108496964 100644 --- a/Demos/Host/StillImageHost/ConfigDescriptor.c +++ b/Demos/Host/StillImageHost/ConfigDescriptor.c @@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Get the Still Image interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoInterfaceFound; @@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Fetch the next endpoint from the current Still Image interface */ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { /* Descriptor not found, error out */ return NoEndpointFound; @@ -148,7 +148,7 @@ uint8_t ProcessConfigurationDescriptor(void) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextStillImageInterface) +uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) { @@ -173,7 +173,7 @@ DESCRIPTOR_COMPARATOR(NextStillImageInterface) * * \return A value from the DSEARCH_Return_ErrorCodes_t enum */ -DESCRIPTOR_COMPARATOR(NextSImageInterfaceDataEndpoint) +uint8_t DComp_NextSImageInterfaceDataEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { diff --git a/Demos/Host/StillImageHost/ConfigDescriptor.h b/Demos/Host/StillImageHost/ConfigDescriptor.h index cb4de5f46..29df30c0c 100644 --- a/Demos/Host/StillImageHost/ConfigDescriptor.h +++ b/Demos/Host/StillImageHost/ConfigDescriptor.h @@ -66,11 +66,10 @@ NoEndpointFound = 5, /**< The correct SI endpoint descriptors were not found in the device's SI interface */ }; - /* Configuration Descriptor Comparison Functions: */ - DESCRIPTOR_COMPARATOR(NextStillImageInterface); - DESCRIPTOR_COMPARATOR(NextSImageInterfaceDataEndpoint); - /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); + + uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor); + uint8_t DComp_NextSImageInterfaceDataEndpoint(void* CurrentDescriptor); #endif diff --git a/Demos/Host/StillImageHost/StillImageHost.c b/Demos/Host/StillImageHost/StillImageHost.c index ceec151aa..197e832f6 100644 --- a/Demos/Host/StillImageHost/StillImageHost.c +++ b/Demos/Host/StillImageHost/StillImageHost.c @@ -81,7 +81,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -93,7 +93,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop USB management and Still Image tasks */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -106,7 +106,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Once device is fully enumerated, start the Still Image Host task */ Scheduler_SetTaskMode(USB_SImage_Host, TASK_RUN); @@ -116,7 +116,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -130,7 +130,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -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); diff --git a/Demos/Host/StillImageHost/StillImageHost.h b/Demos/Host/StillImageHost/StillImageHost.h index 4c9091cfe..909ed89bc 100644 --- a/Demos/Host/StillImageHost/StillImageHost.h +++ b/Demos/Host/StillImageHost/StillImageHost.h @@ -68,14 +68,13 @@ /* Task Definitions: */ TASK(USB_SImage_Host); - /* Event Handlers: */ - HANDLES_EVENT(USB_DeviceAttached); - HANDLES_EVENT(USB_DeviceUnattached); - HANDLES_EVENT(USB_DeviceEnumerationComplete); - HANDLES_EVENT(USB_HostError); - HANDLES_EVENT(USB_DeviceEnumerationFailed); - /* Function Prototypes: */ + 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 UnicodeToASCII(uint8_t* restrict UnicodeString, char* restrict Buffer); void ShowCommandError(uint8_t ErrorCode, bool ResponseCodeError); void UpdateStatus(uint8_t CurrentStatus); diff --git a/Demos/Host/StillImageHost/makefile b/Demos/Host/StillImageHost/makefile index f78d66c03..3663d4804 100644 --- a/Demos/Host/StillImageHost/makefile +++ b/Demos/Host/StillImageHost/makefile @@ -506,7 +506,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 ------------------------------------ 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