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.
pull/1469/head
Dean Camera 16 years ago
parent 72c2922e38
commit 2ee9fc7077

@ -119,7 +119,7 @@ int main(void)
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user /** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
* application started. * application started.
*/ */
EVENT_HANDLER(USB_Disconnect) void EVENT_USB_Disconnect(void)
{ {
/* Upon disconnection, run user application */ /* Upon disconnection, run user application */
RunBootloader = false; RunBootloader = false;
@ -128,7 +128,7 @@ EVENT_HANDLER(USB_Disconnect)
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
* to relay data to and from the attached USB host. * to relay data to and from the attached USB host.
*/ */
EVENT_HANDLER(USB_ConfigurationChanged) void EVENT_USB_ConfigurationChanged(void)
{ {
/* Setup CDC Notification, Rx and Tx Endpoints */ /* Setup CDC Notification, Rx and Tx Endpoints */
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, 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, so that they can be handled appropriately * control requests that are not handled internally by the USB library, so that they can be handled appropriately
* for the application. * for the application.
*/ */
EVENT_HANDLER(USB_UnhandledControlPacket) void EVENT_USB_UnhandledControlPacket(void)
{ {
uint8_t* LineCodingData = (uint8_t*)&LineCoding; uint8_t* LineCodingData = (uint8_t*)&LineCoding;

@ -83,16 +83,6 @@
/** Eight character bootloader firmware identifier reported to the host when requested */ /** Eight character bootloader firmware identifier reported to the host when requested */
#define SOFTWARE_IDENTIFIER "LUFACDC" #define SOFTWARE_IDENTIFIER "LUFACDC"
/* Event Handlers: */
/** 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 Defines: */
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
@ -132,6 +122,10 @@
TASK(CDC_Task); TASK(CDC_Task);
/* Function Prototypes: */ /* Function Prototypes: */
void EVENT_USB_Disconnect(void);
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
static void ReadWriteMemoryBlock(const uint8_t Command); static void ReadWriteMemoryBlock(const uint8_t Command);
static uint8_t FetchNextCommandByte(void); static uint8_t FetchNextCommandByte(void);

@ -502,7 +502,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -139,7 +139,7 @@ int main (void)
/** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user /** Event handler for the USB_Disconnect event. This indicates that the bootloader should exit and the user
* application started. * application started.
*/ */
EVENT_HANDLER(USB_Disconnect) void EventHandler_USB_Disconnect(void)
{ {
/* Upon disconnection, run user application */ /* Upon disconnection, run user application */
RunBootloader = false; RunBootloader = false;
@ -149,7 +149,7 @@ EVENT_HANDLER(USB_Disconnect)
* control requests that are not handled internally by the USB library (including the DFU commands, which are * control requests that are not handled internally by the USB library (including the DFU commands, which are
* all issued via the control endpoint), so that they can be handled appropriately for the application. * all issued via the control endpoint), so that they can be handled appropriately for the application.
*/ */
EVENT_HANDLER(USB_UnhandledControlPacket) void EventHandler_USB_UnhandledControlPacket(void)
{ {
/* Get the size of the command and data from the wLength value */ /* Get the size of the command and data from the wLength value */
SentCommand.DataSize = USB_ControlRequest.wLength; SentCommand.DataSize = USB_ControlRequest.wLength;

@ -191,15 +191,11 @@
errUNKNOWN = 14, errUNKNOWN = 14,
errSTALLEDPKT = 15 errSTALLEDPKT = 15
}; };
/* Event Handlers: */
/** 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_UnhandledControlPacket event when thrown by the library. */
HANDLES_EVENT(USB_UnhandledControlPacket);
/* Function Prototypes: */ /* Function Prototypes: */
void EVENT_USB_Disconnect(void);
void EVENT_USB_UnhandledControlPacket(void);
#if defined(INCLUDE_FROM_BOOTLOADER_C) #if defined(INCLUDE_FROM_BOOTLOADER_C)
static void DiscardFillerBytes(uint8_t NumberOfBytes); static void DiscardFillerBytes(uint8_t NumberOfBytes);
static void ProcessBootloaderCommand(void); static void ProcessBootloaderCommand(void);

@ -503,7 +503,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -81,7 +81,7 @@ int main(void)
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
* to relay data to and from the attached USB host. * to relay data to and from the attached USB host.
*/ */
EVENT_HANDLER(USB_ConfigurationChanged) void EVENT_USB_ConfigurationChanged(void)
{ {
/* Setup HID Report Endpoint */ /* Setup HID Report Endpoint */
Endpoint_ConfigureEndpoint(HID_EPNUM, EP_TYPE_INTERRUPT, Endpoint_ConfigureEndpoint(HID_EPNUM, EP_TYPE_INTERRUPT,
@ -93,7 +93,7 @@ EVENT_HANDLER(USB_ConfigurationChanged)
* control requests that are not handled internally by the USB library (including the HID commands, which are * 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. * 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 */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -60,15 +60,9 @@
#define REQ_SetReport 0x09 #define REQ_SetReport 0x09
#define TEENSY_STARTAPPLICATION 0xFFFF #define TEENSY_STARTAPPLICATION 0xFFFF
/* Event Handlers: */ /* Function Prototypes: */
/** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ void EVENT_USB_ConfigurationChanged(void);
HANDLES_EVENT(USB_Disconnect); void EVENT_USB_UnhandledControlPacket(void);
/** 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);
#endif #endif

@ -502,7 +502,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * configures the sample update and PWM timers.
*/ */
EVENT_HANDLER(USB_Connect) void EVENT_USB_Connect(void)
{ {
/* Start USB management task */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop the sample reload timer */
TCCR0B = 0; 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 /** 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. * of the USB device after enumeration - the device endpoints are configured.
*/ */
EVENT_HANDLER(USB_ConfigurationChanged) void EVENT_USB_ConfigurationChanged(void)
{ {
/* Setup audio stream endpoint */ /* Setup audio stream endpoint */
Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, 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 * 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. * 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 */ /* Process General and Audio specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -71,20 +71,12 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_Audio_Task); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * configures the sample update and PWM timers.
*/ */
EVENT_HANDLER(USB_Connect) void EventHandler_USB_Connect(void)
{ {
/* Start USB management task */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop the timers */
TCCR0B = 0; 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 /** 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. * of the USB device after enumeration - the device endpoints are configured.
*/ */
EVENT_HANDLER(USB_ConfigurationChanged) void EventHandler_USB_ConfigurationChanged(void)
{ {
/* Setup audio stream endpoint */ /* Setup audio stream endpoint */
Endpoint_ConfigureEndpoint(AUDIO_STREAM_EPNUM, EP_TYPE_ISOCHRONOUS, 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 * 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. * 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 */ /* Process General and Audio specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -107,21 +107,13 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_Audio_Task); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running CDC and USB management tasks */
Scheduler_SetTaskMode(CDC_Task, TASK_STOP); 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 /** 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. * 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 */ /* Setup CDC Notification, Rx and Tx Endpoints */
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, 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, * 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. * 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; uint8_t* LineCodingData = (uint8_t*)&LineCoding;

@ -111,19 +111,6 @@
*/ */
#define CONTROL_LINE_IN_OVERRUNERROR (1 << 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 Defines: */
/** Type define for the virtual serial port line encoding settings, for storing the current USART configuration /** 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. * as set by the host via a class specific request.
@ -185,6 +172,11 @@
TASK(CDC_Task); TASK(CDC_Task);
/* Function Prototypes: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running CDC and USB management tasks */
Scheduler_SetTaskMode(CDC1_Task, TASK_STOP); 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 /** 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. * 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 */ /* Setup CDC Notification, Rx and Tx Endpoints for the first CDC */
Endpoint_ConfigureEndpoint(CDC1_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, 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, * 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. * 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 */ /* 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; uint8_t* LineCodingData = (USB_ControlRequest.wIndex == 0) ? (uint8_t*)&LineCoding1 : (uint8_t*)&LineCoding2;

@ -60,19 +60,6 @@
/** CDC Class specific request to set the current virtual serial port handshake line states. */ /** CDC Class specific request to set the current virtual serial port handshake line states. */
#define REQ_SetControlLineState 0x22 #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 Defines: */
/** Type define for the virtual serial port line encoding settings, for storing the current USART configuration /** 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. * as set by the host via a class specific request.
@ -121,6 +108,11 @@
TASK(CDC2_Task); TASK(CDC2_Task);
/* Function Prototypes: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running HID reporting and USB management tasks */
Scheduler_SetTaskMode(USB_HID_Report, TASK_STOP); 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 /** 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. * 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 */ /* Setup Generic IN Report Endpoint */
Endpoint_ConfigureEndpoint(GENERIC_IN_EPNUM, EP_TYPE_INTERRUPT, 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 * 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. * 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 */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -67,20 +67,15 @@
Status_USBReady = 2, /**< USB interface is connected and ready */ 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 Definitions: */
TASK(USB_HID_Report); TASK(USB_HID_Report);
/* Function Prototypes: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ProcessGenericHIDReport(uint8_t* DataArray); void ProcessGenericHIDReport(uint8_t* DataArray);
void CreateGenericHIDReport(uint8_t* DataArray); void CreateGenericHIDReport(uint8_t* DataArray);

@ -504,7 +504,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running joystick reporting and USB management tasks */
Scheduler_SetTaskMode(USB_Joystick_Report, TASK_STOP); 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 /** 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. * 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 */ /* Setup Joystick Report Endpoint */
Endpoint_ConfigureEndpoint(JOYSTICK_EPNUM, EP_TYPE_INTERRUPT, 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 * 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. * 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 */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -78,20 +78,12 @@
Status_USBReady = 2, /**< USB interface is connected and ready */ 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: */ /* 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); bool GetNextReport(USB_JoystickReport_Data_t* ReportData);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
* the status LEDs. * the status LEDs.
*/ */
EVENT_HANDLER(USB_Disconnect) void EVENT_USB_Disconnect(void)
{ {
/* Stop running keyboard reporting and USB management tasks */ /* Stop running keyboard reporting and USB management tasks */
Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP); 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 /** 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. * 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 */ /* Setup Keyboard Keycode Report Endpoint */
Endpoint_ConfigureEndpoint(KEYBOARD_EPNUM, EP_TYPE_INTERRUPT, 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 * 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. * 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 */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
@ -220,7 +220,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* 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 */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));

@ -55,25 +55,25 @@
/* Macros: */ /* Macros: */
/** Idle period indicating that reports should be sent only when the inputs have changed */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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. */ /** 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 Definitions: */
TASK(USB_Keyboard_Report); TASK(USB_Keyboard_Report);
@ -97,25 +97,17 @@
Status_USBEnumerating = 1, /**< USB interface is enumerating */ Status_USBEnumerating = 1, /**< USB interface is enumerating */
Status_USBReady = 2, /**< USB interface is connected and ready */ 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: */ /* 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 CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData);
void ProcessLEDReport(uint8_t LEDReport); void ProcessLEDReport(uint8_t LEDReport);
void SendNextReport(void); void SendNextReport(void);
void ReceiveNextReport(void); void ReceiveNextReport(void);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -504,7 +504,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running HID reporting and USB management tasks */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Setup Keyboard Report Endpoint */
Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, 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 * 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. * 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* ReportData;
uint8_t ReportSize; uint8_t ReportSize;

@ -95,20 +95,12 @@
int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */ int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */
} USB_MouseReport_Data_t; } 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running audio and USB management tasks */
Scheduler_SetTaskMode(USB_MIDI_Task, TASK_STOP); 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 /** 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. * 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 */ /* Setup MIDI stream endpoints */
Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK, Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK,

@ -80,17 +80,11 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_MIDI_Task); 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: */ /* 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, void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff,
const uint8_t CableID, const uint8_t Channel); const uint8_t CableID, const uint8_t Channel);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 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 */ /* Indicate USB enumerating */
UpdateStatus(Status_USBEnumerating); 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 /** 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. * the status LEDs and stops the Mass Storage management task.
*/ */
EVENT_HANDLER(USB_Disconnect) void EventHandler_USB_Disconnect(void)
{ {
/* Stop running mass storage task */ /* Stop running mass storage task */
Scheduler_SetTaskMode(USB_MassStorage, TASK_STOP); 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 /** 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. * 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 */ /* Setup Mass Storage In and Out Endpoints */
Endpoint_ConfigureEndpoint(MASS_STORAGE_IN_EPNUM, EP_TYPE_BULK, 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 * 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. * 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 */ /* Process UFI specific control requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
@ -283,7 +283,7 @@ static bool ReadInCommandBlock(void)
/* Read in command block header */ /* Read in command block header */
Endpoint_Read_Stream_LE(&CommandBlock, (sizeof(CommandBlock) - sizeof(CommandBlock.SCSICommandData)), Endpoint_Read_Stream_LE(&CommandBlock, (sizeof(CommandBlock) - sizeof(CommandBlock.SCSICommandData)),
AbortOnMassStoreReset); StreamCallback_AbortOnMassStoreReset);
/* Check if the current command is being aborted by the host */ /* Check if the current command is being aborted by the host */
if (IsMassStoreReset) if (IsMassStoreReset)
@ -305,7 +305,7 @@ static bool ReadInCommandBlock(void)
/* Read in command block command data */ /* Read in command block command data */
Endpoint_Read_Stream_LE(&CommandBlock.SCSICommandData, Endpoint_Read_Stream_LE(&CommandBlock.SCSICommandData,
CommandBlock.SCSICommandLength, CommandBlock.SCSICommandLength,
AbortOnMassStoreReset); StreamCallback_AbortOnMassStoreReset);
/* Check if the current command is being aborted by the host */ /* Check if the current command is being aborted by the host */
if (IsMassStoreReset) if (IsMassStoreReset)
@ -346,7 +346,7 @@ static void ReturnCommandStatus(void)
/* Write the CSW to the endpoint */ /* Write the CSW to the endpoint */
Endpoint_Write_Stream_LE(&CommandStatus, sizeof(CommandStatus), Endpoint_Write_Stream_LE(&CommandStatus, sizeof(CommandStatus),
AbortOnMassStoreReset); StreamCallback_AbortOnMassStoreReset);
/* Check if the current command is being aborted by the host */ /* Check if the current command is being aborted by the host */
if (IsMassStoreReset) 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 /** 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. * 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 */ /* Abort if a Mass Storage reset command was received */
if (IsMassStoreReset) if (IsMassStoreReset)

@ -130,23 +130,12 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_MassStorage); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#if defined(INCLUDE_FROM_MASSSTORAGE_C) #if defined(INCLUDE_FROM_MASSSTORAGE_C)
@ -154,4 +143,6 @@
static void ReturnCommandStatus(void); static void ReturnCommandStatus(void);
#endif #endif
uint8_t StreamCallback_AbortOnMassStoreReset(void);
#endif #endif

@ -166,12 +166,12 @@ static bool SCSI_Command_Inquiry(void)
} }
/* Write the INQUIRY data to the endpoint */ /* 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]; uint8_t PadBytes[AllocationLength - BytesTransferred];
/* Pad out remaining bytes with 0x00 */ /* 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 */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearIN(); Endpoint_ClearIN();
@ -193,12 +193,12 @@ static bool SCSI_Command_Request_Sense(void)
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData); uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
/* Send the SENSE data - this indicates to the host the status of the last command */ /* 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]; uint8_t PadBytes[AllocationLength - BytesTransferred];
/* Pad out remaining bytes with 0x00 */ /* 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 */ /* Finalize the stream transfer to send the last packet */
Endpoint_ClearIN(); Endpoint_ClearIN();

@ -508,7 +508,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running mouse reporting and USB management tasks */
Scheduler_SetTaskMode(USB_Mouse_Report, TASK_STOP); 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 /** 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. * 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 */ /* Setup Mouse Report Endpoint */
Endpoint_ConfigureEndpoint(MOUSE_EPNUM, EP_TYPE_INTERRUPT, 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 * 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. * 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 */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)
@ -195,7 +195,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
Endpoint_ClearSETUP(); Endpoint_ClearSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */ /* 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 */ /* Acknowledge status stage */
while (!(Endpoint_IsINReady())); while (!(Endpoint_IsINReady()));

@ -98,20 +98,12 @@
Status_USBReady = 2, /**< USB interface is connected and ready */ 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: */ /* 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 CreateMouseReport(USB_MouseReport_Data_t* ReportData);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -504,7 +504,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running TCP/IP and USB management tasks */
Scheduler_SetTaskMode(RNDIS_Task, TASK_STOP); 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 /** 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. * 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 */ /* Setup CDC Notification, Rx and Tx Endpoints */
Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, 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, * 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. * 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 */ /* Process RNDIS class commands */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -60,19 +60,6 @@
/* Macros: */ /* Macros: */
/** Notification value to indicate that a frame is ready to be read by the host. */ /** Notification value to indicate that a frame is ready to be read by the host. */
#define NOTIF_RESPONSE_AVAILABLE 0x01 #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 Defines: */
/** Type define for a RNDIS notification message, for transmission to the RNDIS host via the notification /** Type define for a RNDIS notification message, for transmission to the RNDIS host via the notification
@ -102,6 +89,11 @@
TASK(Ethernet_Task); TASK(Ethernet_Task);
/* Function Prototypes: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -518,7 +518,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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 */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); 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 /** 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. * 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 */ /* Stop running CDC and USB management tasks */
Scheduler_SetTaskMode(CDC_Task, TASK_STOP); 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 /** 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. * 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 */ /* Setup CDC Notification, Rx and Tx Endpoints */
Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, 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, * 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. * 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; uint8_t* LineCodingData = (uint8_t*)&LineCoding;

@ -112,19 +112,6 @@
*/ */
#define CONTROL_LINE_IN_OVERRUNERROR (1 << 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 Defines: */
/** Type define for the virtual serial port line encoding settings, for storing the current USART configuration /** 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. * as set by the host via a class specific request.
@ -186,6 +173,11 @@
TASK(CDC_Task); TASK(CDC_Task);
/* Function Prototypes: */ /* 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 ReconfigureUSART(void);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -506,7 +506,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop keyboard and USB management task */ /* Stop keyboard and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start CDC Host task */
Scheduler_SetTaskMode(USB_CDC_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -76,14 +76,13 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_CDC_Host); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
#endif #endif

@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the CDC control interface from the configuration descriptor */ /* Get the CDC control interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; return NoCDCInterfaceFound;
@ -82,14 +82,14 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */ /* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, 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 */ /* 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)) if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE))
{ {
/* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */ /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; 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) */ /* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoCDCInterfaceFound; return NoCDCInterfaceFound;
@ -119,7 +119,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Fetch the next bulk or interrupt endpoint from the current CDC interface */ /* Fetch the next bulk or interrupt endpoint from the current CDC interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -186,7 +186,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -210,7 +210,7 @@ DESCRIPTOR_COMPARATOR(NextCDCControlInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -236,7 +236,7 @@ DESCRIPTOR_COMPARATOR(NextCDCDataInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {

@ -75,12 +75,11 @@
NoEndpointFound = 5, /**< Compatible CDC endpoints were not found in the device's CDC interface */ 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: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor);
uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor);
uint8_t DComp_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -506,7 +506,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -72,7 +72,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the HID interface from the configuration descriptor */ /* Get the HID interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Get the next HID interface's data endpoint descriptor */ /* Get the next HID interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, 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 /* 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 */ * 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 * \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 */ /* Determine if the current descriptor is an interface descriptor */
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
@ -155,7 +155,7 @@ DESCRIPTOR_COMPARATOR(NextHIDInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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 */ /* Determine the type of the current descriptor */
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)

@ -60,11 +60,10 @@
NoEndpointFound = 5, /**< A compatible HID IN endpoint 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(NextHIDInterface);
DESCRIPTOR_COMPARATOR(NextInterfaceHIDDataEndpoint);
/* Function Prototypes: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextHIDInterface(void* CurrentDescriptor);
uint8_t DComp_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop HID and USB management task */ /* Stop HID and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start HID Host task */
Scheduler_SetTaskMode(USB_HID_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -82,15 +82,14 @@
Status_EnumerationError = 3, /**< Software error while enumerating the attached USB device */ Status_EnumerationError = 3, /**< Software error while enumerating the attached USB device */
Status_HardwareError = 4, /**< Hardware 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ReadNextReport(void); void ReadNextReport(void);
void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t ReportType, uint16_t ReportLength); void WriteNextReport(uint8_t* ReportOUTData, uint8_t ReportIndex, uint8_t ReportType, uint16_t ReportLength);

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface from the configuration descriptor */ /* Get the keyboard interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface's data endpoint descriptor */ /* Get the keyboard interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -105,7 +105,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -129,7 +129,7 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {

@ -62,12 +62,11 @@
NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's 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 */ 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: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor);
uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop Keyboard and USB management task */ /* Stop Keyboard and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start Keyboard Host task */
Scheduler_SetTaskMode(USB_Keyboard_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -83,14 +83,13 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_Keyboard_Host); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ReadNextReport(void); void ReadNextReport(void);

@ -506,7 +506,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface from the configuration descriptor */ /* Get the keyboard interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface's HID descriptor */ /* Get the keyboard interface's HID descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHID) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDDescriptorFound; return NoHIDDescriptorFound;
@ -89,7 +89,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the keyboard interface's data endpoint descriptor */ /* Get the keyboard interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -116,7 +116,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -140,7 +140,7 @@ DESCRIPTOR_COMPARATOR(NextKeyboardInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {
@ -163,7 +163,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceKeyboardDataEndpoint)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;

@ -68,13 +68,12 @@
NoHIDDescriptorFound = 5, /**< A compatible HID descriptor was not found in the device's HID interface */ 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 */ 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: */ /* 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 #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop keyboard and USB management task */ /* Stop keyboard and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start Keyboard Host task */
Scheduler_SetTaskMode(USB_Keyboard_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -67,14 +67,13 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_Keyboard_Host); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ProcessKeyboardReport(uint8_t* KeyboardReport); void ProcessKeyboardReport(uint8_t* KeyboardReport);

@ -507,7 +507,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mass storage interface from the configuration descriptor */ /* Get the mass storage interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoInterfaceFound; return NoInterfaceFound;
@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Fetch the next bulk endpoint from the current mass storage interface */ /* Fetch the next bulk endpoint from the current mass storage interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -127,7 +127,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -152,7 +152,7 @@ DESCRIPTOR_COMPARATOR(NextMassStorageInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {

@ -65,12 +65,11 @@
NoInterfaceFound = 4, /**< A compatible MSD interface was not found in the device's Configuration Descriptor */ 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 */ 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: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor);
uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop USB management and Mass Storage tasks */ /* Stop USB management and Mass Storage tasks */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Once device is fully enumerated, start the Mass Storage Host task */
Scheduler_SetTaskMode(USB_MassStore_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -134,7 +134,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -70,15 +70,14 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_MassStore_Host); 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: */ /* 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 ShowDiskReadError(char* CommandString, bool FailedAtSCSILayer, uint8_t ErrorCode);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -508,7 +508,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface from the configuration descriptor */ /* Get the mouse interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface's data endpoint descriptor */ /* Get the mouse interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -105,7 +105,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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 */ /* Determine if the current descriptor is an interface descriptor */
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
@ -132,7 +132,7 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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 */ /* Determine the type of the current descriptor */
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)

@ -61,13 +61,12 @@
InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's 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 */ 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: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextMouseInterface(void* CurrentDescriptor);
uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop mouse and USB management task */ /* Stop mouse and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start Mouse Host task */
Scheduler_SetTaskMode(USB_Mouse_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -83,14 +83,13 @@
Status_HardwareError = 4, /**< Hardware 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ReadNextReport(void); void ReadNextReport(void);

@ -505,7 +505,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -70,7 +70,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface from the configuration descriptor */ /* Get the mouse interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDInterfaceFound; return NoHIDInterfaceFound;
@ -78,7 +78,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface's HID descriptor */ /* Get the mouse interface's HID descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextHID) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoHIDDescriptorFound; return NoHIDDescriptorFound;
@ -89,7 +89,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the mouse interface's data endpoint descriptor */ /* Get the mouse interface's data endpoint descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -116,7 +116,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -140,7 +140,7 @@ DESCRIPTOR_COMPARATOR(NextMouseInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {
@ -163,7 +163,7 @@ DESCRIPTOR_COMPARATOR(NextInterfaceMouseDataEndpoint)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
return DESCRIPTOR_SEARCH_Found; return DESCRIPTOR_SEARCH_Found;

@ -69,13 +69,12 @@
NoHIDDescriptorFound = 5, /**< A compatible HID descriptor was not found in the device's HID interface */ 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 */ 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: */ /* 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 #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop mouse and USB management task */ /* Stop mouse and USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Start Mouse Host task */
Scheduler_SetTaskMode(USB_Mouse_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -129,7 +129,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -66,15 +66,14 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_Mouse_Host); 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: */ /* 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 UpdateStatus(uint8_t CurrentStatus);
void ProcessMouseReport(uint8_t* MouseReport); void ProcessMouseReport(uint8_t* MouseReport);

@ -507,7 +507,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -71,7 +71,7 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Get the Still Image interface from the configuration descriptor */ /* Get the Still Image interface from the configuration descriptor */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoInterfaceFound; return NoInterfaceFound;
@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
{ {
/* Fetch the next endpoint from the current Still Image interface */ /* Fetch the next endpoint from the current Still Image interface */
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) DComp_NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
{ {
/* Descriptor not found, error out */ /* Descriptor not found, error out */
return NoEndpointFound; return NoEndpointFound;
@ -148,7 +148,7 @@ uint8_t ProcessConfigurationDescriptor(void)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
{ {
@ -173,7 +173,7 @@ DESCRIPTOR_COMPARATOR(NextStillImageInterface)
* *
* \return A value from the DSEARCH_Return_ErrorCodes_t enum * \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) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
{ {

@ -66,11 +66,10 @@
NoEndpointFound = 5, /**< The correct SI endpoint descriptors were not found in the device's SI interface */ 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: */ /* Function Prototypes: */
uint8_t ProcessConfigurationDescriptor(void); uint8_t ProcessConfigurationDescriptor(void);
uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor);
uint8_t DComp_NextSImageInterfaceDataEndpoint(void* CurrentDescriptor);
#endif #endif

@ -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 /** 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. * 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")); puts_P(PSTR("Device Attached.\r\n"));
UpdateStatus(Status_USBEnumerating); 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 /** 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. * stops the library USB task management process.
*/ */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
/* Stop USB management and Still Image tasks */ /* Stop USB management and Still Image tasks */
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 /** 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. * 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 */ /* Once device is fully enumerated, start the Still Image Host task */
Scheduler_SetTaskMode(USB_SImage_Host, TASK_RUN); 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 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(); USB_ShutDown();
@ -130,7 +130,7 @@ EVENT_HANDLER(USB_HostError)
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
* enumerating an attached USB device. * 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode);

@ -68,14 +68,13 @@
/* Task Definitions: */ /* Task Definitions: */
TASK(USB_SImage_Host); 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: */ /* 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 UnicodeToASCII(uint8_t* restrict UnicodeString, char* restrict Buffer);
void ShowCommandError(uint8_t ErrorCode, bool ResponseCodeError); void ShowCommandError(uint8_t ErrorCode, bool ResponseCodeError);
void UpdateStatus(uint8_t CurrentStatus); void UpdateStatus(uint8_t CurrentStatus);

@ -506,7 +506,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -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 for the USB_VBUSChange event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_VBUSChange) void EVENT_USB_VBUSChange(void)
{ {
puts_P(PSTR(EVENT_PREFIX "VBUS Change\r\n")); puts_P(PSTR(EVENT_PREFIX "VBUS Change\r\n"));
} }
/** Event handler for the USB_VBUSConnect event. When fired, the event is logged to the USART. */ /** Event handler for the USB_VBUSConnect event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_VBUSConnect) void EVENT_USB_VBUSConnect(void)
{ {
puts_P(PSTR(EVENT_PREFIX "VBUS +\r\n")); puts_P(PSTR(EVENT_PREFIX "VBUS +\r\n"));
} }
/** Event handler for the USB_VBUSDisconnect event. When fired, the event is logged to the USART. */ /** Event handler for the USB_VBUSDisconnect event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_VBUSDisconnect) void EVENT_USB_VBUSDisconnect(void)
{ {
puts_P(PSTR(EVENT_PREFIX "VBUS -\r\n")); puts_P(PSTR(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 * Event handler for the USB_Connect event. When fired, the event is logged to the USART and the
* USB task started. * USB task started.
*/ */
EVENT_HANDLER(USB_Connect) void EVENT_USB_Connect(void)
{ {
puts_P(PSTR(EVENT_PREFIX "USB +\r\n")); puts_P(PSTR(EVENT_PREFIX "USB +\r\n"));
LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED3 | LEDS_LED4); 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 * Event handler for the USB_Disconnect event. When fired, the event is logged to the USART and the
* USB task stopped. * USB task stopped.
*/ */
EVENT_HANDLER(USB_Disconnect) void EVENT_USB_Disconnect(void)
{ {
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); 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 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")); puts_P(PSTR(EVENT_PREFIX ESC_BG_YELLOW "USB Sleep\r\n"));
LEDs_SetAllLEDs(LEDS_ALL_LEDS); LEDs_SetAllLEDs(LEDS_ALL_LEDS);
} }
/** Event handler for the USB_WakeUp event. When fired, the event is logged to the USART. */ /** 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")); puts_P(PSTR(EVENT_PREFIX ESC_BG_GREEN "USB Wakeup\r\n"));
LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED4); LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED4);
} }
/** Event handler for the USB_Reset event. When fired, the event is logged to the USART. */ /** Event handler for the USB_Reset event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_Reset) void EVENT_USB_Reset(void)
{ {
puts_P(PSTR(EVENT_PREFIX "USB Reset\r\n")); puts_P(PSTR(EVENT_PREFIX "USB Reset\r\n"));
} }
/** Event handler for the USB_UIDChange event. When fired, the event is logged to the USART. */ /** 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; 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 * Event handler for the USB_PowerOnFail event. When fired, the event is logged to the USART and the program
* execution aborted. * execution aborted.
*/ */
EVENT_HANDLER(USB_InitFailure) void EVENT_USB_InitFailure(const uint8_t ErrorCode)
{ {
char* ModeStrPtr; 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 * Event handler for the USB_HostError event. When fired, the event is logged to the USART and the program
* execution aborted. * 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")); puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Host Mode Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); 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 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")); puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); 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 * Event handler for the USB_DeviceError event. When fired, the event is logged to the USART and the program
* execution aborted. * 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")); puts_P(PSTR(EVENT_PREFIX ESC_BG_RED "Device Mode Error\r\n"));
printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); 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 for the USB_UnhandledControlPacket event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_UnhandledControlPacket) void EVENT_USB_UnhandledControlPacket(void)
{ {
puts_P(PSTR(EVENT_PREFIX "Ctrl Request\r\n")); puts_P(PSTR(EVENT_PREFIX "Ctrl Request\r\n"));
printf_P(PSTR(" -- Req Data %d\r\n"), USB_ControlRequest.bRequest); 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 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")); 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 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")); 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 for the USB_DeviceUnattached event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_DeviceUnattached) void EVENT_USB_DeviceUnattached(void)
{ {
puts_P(PSTR(EVENT_PREFIX ESC_BG_YELLOW "Device -\r\n")); puts_P(PSTR(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 for the USB_DeviceEnumerationComplete event. When fired, the event is logged to the USART. */
EVENT_HANDLER(USB_DeviceEnumerationComplete) void EVENT_USB_DeviceEnumerationComplete(void)
{ {
puts_P(PSTR(EVENT_PREFIX "Device Enumeration Complete\r\n")); puts_P(PSTR(EVENT_PREFIX "Device Enumeration Complete\r\n"));
} }

@ -46,58 +46,6 @@
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes #include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // 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: */ /* Macros: */
/** Prefix sent through the USART when an even fires before the actual event message. */ /** Prefix sent through the USART when an even fires before the actual event message. */
#define EVENT_PREFIX ESC_INVERSE_ON "EVENT:" ESC_INVERSE_OFF " " #define EVENT_PREFIX ESC_INVERSE_ON "EVENT:" ESC_INVERSE_OFF " "
@ -107,4 +55,23 @@
static void Abort_Program(void) ATTR_NO_RETURN; static void Abort_Program(void) ATTR_NO_RETURN;
#endif #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 #endif

@ -509,7 +509,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

@ -20,6 +20,10 @@
* - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype
* inside the library that is able to hold their defined value to save space * inside the library that is able to hold their defined value to save space
* - Removed DESCRIPTOR_ADDRESS() macro as it was largely supurflous and only served to obfuscate code * - Removed DESCRIPTOR_ADDRESS() macro as it was largely supurflous and only served to obfuscate code
* - 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
* *
* *
* \section Sec_ChangeLog090510 Version 090510 * \section Sec_ChangeLog090510 Version 090510

@ -114,7 +114,7 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,
USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type); USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);
} }
uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine) uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine)
{ {
uint8_t ErrorCode; uint8_t ErrorCode;

@ -110,63 +110,60 @@
#else #else
#define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bLength #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bLength
#endif #endif
/** Creates a prototype for or begins a descriptor comparator routine. Descriptor comparator routines are /* Type Defines: */
* small search routines which are passed a pointer to the current sub descriptor in the configuration /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
* descriptor, and which analyse the sub descriptor to determine whether or not it matches the routine's * of type void, returning a uint8_t value).
* search parameters. Comparator routines provide a powerful way to scan through the config descriptor
* for certain descriptors matching unique criteria.
* *
* Comparator routines are passed in a single pointer named CurrentDescriptor, and should return a value * \see \ref USB_GetNextDescriptorComp function for more details
* of a member of the \ref DSearch_Return_ErrorCodes_t enum.
*/ */
#define DESCRIPTOR_COMPARATOR(name) uint8_t DCOMP_##name (void* const CurrentDescriptor) typedef uint8_t (* const ConfigComparatorPtr_t)(void* const);
/* Pseudo-Function Macros: */ /* Function Prototypes: */
#if defined(__DOXYGEN__) /** Searches for the next descriptor in the given configuration descriptor using a premade comparator
/** Searches for the next descriptor in the given configuration descriptor using a premade comparator * function. The routine updates the position and remaining configuration descriptor bytes values
* function. The routine updates the position and remaining configuration descriptor bytes values * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back
* automatically. If a comparator routine fails a search, the descriptor pointer is retreated back * so that the next descriptor search invocation will start from the descriptor which first caused the
* so that the next descriptor search invocation will start from the descriptor which first caused the * original search to fail. This behaviour allows for one comparator to be used immediately after another
* original search to fail. This behaviour allows for one comparator to be used immediately after another * has failed, starting the second search from the descriptor which failed the first.
* has failed, starting the second search from the descriptor which failed the first. *
* * Comparator functions should be standard functions which accept a pointer to the header of the current
* \note This function is available in USB Host mode only. * descriptor inside the configuration descriptor which is being compared, and should return a value from
* * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value.
* \param BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor *
* \param CurrConfigLoc Pointer to the current position in the configuration descriptor * \note This function is available in USB Host mode only.
* \param ComparatorRoutine Name of the comparator search function to use on the configuration descriptor *
* * \param BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor
* \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum * \param CurrConfigLoc Pointer to the current position in the configuration descriptor
* * \param ComparatorRoutine Name of the comparator search function to use on the configuration descriptor
* Usage Example: *
* \code * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum
* DESCRIPTOR_COMPARATOR(EndpointSearcher); // Comparator Prototype *
* * Usage Example:
* DESCRIPTOR_COMPARATOR(EndpointSearcher) * \code
* { * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype
* if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) *
* return DESCRIPTOR_SEARCH_Found; * uint8_t EndpointSearcher(void* CurrentDescriptor)
* else * {
* return DESCRIPTOR_SEARCH_NotFound; * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
* } * return DESCRIPTOR_SEARCH_Found;
* * else
* //... * return DESCRIPTOR_SEARCH_NotFound;
* // After retrieving configuration descriptor: * }
* if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) == *
* Descriptor_Search_Comp_Found) * //...
* { * // After retrieving configuration descriptor:
* // Do something with the endpoint descriptor * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==
* } * Descriptor_Search_Comp_Found)
* \endcode * {
*/ * // Do something with the endpoint descriptor
uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ComparatorPtr_t ComparatorRoutine); * }
#else * \endcode
#define USB_GetNextDescriptorComp(DSize, DPos, DSearch) USB_GetNextDescriptorComp_Prv(DSize, DPos, DCOMP_##DSearch) */
#endif uint8_t USB_GetNextDescriptorComp(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
/* Enums: */ /* Enums: */
/** Enum for return values of a descriptor comparator made with \ref DESCRIPTOR_COMPARATOR. */ /** Enum for return values of a descriptor comparator function. */
enum DSearch_Return_ErrorCodes_t enum DSearch_Return_ErrorCodes_t
{ {
DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */ DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */
@ -264,20 +261,6 @@
*BytesRem -= CurrDescriptorSize; *BytesRem -= CurrDescriptorSize;
} }
/* Type Defines: */
/** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array
* of type void, returning a uint8_t value).
*
* \see \ref USB_GetNextDescriptorComp function for more details
*/
typedef uint8_t (* const ConfigComparatorPtr_t)(void* const);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Function Prototypes: */
uint8_t USB_GetNextDescriptorComp_Prv(uint16_t* BytesRem, uint8_t** CurrConfigLoc, ConfigComparatorPtr_t ComparatorRoutine);
#endif
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)
} }

@ -36,9 +36,9 @@
* multiple places in the user or library code, which may or may not be inside an ISR, thus each handler * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler
* should be written to be as small and fast as possible to prevent possible problems. * should be written to be as small and fast as possible to prevent possible problems.
* *
* Events can be hooked by the user application using the \ref EVENT_HANDLER() and \ref HANDLES_EVENT() macros. If an * Events can be hooked by the user application by declaring a handler function with the same name and parameters
* event with no associated handler is fired within the library, it by default fires an internal empty stub * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an
* function. This is achieved through the use of the GCC compiler's "alias" attribute. * internal empty stub function. This is achieved through the use of the GCC compiler's "alias" attribute.
* *
* Each event must only have one associated event handler, but can be raised by multiple sources. * Each event must only have one associated event handler, but can be raised by multiple sources.
* *
@ -59,96 +59,15 @@
extern "C" { extern "C" {
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Raises a given event name, with the specified parameters. For events with no parameters the
* only argument to the macro is the event name, events with parameters list the parameter values
* after the name as a comma separated list.
*
* When a given event is fired, its corresponding event handler code is executed.
*
* Usage Examples:
* \code
* // Raise the USB_VBUSChange event, which takes no parameters
* RAISE_EVENT(USB_VBUSChange);
*
* // Raise the USB_UnhandledControlPacket event which takes two parameters
* RAISE_EVENT(USB_UnhandledControlPacket, 0, 1);
* \endcode
*
* \see RAISES_EVENT()
*/
#define RAISE_EVENT(e, ...) Event_ ## e (__VA_ARGS__)
/** Indicates that a given module can raise a given event. This is the equivalent of putting the
* event function's prototype into the module, but in a cleaner way. Each event which may be
* fired via the \ref RAISE_EVENT macro in the module should have an accompanying \ref RAISES_EVENT
* prototype in the module's header file.
*
* Usage Examples:
* \code
* // Module can raise the USB_VBUSChange event
* RAISES_EVENT(USB_VBUSChange);
*
* // ...
* // Inside a block of code in a function of the module, raise the USB_VBUSChange event
* RAISE_EVENT(USB_VBUSChange);
* \endcode
*
* \see RAISE_EVENT()
*/
#define RAISES_EVENT(e) HANDLES_EVENT(e)
/** Defines an event handler for the given event. Event handlers should be short in length, as they
* may be raised from inside an ISR. The user application can react to each event as it sees fit,
* such as logging the event, indicating the change to the user or performing some other action.
*
* Only one event handler may be defined in any user project for each individual event. Events may
* or may not have parameters - for each event, refer to its documentation elsewhere in this module
* to determine the presence and purpose of any event parameters.
*
* Usage Example:
* \code
* // Create an event handler for the USB_VBUSChange event
* EVENT_HANDLER(USB_VBUSChange)
* {
* // Code to execute when the VBUS level changes
* }
* \endcode
*
* \see HANDLES_EVENT()
*/
#define EVENT_HANDLER(e) void Event_ ## e e ## _P
/** Indicates that a given module handles an event. This is the equivalent of putting the
* event function's prototype into the module, but in a cleaner way. Each event which may be
* handled via the \ref EVENT_HANDLER macro in the module should have an accompanying \ref HANDLES_EVENT
* prototype in the module's header file.
*
* Usage Examples:
* \code
* // Module handles the USB_VBUSChange event
* HANDLES_EVENT(USB_VBUSChange);
*
* // Create the USB_VBUSChange event handler
* EVENT_HANDLER(USB_VBUSChange)
* {
* // Event handler code here
* }
* \endcode
*
* \see EVENT_HANDLER()
*/
#define HANDLES_EVENT(e) EVENT_HANDLER(e)
/* Pseudo-Functions for Doxygen: */ /* Pseudo-Functions for Doxygen: */
#if defined(__DOXYGEN__) #if !defined(INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)
/** Event for VBUS level change. This event fires when the VBUS line of the USB AVR changes from /** Event for VBUS level change. This event fires when the VBUS line of the USB AVR changes from
* high to low or vice-versa. * high to low or vice-versa.
* *
* \note This event is only available on USB AVR models which support VBUS notification interrupts. * \note This event is only available on USB AVR models which support VBUS notification interrupts.
*/ */
void USB_VBUSChange(void); void EVENT_USB_VBUSChange(void);
/** Event for VBUS attachment. This event fires when the VBUS line of the USB AVR changes from /** Event for VBUS attachment. This event fires when the VBUS line of the USB AVR changes from
* low to high, signalling the attachment of the USB device to a host, before the enumeration * low to high, signalling the attachment of the USB device to a host, before the enumeration
@ -156,7 +75,7 @@
* *
* \note This event is only available on USB AVR models which support VBUS notification interrupts. * \note This event is only available on USB AVR models which support VBUS notification interrupts.
*/ */
void USB_VBUSConnect(void); void EVENT_USB_VBUSConnect(void);
/** Event for VBUS detachment. This event fires when the VBUS line of the USB AVR changes from /** Event for VBUS detachment. This event fires when the VBUS line of the USB AVR changes from
* high to low, signalling the USB device has been removed from a host whether it has been enumerated * high to low, signalling the USB device has been removed from a host whether it has been enumerated
@ -164,7 +83,7 @@
* *
* \note This event is only available on USB AVR models which support VBUS notification interrupts. * \note This event is only available on USB AVR models which support VBUS notification interrupts.
*/ */
void USB_VBUSDisconnect(void); void EVENT_USB_VBUSDisconnect(void);
/** Event for USB device connection. This event fires when the AVR is in USB host mode and a device /** Event for USB device connection. This event fires when the AVR is in USB host mode and a device
* has been attached (but not yet fully enumerated), or when in device mode and the device is connected * has been attached (but not yet fully enumerated), or when in device mode and the device is connected
@ -178,11 +97,11 @@
* which is not always accurate (host may suspend the bus while still connected). If the actual connection state * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by \ref RAISE_EVENT(), and the \ref USB_IsConnected global changed manually. * and disconnection events may be manually fired, and the \ref USB_IsConnected global changed manually.
* *
* \see USBTask.h for more information on the USB management task and reducing CPU usage. * \see USBTask.h for more information on the USB management task and reducing CPU usage.
*/ */
void USB_Connect(void); void EVENT_USB_Connect(void);
/** Event for USB device disconnection. This event fires when the AVR is in USB host mode and an /** Event for USB device disconnection. This event fires when the AVR is in USB host mode and an
* attached and enumerated device has been disconnected, or when in device mode and the device is * attached and enumerated device has been disconnected, or when in device mode and the device is
@ -196,11 +115,11 @@
* which is not always accurate (host may suspend the bus while still connected). If the actual connection state * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by \ref RAISE_EVENT(), and the \ref USB_IsConnected global changed manually. * and disconnection events may be manually fired, and the \ref USB_IsConnected global changed manually.
* *
* \see USBTask.h for more information on the USB management task and reducing CPU usage. * \see USBTask.h for more information on the USB management task and reducing CPU usage.
*/ */
void USB_Disconnect(void); void EVENT_USB_Disconnect(void);
/** Event for USB initialization failure. This event fires when the USB interface fails to /** Event for USB initialization failure. This event fires when the USB interface fails to
* initialize correctly due to a hardware or software fault. * initialize correctly due to a hardware or software fault.
@ -208,9 +127,8 @@
* \note This event only exists on USB AVR models which support dual role modes. * \note This event only exists on USB AVR models which support dual role modes.
* *
* \param ErrorCode Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t * \param ErrorCode Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t
* located in LowLevel.h.
*/ */
void USB_InitFailure(const uint8_t ErrorCode); void EVENT_USB_InitFailure(const uint8_t ErrorCode);
/** Event for USB mode pin level change. This event fires when the USB interface is set to dual role /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role
* mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires
@ -221,24 +139,23 @@
* \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied * \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied
* to the compiler (see \ref Group_USBManagement documentation). * to the compiler (see \ref Group_USBManagement documentation).
*/ */
void USB_UIDChange(void); void EVENT_USB_UIDChange(void);
/** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB
* interface is in host mode. * interface is in host mode.
* *
* \param ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t * \param ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t
* located in Host.h.
* *
* \note This event only exists on USB AVR models which supports host mode. * \note This event only exists on USB AVR models which supports host mode.
* *
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
*/ */
void USB_HostError(const uint8_t ErrorCode); void EVENT_USB_HostError(const uint8_t ErrorCode);
/** Event for USB device attachment. This event fires when a the USB interface is in host mode, and /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and
* a USB device has been connected to the USB interface. This is interrupt driven, thus fires before * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before
* the standard \ref USB_Connect event and so can be used to programmatically start the USB management * the standard \ref EVENT_USB_Connect event and so can be used to programmatically start the USB management
* task to reduce CPU consumption. * task to reduce CPU consumption.
* *
* \note This event only exists on USB AVR models which supports host mode. * \note This event only exists on USB AVR models which supports host mode.
@ -248,7 +165,7 @@
* *
* \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage. * \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage.
*/ */
void USB_DeviceAttached(void); void EVENT_USB_DeviceAttached(void);
/** Event for USB device removal. This event fires when a the USB interface is in host mode, and /** Event for USB device removal. This event fires when a the USB interface is in host mode, and
* a USB device has been removed the USB interface whether or not it has been enumerated. This * a USB device has been removed the USB interface whether or not it has been enumerated. This
@ -261,13 +178,13 @@
* *
* \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage. * \see \ref TASK(USB_USBTask) for more information on the USB management task and reducing CPU usage.
*/ */
void USB_DeviceUnattached(void); void EVENT_USB_DeviceUnattached(void);
/** Event for USB device enumeration failure. This event fires when a the USB interface is /** Event for USB device enumeration failure. This event fires when a the USB interface is
* in host mode, and an attached USB device has failed to enumerate completely. * in host mode, and an attached USB device has failed to enumerate completely.
* *
* \param ErrorCode Error code indicating the failure reason, a value in * \param ErrorCode Error code indicating the failure reason, a value in
* \ref USB_Host_EnumerationErrorCodes_t located in Host.h. * \ref USB_Host_EnumerationErrorCodes_t
* *
* \param SubErrorCode Sub error code indicating the reason for failure - for example, if the * \param SubErrorCode Sub error code indicating the reason for failure - for example, if the
* ErrorCode parameter indicates a control error, this will give the error * ErrorCode parameter indicates a control error, this will give the error
@ -278,14 +195,14 @@
* \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
*/ */
void USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);
/** Event for USB device enumeration completion. This event fires when a the USB interface is /** Event for USB device enumeration completion. This event fires when a the USB interface is
* in host mode and an attached USB device has been completely enumerated and is ready to be * in host mode and an attached USB device has been completely enumerated and is ready to be
* controlled by the user application, or when the library is in device mode, and the Host * controlled by the user application, or when the library is in device mode, and the Host
* has finished enumerating the device. * has finished enumerating the device.
*/ */
void USB_DeviceEnumerationComplete(void); void EVENT_USB_DeviceEnumerationComplete(void);
/** Event for unhandled control requests. This event fires when a the USB host issues a control /** Event for unhandled control requests. This event fires when a the USB host issues a control
* request to the control endpoint (address 0) that the library does not handle. This may either * request to the control endpoint (address 0) that the library does not handle. This may either
@ -301,7 +218,7 @@
* request SETUP parameters into the \ref USB_ControlRequest structure which should then be used * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used
* by the application to determine how to handle the issued request. * by the application to determine how to handle the issued request.
*/ */
void USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
/** Event for USB configuration number changed. This event fires when a the USB host changes the /** Event for USB configuration number changed. This event fires when a the USB host changes the
* selected configuration number while in device mode. This event should be hooked in device * selected configuration number while in device mode. This event should be hooked in device
@ -312,7 +229,7 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
*/ */
void USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
/** Event for USB suspend. This event fires when a the USB host suspends the device by halting its /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its
* transmission of Start Of Frame pulses to the device. This is generally hooked in order to move * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move
@ -321,9 +238,9 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
* *
* \see \ref USB_WakeUp() event for accompanying Wake Up event. * \see \ref EVENT_USB_WakeUp() event for accompanying Wake Up event.
*/ */
void USB_Suspend(void); void EVENT_USB_Suspend(void);
/** Event for USB wake up. This event fires when a the USB interface is suspended while in device /** Event for USB wake up. This event fires when a the USB interface is suspended while in device
* mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally
@ -333,9 +250,9 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
* *
* \see \ref USB_Suspend() event for accompanying Suspend event. * \see \ref EVENT_USB_Suspend() event for accompanying Suspend event.
*/ */
void USB_WakeUp(void); void EVENT_USB_WakeUp(void);
/** Event for USB interface reset. This event fires when a the USB interface is in device mode, and /** Event for USB interface reset. This event fires when a the USB interface is in device mode, and
* a the USB host requests that the device reset its interface. This is generally hooked so that * a the USB host requests that the device reset its interface. This is generally hooked so that
@ -346,90 +263,55 @@
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
*/ */
void USB_Reset(void); void EVENT_USB_Reset(void);
/** Event for USB device mode error. This event fires when the USB interface is in device mode, /** Event for USB device mode error. This event fires when the USB interface is in device mode,
* and an error occurs which prevents it from operating normally. * and an error occurs which prevents it from operating normally.
* *
* \param ErrorCode Error code indicating the source of the error. One of the values in the * \param ErrorCode Error code indicating the source of the error, a value in
* \ref USB_Device_ErrorCodes_t enum located in Device.h. * \ref USB_Device_ErrorCodes_t
* *
* \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see
* \ref Group_USBManagement documentation). * \ref Group_USBManagement documentation).
*/ */
void USB_DeviceError(const uint8_t ErrorCode); void EVENT_USB_DeviceError(const uint8_t ErrorCode);
#endif #endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */
#define ALIAS_STUB(e) EVENT_HANDLER(e) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub)
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
#define USB_VBUSChange_P (void)
#define USB_VBUSConnect_P (void)
#define USB_VBUSDisconnect_P (void)
#endif
#define USB_Connect_P (void)
#define USB_Disconnect_P (void)
#define USB_DeviceEnumerationComplete_P (void)
#if defined(USB_CAN_BE_BOTH)
#define USB_InitFailure_P (const uint8_t ErrorCode)
#define USB_UIDChange_P (void)
#endif
#if defined(USB_CAN_BE_HOST)
#define USB_HostError_P (const uint8_t ErrorCode)
#define USB_DeviceAttached_P (void)
#define USB_DeviceUnattached_P (void)
#define USB_DeviceEnumerationFailed_P (const uint8_t ErrorCode, const uint8_t SubErrorCode)
#endif
#if defined(USB_CAN_BE_DEVICE)
#define USB_UnhandledControlPacket_P (void)
#define USB_ConfigurationChanged_P (void)
#define USB_Suspend_P (void)
#define USB_WakeUp_P (void)
#define USB_Reset_P (void)
#define USB_DeviceError_P (const uint8_t ErrorCode)
#endif
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(INCLUDE_FROM_EVENTS_C) #if defined(INCLUDE_FROM_EVENTS_C)
void USB_Event_Stub(void) ATTR_CONST; void USB_Event_Stub(void) ATTR_CONST;
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
ALIAS_STUB(USB_VBUSChange); void EVENT_USB_VBUSChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_VBUSConnect); void EVENT_USB_VBUSConnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_VBUSDisconnect); void EVENT_USB_VBUSDisconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif #endif
ALIAS_STUB(USB_Connect); void EVENT_USB_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_Disconnect); void EVENT_USB_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_DeviceEnumerationComplete); void EVENT_USB_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
ALIAS_STUB(USB_InitFailure); void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_UIDChange); void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif #endif
#if defined(USB_CAN_BE_HOST) #if defined(USB_CAN_BE_HOST)
ALIAS_STUB(USB_HostError); void EVENT_USB_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_DeviceAttached); void EVENT_USB_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_DeviceUnattached); void EVENT_USB_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_DeviceEnumerationFailed); void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode)
ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif #endif
#if defined(USB_CAN_BE_DEVICE) void EVENT_USB_UnhandledControlPacket(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_UnhandledControlPacket); void EVENT_USB_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_ConfigurationChanged); void EVENT_USB_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_Suspend); void EVENT_USB_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_WakeUp); void EVENT_USB_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_Reset); void EVENT_USB_DeviceError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
ALIAS_STUB(USB_DeviceError);
#endif
#endif #endif
#endif #endif

@ -36,7 +36,7 @@
uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress) uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
{ {
RAISE_EVENT(USB_DeviceError, DEVICE_ERROR_GetDescriptorNotHooked); EVENT_USB_DeviceError(DEVICE_ERROR_GetDescriptorNotHooked);
return 0; return 0;
}; };

@ -175,16 +175,6 @@
*/ */
#define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4) #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
/* Events: */
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
/** This module raises the Device Error event while in device mode, if the \ref USB_GetDescriptor()
* routine is not hooked in the user application to properly return descriptors to the library.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceError);
#endif
/* Enums: */ /* Enums: */
/** Enum for the possible standard descriptor types, as given in each descriptor's header. */ /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
enum USB_DescriptorTypes_t enum USB_DescriptorTypes_t

@ -160,41 +160,41 @@
{ {
REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients * recipients. Passed to the user application for other recipients
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients * recipients. Passed to the user application for other recipients
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface
* recipients. Passed to the user application for other recipients * recipients. Passed to the user application for other recipients
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the * to the user application for other recipients via the
* \ref USB_UnhandledControlPacket() event when received in * \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request
* types. */ * types. */
REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the * to the user application for other recipients via the
* \ref USB_UnhandledControlPacket() event when received in * \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed
* to the user application for other recipients via the * to the user application for other recipients via the
* \ref USB_UnhandledControlPacket() event when received in * \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application
* via the \ref USB_UnhandledControlPacket() event when received in * via the \ref EVENT_USB_UnhandledControlPacket() event when received in
* device mode. */ * device mode. */
}; };

@ -32,7 +32,8 @@
* @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks * @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks
* *
* Macros and enums for the stream callback routines. This module contains the code required to easily set up * Macros and enums for the stream callback routines. This module contains the code required to easily set up
* stream callback functions which can be used to force early abort of a stream read/write process. * stream callback functions which can be used to force early abort of a stream read/write process. Each callback
* should take no arguments, and return a value from the \ref StreamCallback_Return_ErrorCodes_t enum.
* *
* @{ * @{
*/ */
@ -42,37 +43,6 @@
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Macros: */
/** Creates a prototype for or begins a stream callback routine. Stream callback routines are small
* routines which are executed during stream read or writes (if the callback-enabled versions of
* these functions are used) which allow the user application to abort the transfer when certain
* arbitrary conditions are met.
*
* Stream callback functions should return a value from the \ref StreamCallback_Return_ErrorCodes_t
* enum.
*
* Usage Example (Device Endpoint, but applicable for Host Pipes also):
* \code
* STREAM_CALLBACK(GlobalNotSet); // Callback Prototype
*
* STREAM_CALLBACK(GlobalNotSet)
* {
* if (MyGlobal == false)
* return ENDPOINT_STREAMCALLBACK_Continue;
* else
* return ENDPOINT_STREAMCALLBACK_Abort;
* }
*
* //...
* // Inside some routine:
* if (Endpoint_Write_Stream_LE(DataBuffer, sizeof(DataBuffer), GlobalNotSet) ==
* ENDPOINT_RWSTREAM_ERROR_CallbackAborted)
* {
* // Do something when the callback aborted the transfer early
* }
* \endcode
*/
#define STREAM_CALLBACK(name) uint8_t name (void)
/** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream
* call has no callback function to be called between USB packets. * call has no callback function to be called between USB packets.
*/ */

@ -72,24 +72,24 @@ ISR(USB_GEN_vect, ISR_BLOCK)
{ {
USB_INT_Clear(USB_INT_VBUS); USB_INT_Clear(USB_INT_VBUS);
RAISE_EVENT(USB_VBUSChange); EVENT_USB_VBUSChange();
if (USB_VBUS_GetStatus()) if (USB_VBUS_GetStatus())
{ {
RAISE_EVENT(USB_VBUSConnect); EVENT_USB_VBUSConnect();
if (USB_IsConnected) if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_ResetInterface(); USB_ResetInterface();
USB_IsConnected = true; USB_IsConnected = true;
RAISE_EVENT(USB_Connect); EVENT_USB_Connect();
} }
else else
{ {
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_Detach(); USB_Detach();
USB_CLK_Freeze(); USB_CLK_Freeze();
@ -98,7 +98,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_IsConnected = false; USB_IsConnected = false;
RAISE_EVENT(USB_VBUSDisconnect); EVENT_USB_VBUSDisconnect();
USB_INT_Clear(USB_INT_VBUS); USB_INT_Clear(USB_INT_VBUS);
} }
@ -119,13 +119,13 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_IsSuspended = true; USB_IsSuspended = true;
RAISE_EVENT(USB_Suspend); EVENT_USB_Suspend();
#if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT) #if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
if (USB_IsConnected) if (USB_IsConnected)
{ {
USB_IsConnected = false; USB_IsConnected = false;
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
} }
#endif #endif
} }
@ -149,13 +149,13 @@ ISR(USB_GEN_vect, ISR_BLOCK)
if (!(USB_IsConnected)) if (!(USB_IsConnected))
{ {
USB_IsConnected = true; USB_IsConnected = true;
RAISE_EVENT(USB_Connect); EVENT_USB_Connect();
} }
#endif #endif
USB_IsSuspended = false; USB_IsSuspended = false;
RAISE_EVENT(USB_WakeUp); EVENT_USB_WakeUp();
} }
if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
@ -178,7 +178,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Enable(USB_INT_ENDPOINT_SETUP); USB_INT_Enable(USB_INT_ENDPOINT_SETUP);
#endif #endif
RAISE_EVENT(USB_Reset); EVENT_USB_Reset();
} }
#endif #endif
@ -189,8 +189,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Clear(USB_INT_DCONNI); USB_INT_Clear(USB_INT_DCONNI);
USB_INT_Disable(USB_INT_DDISCI); USB_INT_Disable(USB_INT_DDISCI);
RAISE_EVENT(USB_DeviceUnattached); EVENT_USB_DeviceUnattached();
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_ResetInterface(); USB_ResetInterface();
} }
@ -202,8 +202,8 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_Host_VBUS_Manual_Off(); USB_Host_VBUS_Manual_Off();
USB_Host_VBUS_Auto_Off(); USB_Host_VBUS_Auto_Off();
RAISE_EVENT(USB_HostError, HOST_ERROR_VBusVoltageDip); EVENT_USB_HostError(HOST_ERROR_VBusVoltageDip);
RAISE_EVENT(USB_DeviceUnattached); EVENT_USB_DeviceUnattached();
USB_HostState = HOST_STATE_Unattached; USB_HostState = HOST_STATE_Unattached;
} }
@ -213,7 +213,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_INT_Clear(USB_INT_SRPI); USB_INT_Clear(USB_INT_SRPI);
USB_INT_Disable(USB_INT_SRPI); USB_INT_Disable(USB_INT_SRPI);
RAISE_EVENT(USB_DeviceAttached); EVENT_USB_DeviceAttached();
USB_INT_Enable(USB_INT_DDISCI); USB_INT_Enable(USB_INT_DDISCI);
@ -224,11 +224,11 @@ ISR(USB_GEN_vect, ISR_BLOCK)
{ {
USB_INT_Clear(USB_INT_BCERRI); USB_INT_Clear(USB_INT_BCERRI);
RAISE_EVENT(USB_DeviceEnumerationFailed, HOST_ENUMERROR_NoDeviceDetected, 0); EVENT_USB_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
RAISE_EVENT(USB_DeviceUnattached); EVENT_USB_DeviceUnattached();
if (USB_IsConnected) if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_ResetInterface(); USB_ResetInterface();
} }
@ -242,12 +242,12 @@ ISR(USB_GEN_vect, ISR_BLOCK)
if (USB_IsConnected) if (USB_IsConnected)
{ {
if (USB_CurrentMode == USB_MODE_HOST) if (USB_CurrentMode == USB_MODE_HOST)
RAISE_EVENT(USB_DeviceUnattached); EVENT_USB_DeviceUnattached();
else else
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
} }
RAISE_EVENT(USB_UIDChange); EVENT_USB_UIDChange();
USB_ResetInterface(); USB_ResetInterface();
} }

