diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-05-18 10:05:21 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-05-18 10:05:21 +0000 |
commit | 2ee9fc707784e115d744dbc229bdc893f4bb6bc1 (patch) | |
tree | 1f4de5f6d8e2a9bfe89d3263f19f9b9ebf855812 /Demos/Device/Keyboard | |
parent | 72c2922e38a2dfd14eb2d8e3692171704b5508f4 (diff) | |
download | lufa-2ee9fc707784e115d744dbc229bdc893f4bb6bc1.tar.gz lufa-2ee9fc707784e115d744dbc229bdc893f4bb6bc1.tar.bz2 lufa-2ee9fc707784e115d744dbc229bdc893f4bb6bc1.zip |
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.
Diffstat (limited to 'Demos/Device/Keyboard')
-rw-r--r-- | Demos/Device/Keyboard/Keyboard.c | 10 | ||||
-rw-r--r-- | Demos/Device/Keyboard/Keyboard.h | 34 | ||||
-rw-r--r-- | Demos/Device/Keyboard/makefile | 2 |
3 files changed, 19 insertions, 27 deletions
diff --git a/Demos/Device/Keyboard/Keyboard.c b/Demos/Device/Keyboard/Keyboard.c index fe041ef08..6abd193f4 100644 --- a/Demos/Device/Keyboard/Keyboard.c +++ b/Demos/Device/Keyboard/Keyboard.c @@ -100,7 +100,7 @@ int main(void) /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and
* starts the library USB task to begin the enumeration and USB management process.
*/
-EVENT_HANDLER(USB_Connect)
+void EVENT_USB_Connect(void)
{
/* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);
@@ -115,7 +115,7 @@ EVENT_HANDLER(USB_Connect) /** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via
* the status LEDs.
*/
-EVENT_HANDLER(USB_Disconnect)
+void EVENT_USB_Disconnect(void)
{
/* Stop running keyboard reporting and USB management tasks */
Scheduler_SetTaskMode(USB_Keyboard_Report, TASK_STOP);
@@ -128,7 +128,7 @@ EVENT_HANDLER(USB_Disconnect) /** Event handler for the USB_ConfigurationChanged event. This is fired when the host sets the current configuration
* of the USB device after enumeration, and configures the keyboard device endpoints.
*/
-EVENT_HANDLER(USB_ConfigurationChanged)
+void EVENT_USB_ConfigurationChanged(void)
{
/* Setup Keyboard Keycode Report Endpoint */
Endpoint_ConfigureEndpoint(KEYBOARD_EPNUM, EP_TYPE_INTERRUPT,
@@ -151,7 +151,7 @@ EVENT_HANDLER(USB_ConfigurationChanged) * control requests that are not handled internally by the USB library (including the HID commands, which are
* all issued via the control endpoint), so that they can be handled appropriately for the application.
*/
-EVENT_HANDLER(USB_UnhandledControlPacket)
+void EVENT_USB_UnhandledControlPacket(void)
{
/* Handle HID Class specific requests */
switch (USB_ControlRequest.bRequest)
@@ -220,7 +220,7 @@ EVENT_HANDLER(USB_UnhandledControlPacket) Endpoint_ClearSETUP();
/* Set or clear the flag depending on what the host indicates that the current Protocol should be */
- UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000);
+ UsingReportProtocol = (USB_ControlRequest.wValue != 0);
/* Acknowledge status stage */
while (!(Endpoint_IsINReady()));
diff --git a/Demos/Device/Keyboard/Keyboard.h b/Demos/Device/Keyboard/Keyboard.h index 2cc9c5ca8..c4ed6e07c 100644 --- a/Demos/Device/Keyboard/Keyboard.h +++ b/Demos/Device/Keyboard/Keyboard.h @@ -55,25 +55,25 @@ /* Macros: */
/** Idle period indicating that reports should be sent only when the inputs have changed */
- #define HID_IDLE_CHANGESONLY 0
+ #define HID_IDLE_CHANGESONLY 0
/** HID Class specific request to get the next HID report from the device. */
- #define REQ_GetReport 0x01
+ #define REQ_GetReport 0x01
/** HID Class specific request to get the idle timeout period of the device. */
- #define REQ_GetIdle 0x02
+ #define REQ_GetIdle 0x02
/** HID Class specific request to send the next HID report to the device. */
- #define REQ_SetReport 0x09
+ #define REQ_SetReport 0x09
/** HID Class specific request to set the idle timeout period of the device. */
- #define REQ_SetIdle 0x0A
+ #define REQ_SetIdle 0x0A
/** HID Class specific request to get the current HID protocol in use, either report or boot. */
- #define REQ_GetProtocol 0x03
+ #define REQ_GetProtocol 0x03
/** HID Class specific request to set the current HID protocol in use, either report or boot. */
- #define REQ_SetProtocol 0x0B
+ #define REQ_SetProtocol 0x0B
/* Task Definitions: */
TASK(USB_Keyboard_Report);
@@ -97,25 +97,17 @@ Status_USBEnumerating = 1, /**< USB interface is enumerating */
Status_USBReady = 2, /**< USB interface is connected and ready */
};
-
- /* Event Handlers: */
- /** Indicates that this module will catch the USB_Connect event when thrown by the library. */
- HANDLES_EVENT(USB_Connect);
-
- /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */
- HANDLES_EVENT(USB_Disconnect);
-
- /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */
- HANDLES_EVENT(USB_ConfigurationChanged);
-
- /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */
- HANDLES_EVENT(USB_UnhandledControlPacket);
/* Function Prototypes: */
+ void EVENT_USB_Connect(void);
+ void EVENT_USB_Disconnect(void);
+ void EVENT_USB_ConfigurationChanged(void);
+ void EVENT_USB_UnhandledControlPacket(void);
+
void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData);
void ProcessLEDReport(uint8_t LEDReport);
void SendNextReport(void);
void ReceiveNextReport(void);
void UpdateStatus(uint8_t CurrentStatus);
-
+
#endif
diff --git a/Demos/Device/Keyboard/makefile b/Demos/Device/Keyboard/makefile index bacf6dc57..3c597bf49 100644 --- a/Demos/Device/Keyboard/makefile +++ b/Demos/Device/Keyboard/makefile @@ -504,7 +504,7 @@ sizeafter: checkhooks: build
@echo
@echo ------- Unhooked LUFA Events -------
- @$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \
+ @$(shell) (grep -s '^EVENT_.*LUFA/.*\\.o' $(TARGET).map | \
cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)"
@echo ------------------------------------
|