@ -45,113 +45,6 @@
extern "C" { extern "C" {
#endif #endif
/* Public Interface - May be used in end-application: */
/* Throwable Events: */
/** This module raises the USB Connected interrupt when the AVR is attached to a host while in device
* USB mode.
*
* \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
* this means that the current connection state is derived from the bus suspension and wake up events by default,
* which is not always accurate (host may suspend the bus while still connected). If the actual connection state
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by \ref RAISE_EVENT(), and the USB_IsConnected global changed manually.
*/
RAISES_EVENT(USB_Connect);
/** This module raises the USB Disconnected interrupt when the AVR is removed from a host while in
* device USB mode.
*
* \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.
* this means that the current connection state is derived from the bus suspension and wake up events by default,
* which is not always accurate (host may suspend the bus while still connected). If the actual connection state
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by \ref RAISE_EVENT(), and the USB_IsConnected global changed manually.
*/
RAISES_EVENT(USB_Disconnect);
#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
/** This module raises the VBUS Change event when the current VBUS status (present or not present) has
* changed.
*
* \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_VBUSChange);
/** This module raises the VBUS Connect event when the VBUS line is powered.
*
* \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_VBUSConnect);
/** This module raises the VBUS Disconnect event when power is removed from the VBUS line.
*
* \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_VBUSDisconnect);
#endif
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
/** This module raises the Suspended event when the host suspends the USB interface of the AVR
* whilst running in device mode.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_Suspend);
/** This module raises the Wake Up event when the host resumes the USB interface of the AVR
* whilst running in device mode.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_WakeUp);
/** This module raises the USB Reset event when the host resets the USB interface of the AVR
* whilst running in device mode.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_Reset);
#endif
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
/** This module raises the Host Error event when the VBUS line voltage dips below the minimum threshold
* while running in host mode.
*
* \note Not all USB AVR models support host mode; this event only exists on supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_HostError);
/** This module raises the Device Unattached event when an attached device is removed from the AVR whilst
* running in host mode.
*
* \note Not all USB AVR models support host mode; this event only exists on supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceUnattached);
#endif
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
/** This module raises the UID Change event when the UID line changes in value on dual-role devices.
*
* \note Not all USB AVR models support host mode and thus the UID pin; this event only exists on
* supported AVRs.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_UIDChange);
#endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */

@ -67,7 +67,7 @@
* which is not always accurate (host may suspend the bus while still connected). If the actual connection state * which is not always accurate (host may suspend the bus while still connected). If the actual connection state
* needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by
* passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection
* and disconnection events may be manually fired by \ref RAISE_EVENT(), and the \ref USB_IsConnected global changed manually. * and disconnection events may be manually fired, and the \ref USB_IsConnected global changed manually.
* *
* \ingroup Group_USBManagement * \ingroup Group_USBManagement
*/ */
@ -84,7 +84,7 @@
extern volatile bool USB_IsInitialized; extern volatile bool USB_IsInitialized;
/** Structure containing the last received Control request when in Device mode (for use in user-applications /** Structure containing the last received Control request when in Device mode (for use in user-applications
* inside of the \ref USB_UnhandledControlPacket() event, or for filling up with a control request to issue when * inside of the \ref EVENT_USB_UnhandledControlPacket() event, or for filling up with a control request to issue when
* in Host mode before calling \ref USB_Host_SendControlRequest(). * in Host mode before calling \ref USB_Host_SendControlRequest().
* *
* \ingroup Group_USBManagement * \ingroup Group_USBManagement
@ -122,52 +122,6 @@
extern volatile uint8_t USB_HostState; extern volatile uint8_t USB_HostState;
#endif #endif
/* Throwable Events: */
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
/** This module raises the \ref USB_Connect event when a USB device has been connected whilst in host
* mode, but not yet enumerated.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_Connect);
/** This module raises the \ref USB_DeviceAttached event when in host mode, and a device is attached
* to the AVR's USB interface.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceAttached);
/** This module raises the \ref USB_DeviceUnattached event when in host mode, and a device is removed
* from the AVR's USB interface.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceUnattached);
/** This module raises the \ref USB_DeviceEnumerationFailed event when in host mode, and an
* attached USB device has failed to successfully enumerated.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceEnumerationFailed);
/** This module raises the \ref USB_DeviceEnumerationComplete event when in host mode, and an
* attached USB device has been successfully enumerated and ready to be used by the user
* application.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceEnumerationComplete);
/** This module raises the \ref USB_Disconnect event when an attached USB device is removed from the USB
* bus.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_Disconnect);
#endif
/* Tasks: */ /* Tasks: */
/** This is the main USB management task. The USB driver requires that this task be executed /** This is the main USB management task. The USB driver requires that this task be executed
* continuously when the USB system is active (device attached in host mode, or attached to a host * continuously when the USB system is active (device attached in host mode, or attached to a host
@ -177,11 +131,11 @@
* The USB task must be serviced within 50mS in all modes, when needed. The task may be serviced * The USB task must be serviced within 50mS in all modes, when needed. The task may be serviced
* at all times, or (for minimum CPU consumption): * at all times, or (for minimum CPU consumption):
* *
* - In device mode, it may be disabled at start-up, enabled on the firing of the \ref USB_Connect event * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Connect() event
* and disabled again on the firing of the \ref USB_Disconnect event. * and disabled again on the firing of the \ref EVENT_USB_Disconnect() event.
* *
* - In host mode, it may be disabled at start-up, enabled on the firing of the \ref USB_DeviceAttached * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_DeviceAttached()
* event and disabled again on the firing of the \ref USB_DeviceUnattached event. * event and disabled again on the firing of the \ref EVENT_USB_DeviceUnattached() event.
* *
* If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library
* by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch. * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.

@ -106,7 +106,7 @@ void USB_Device_ProcessControlPacket(void)
} }
if (!(RequestHandled)) if (!(RequestHandled))
RAISE_EVENT(USB_UnhandledControlPacket); EVENT_USB_UnhandledControlPacket();
if (Endpoint_IsSETUPReceived()) if (Endpoint_IsSETUPReceived())
{ {
@ -157,9 +157,9 @@ static void USB_Device_SetConfiguration(void)
Endpoint_ClearIN(); Endpoint_ClearIN();
if (!(AlreadyConfigured) && USB_ConfigurationNumber) if (!(AlreadyConfigured) && USB_ConfigurationNumber)
RAISE_EVENT(USB_DeviceEnumerationComplete); EVENT_USB_DeviceEnumerationComplete();
RAISE_EVENT(USB_ConfigurationChanged); EVENT_USB_ConfigurationChanged();
} }
void USB_Device_GetConfiguration(void) void USB_Device_GetConfiguration(void)

@ -81,29 +81,6 @@
* \ingroup Group_Device * \ingroup Group_Device
*/ */
extern bool USB_CurrentlySelfPowered; extern bool USB_CurrentlySelfPowered;
/* Throwable Events: */
/** This module raises the \ref USB_UnhandledControlPacket event when a request to the default control
* endpoint has been received, but the library does not implement an internal handler for it.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_UnhandledControlPacket);
/** This module raises the \ref USB_ConfigurationChanged event when the host issues a \ref REQ_SetConfiguration
* device request, to change the currently selected configuration number.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_ConfigurationChanged);
/** This module raises the \ref USB_DeviceEnumerationComplete event when the host has completed its
* enumeration of the device (i.e. when a \ref REQ_SetConfiguration request changes the current configuration
* number from 0 to a non-zero value).
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceEnumerationComplete);
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)

@ -115,7 +115,7 @@
#endif #endif
/* Enums: */ /* Enums: */
/** Enum for the ErrorCode parameter of the \ref USB_DeviceError event. /** Enum for the ErrorCode parameter of the \ref EVENT_USB_DeviceError() event.
* *
* \see Events.h for more information on this event. * \see Events.h for more information on this event.
*/ */

@ -108,7 +108,7 @@
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
* numerical address in the device. * numerical address in the device.
*/ */
#define ENDPOINT_EPNUM_MASK 0x03 #define ENDPOINT_EPNUM_MASK 0x07
/** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's /** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's
* bank size in the device. * bank size in the device.
@ -712,9 +712,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the next * each USB packet, the given stream callback function is executed repeatedly until the next
* packet is ready, allowing for early aborts of stream transfers. * packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
@ -738,9 +738,9 @@
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers. * aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
@ -765,9 +765,9 @@
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers. * aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
@ -792,9 +792,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the endpoint * each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers. * is ready to accept the next packet, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *
@ -819,9 +819,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the endpoint * each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers. * is ready to accept the next packet, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \note This routine should not be used on CONTROL type endpoints. * \note This routine should not be used on CONTROL type endpoints.
* *

@ -90,7 +90,7 @@ void USB_Host_ProcessNextHostState(void)
USB_INT_Enable(USB_INT_VBERRI); USB_INT_Enable(USB_INT_VBERRI);
USB_IsConnected = true; USB_IsConnected = true;
RAISE_EVENT(USB_Connect); EVENT_USB_Connect();
USB_Host_ResumeBus(); USB_Host_ResumeBus();
Pipe_ClearPipes(); Pipe_ClearPipes();
@ -184,7 +184,7 @@ void USB_Host_ProcessNextHostState(void)
case HOST_STATE_Default_PostAddressSet: case HOST_STATE_Default_PostAddressSet:
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
RAISE_EVENT(USB_DeviceEnumerationComplete); EVENT_USB_DeviceEnumerationComplete();
USB_HostState = HOST_STATE_Addressed; USB_HostState = HOST_STATE_Addressed;
break; break;
@ -192,14 +192,14 @@ void USB_Host_ProcessNextHostState(void)
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached)) if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
{ {
RAISE_EVENT(USB_DeviceEnumerationFailed, ErrorCode, SubErrorCode); EVENT_USB_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
USB_Host_VBUS_Auto_Off(); USB_Host_VBUS_Auto_Off();
RAISE_EVENT(USB_DeviceUnattached); EVENT_USB_DeviceUnattached();
if (USB_IsConnected) if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_ResetInterface(); USB_ResetInterface();
} }

@ -199,7 +199,7 @@
HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */ HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */
}; };
/** Enum for the error codes for the \ref USB_HostError event. /** Enum for the error codes for the \ref EVENT_USB_HostError() event.
* *
* \see \ref Group_Events for more information on this event. * \see \ref Group_Events for more information on this event.
*/ */
@ -213,14 +213,14 @@
*/ */
}; };
/** Enum for the error codes for the \ref USB_DeviceEnumerationFailed event. /** Enum for the error codes for the \ref EVENT_USB_DeviceEnumerationFailed() event.
* *
* \see \ref Group_Events for more information on this event. * \see \ref Group_Events for more information on this event.
*/ */
enum USB_Host_EnumerationErrorCodes_t enum USB_Host_EnumerationErrorCodes_t
{ {
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
* ErrorCode parameter value for the \ref USB_DeviceEnumerationFailed * ErrorCode parameter value for the \ref EVENT_USB_DeviceEnumerationFailed()
* event. * event.
*/ */
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed

@ -92,7 +92,7 @@ void USB_Init(
} }
else else
{ {
RAISE_EVENT(USB_InitFailure, USB_INITERROR_NoUSBModeSpecified); EVENT_USB_InitFailure(USB_INITERROR_NoUSBModeSpecified);
return; return;
} }
#endif #endif
@ -111,7 +111,7 @@ void USB_Init(
void USB_ShutDown(void) void USB_ShutDown(void)
{ {
if (USB_IsConnected) if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect); EVENT_USB_Disconnect();
USB_Detach(); USB_Detach();

@ -283,7 +283,7 @@
/* Enums: */ /* Enums: */
/** Enum for error codes relating to the powering on of the USB interface. These error codes are /** Enum for error codes relating to the powering on of the USB interface. These error codes are
* used in the ErrorCode parameter value of the \ref USB_InitFailure event. * used in the ErrorCode parameter value of the \ref EVENT_USB_InitFailure() event.
*/ */
enum USB_InitErrorCodes_t enum USB_InitErrorCodes_t
{ {
@ -313,24 +313,6 @@
extern volatile uint8_t USB_Options; extern volatile uint8_t USB_Options;
#endif #endif
/* Throwable Events: */
/** This module raises the \ref USB_Disconnect event if the USB interface is reset (such as during a mode
* change while in UID mode) while the USB interface is connected to a device when in host mode, or
* a host while in device mode.
*
* \see Events.h for more information on this event.
*/
RAISES_EVENT(USB_Disconnect);
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
/** This module raises the Power On Failure event when an error occurs while initializing the USB
* interface.
*
* \see Events.h for more information on this event.
*/
RAISES_EVENT(USB_InitFailure);
#endif
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */

@ -745,9 +745,9 @@
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW * \ingroup Group_PipeRW
* *
@ -769,9 +769,9 @@
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW * \ingroup Group_PipeRW
* *
@ -793,9 +793,9 @@
* Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready, * Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,
* allowing for early aborts of stream transfers. * allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW * \ingroup Group_PipeRW
* *
@ -816,9 +816,9 @@
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW * \ingroup Group_PipeRW
* *
@ -840,9 +840,9 @@
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
* *
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. If the token * The callback routine should be created according to the information in \ref Group_StreamCallbacks.
* NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* and this function has the Callback parameter omitted. * disabled and this function has the Callback parameter omitted.
* *
* \ingroup Group_PipeRW * \ingroup Group_PipeRW
* *

@ -19,11 +19,21 @@
* - The Endpoint_ClearEndpointInterrupt() macro has been deleted and references to it should be removed. * - The Endpoint_ClearEndpointInterrupt() macro has been deleted and references to it should be removed.
* - The DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory * - The DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory
* address. * address.
* - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See
* \ref Group_Events for new API details.
* - The STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular
* function signatures of a function accepting no arguments and returning a uint8_t value.
* *
* <b>Device Mode</b> * <b>Host Mode</b>
* - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing * - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing
* projects using interrupts on non-control pipes should switch to polling. * projects using interrupts on non-control pipes should switch to polling.
* - The Pipe_ClearPipeInterrupt() macro has been deleted and references to it should be removed. * - The Pipe_ClearPipeInterrupt() macro has been deleted and references to it should be removed.
* - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See
* \ref Group_Events for new API details.
* - The STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular
* function signatures of a function accepting no arguments and returning a uint8_t value.
* - The DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with
* regular function signatures of a function accepting a pointer to the descriptor to test, and returning a uint8_t value.
* *
* *
* \section Sec_Migration090510 Migrating from 090401 to 090510 * \section Sec_Migration090510 Migrating from 090401 to 090510

@ -115,14 +115,14 @@ int main(void)
} }
/** Event handler for the USB_Connect event. This starts the USB task. */ /** Event handler for the USB_Connect event. This starts the USB task. */
EVENT_HANDLER(USB_Connect) void EVENT_USB_Connect(void)
{ {
/* Start USB management task */ /* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN); Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);
} }
/** Event handler for the USB_Disconnect event. This stops the USB and keyboard report tasks. */ /** Event handler for the USB_Disconnect event. This stops the USB and keyboard report tasks. */
EVENT_HANDLER(USB_Disconnect) void EVENT_USB_Disconnect(void)
{ {
/* Stop running keyboard reporting, card reading and USB management tasks */ /* Stop running keyboard reporting, card reading and USB management tasks */
Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP); Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP);
@ -133,7 +133,7 @@ EVENT_HANDLER(USB_Disconnect)
/** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready
* to relay reports to the host, and starts the keyboard report task. * to relay reports to the host, and starts the keyboard report task.
*/ */
EVENT_HANDLER(USB_ConfigurationChanged) void EVENT_USB_ConfigurationChanged(void)
{ {
/* Setup Keyboard Keycode Report Endpoint */ /* Setup Keyboard Keycode Report Endpoint */
Endpoint_ConfigureEndpoint(KEYBOARD_EPNUM, EP_TYPE_INTERRUPT, Endpoint_ConfigureEndpoint(KEYBOARD_EPNUM, EP_TYPE_INTERRUPT,
@ -152,7 +152,7 @@ EVENT_HANDLER(USB_ConfigurationChanged)
* control requests that are not handled internally by the USB library, so that they can be handled appropriately * control requests that are not handled internally by the USB library, so that they can be handled appropriately
* for the application. * for the application.
*/ */
EVENT_HANDLER(USB_UnhandledControlPacket) void EVENT_USB_UnhandledControlPacket(void)
{ {
/* Handle HID Class specific requests */ /* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest) switch (USB_ControlRequest.bRequest)

@ -99,21 +99,13 @@
uint8_t Reserved; /**< Reserved for OEM use, always set to 0 */ uint8_t Reserved; /**< Reserved for OEM use, always set to 0 */
uint8_t KeyCode; /**< Key code array for pressed keys - up to six can be given simultaneously */ uint8_t KeyCode; /**< Key code array for pressed keys - up to six can be given simultaneously */
} USB_KeyboardReport_Data_t; } USB_KeyboardReport_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: */ /* 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_KeyboardReport_Data_t* ReportData); bool GetNextReport(USB_KeyboardReport_Data_t* ReportData);
void SendKey(USB_KeyboardReport_Data_t* KeyboardReportData, uint8_t Key); void SendKey(USB_KeyboardReport_Data_t* KeyboardReportData, uint8_t Key);
void Send(USB_KeyboardReport_Data_t* KeyboardReportData, bool SendReport); void Send(USB_KeyboardReport_Data_t* KeyboardReportData, bool SendReport);

@ -514,7 +514,7 @@ sizeafter:
checkhooks: build checkhooks: build
@echo @echo
@echo ------- Unhooked LUFA Events ------- @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 ".*") || \ cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)" echo "(None)"
@echo ------------------------------------ @echo ------------------------------------

Loading…
Cancel
Save