Minor updates to the Magstripe and MissileLauncher projects to fix bugs and improve...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 16 Jul 2009 15:00:10 +0000 (15:00 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 16 Jul 2009 15:00:10 +0000 (15:00 +0000)
Fixed error in GenericHID descriptors preventing it from passing the USB-IF HID tests (thanks to Søren Greiner).

Demos/Device/ClassDriver/GenericHID/Descriptors.c
LUFA/ManPages/ChangeLog.txt
Projects/Magstripe/Descriptors.c
Projects/Magstripe/Magstripe.c
Projects/Magstripe/Magstripe.h
Projects/MissileLauncher/MissileLauncher.c

index 0ce3c56..abc360b 100644 (file)
@@ -51,8 +51,8 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
        0x09, 0x02,           /*   Usage (Vendor Defined)                        */\r
        0x75, 0x08,           /*   Report Size (8)                               */\r
        0x95, GENERIC_REPORT_SIZE, /*   Report Count (GENERIC_REPORT_SIZE)       */\r
        0x09, 0x02,           /*   Usage (Vendor Defined)                        */\r
        0x75, 0x08,           /*   Report Size (8)                               */\r
        0x95, GENERIC_REPORT_SIZE, /*   Report Count (GENERIC_REPORT_SIZE)       */\r
-       0x15, 0x00,           /*   Logical Minimum (0)                           */\r
-       0x25, 0xff,           /*   Logical Maximum (255)                         */\r
+       0x15, 0x80,           /*   Logical Minimum (-128)                        */\r
+       0x25, 0x7F,           /*   Logical Maximum (127)                         */\r
        0x81, 0x02,           /*   Input (Data, Variable, Absolute)              */\r
        0x09, 0x03,           /*   Usage (Vendor Defined)                        */\r
        0x75, 0x08,           /*   Report Size (8)                               */\r
        0x81, 0x02,           /*   Input (Data, Variable, Absolute)              */\r
        0x09, 0x03,           /*   Usage (Vendor Defined)                        */\r
        0x75, 0x08,           /*   Report Size (8)                               */\r
index cbe4c59..c2b7d5e 100644 (file)
@@ -60,6 +60,7 @@
   *  - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used\r
   *  - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected\r
   *  - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman)\r
   *  - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used\r
   *  - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected\r
   *  - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman)\r
+  *  - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Søren Greiner)\r
   *\r
   *\r
   *  \section Sec_ChangeLog090605 Version 090605\r
   *\r
   *\r
   *  \section Sec_ChangeLog090605 Version 090605\r
index de704ae..68c98ed 100644 (file)
@@ -154,7 +154,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
                        .EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),\r
                        .Attributes             = EP_TYPE_INTERRUPT,\r
                        .EndpointSize           = KEYBOARD_EPSIZE,\r
                        .EndpointAddress        = (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),\r
                        .Attributes             = EP_TYPE_INTERRUPT,\r
                        .EndpointSize           = KEYBOARD_EPSIZE,\r
-                       .PollingIntervalMS      = 0x04\r
+                       .PollingIntervalMS      = 0x01\r
                },\r
 };\r
 \r
                },\r
 };\r
 \r
index 95c81f3..1151735 100644 (file)
@@ -130,6 +130,7 @@ void ReadMagstripeData(void)
                        bool ClockPinLevel     = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);\r
                        bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);\r
                \r
                        bool ClockPinLevel     = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);\r
                        bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);\r
                \r
+                       /* Sample on rising clock edges */\r
                        if (ClockPinLevel && ClockLevelChanged)\r
                          BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);\r
                }\r
                        if (ClockPinLevel && ClockLevelChanged)\r
                          BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);\r
                }\r
@@ -171,15 +172,15 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
        static bool IsKeyReleaseReport;\r
        static bool IsNewlineReport;\r
 \r
        static bool IsKeyReleaseReport;\r
        static bool IsNewlineReport;\r
 \r
-       BitBuffer_t*               Buffer         = NULL;\r
        USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
        USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
+       BitBuffer_t*               Buffer         = NULL;\r
        \r
        \r
-       /* Key reports must be interleaved with 0 Key Code reports to release the keys, or repeated keys will be ignored */\r
+       /* Key reports must be interleaved with key release reports, or repeated keys will be ignored */\r
        IsKeyReleaseReport = !IsKeyReleaseReport;       \r
 \r
        if (IsKeyReleaseReport)\r
        {\r
        IsKeyReleaseReport = !IsKeyReleaseReport;       \r
 \r
        if (IsKeyReleaseReport)\r
        {\r
-               KeyboardReport->KeyCode = 0;\r
+               KeyboardReport->KeyCode = KEY_NONE;\r
        }\r
        else if (IsNewlineReport)\r
        {\r
        }\r
        else if (IsNewlineReport)\r
        {\r
@@ -188,6 +189,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
+               /* Read out tracks in ascending order - when each track buffer is empty, progress to next buffer */\r
                if (TrackDataBuffers[0].Elements)\r
                  Buffer = &TrackDataBuffers[0];\r
                else if (TrackDataBuffers[1].Elements)\r
                if (TrackDataBuffers[0].Elements)\r
                  Buffer = &TrackDataBuffers[0];\r
                else if (TrackDataBuffers[1].Elements)\r
@@ -199,7 +201,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
 \r
                KeyboardReport->KeyCode = BitBuffer_GetNextBit(Buffer) ? KEY_1 : KEY_0;\r
                \r
 \r
                KeyboardReport->KeyCode = BitBuffer_GetNextBit(Buffer) ? KEY_1 : KEY_0;\r
                \r
-               /* If buffer now empty, next report must be a newline to seperate track data */\r
+               /* If current track buffer now empty, next report must be a newline to seperate track data */\r
                if (!(Buffer->Elements))\r
                  IsNewlineReport = true;\r
        }\r
                if (!(Buffer->Elements))\r
                  IsNewlineReport = true;\r
        }\r
index 1009e32..93e593e 100644 (file)
@@ -51,6 +51,9 @@
                #include <LUFA/Drivers/USB/Class/HID.h>\r
 \r
        /* Macros: */\r
                #include <LUFA/Drivers/USB/Class/HID.h>\r
 \r
        /* Macros: */\r
+               /** HID keyboard keycode to indicate that no is currently pressed. */\r
+               #define KEY_NONE           0\r
+       \r
                /** HID keyboard keycode to indicate that the "1" key is currently pressed. */\r
                #define KEY_1              30\r
 \r
                /** HID keyboard keycode to indicate that the "1" key is currently pressed. */\r
                #define KEY_1              30\r
 \r
index 046c132..88902cf 100644 (file)
@@ -137,8 +137,9 @@ void SetupHardware(void)
 void Read_Joystick_Status(void)\r
 {\r
        uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
 void Read_Joystick_Status(void)\r
 {\r
        uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
+       uint8_t Buttons_LCL   = Buttons_GetStatus();\r
 \r
 \r
-       if (BUTTONS_BUTTON1 && Buttons_GetStatus())\r
+       if (Buttons_LCL & BUTTONS_BUTTON1)\r
          Send_Command(CMD_FIRE);\r
        else if (JoyStatus_LCL & JOY_UP)\r
          Send_Command(CMD_UP);\r
          Send_Command(CMD_FIRE);\r
        else if (JoyStatus_LCL & JOY_UP)\r
          Send_Command(CMD_UP);\r
@@ -285,7 +286,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint16_t ReportLength)
                /* Class specific request to send a HID report to the device */\r
                USB_ControlRequest = (USB_Request_Header_t)\r
                        {\r
                /* Class specific request to send a HID report to the device */\r
                USB_ControlRequest = (USB_Request_Header_t)\r
                        {\r
-                               .bmRequestType = 0x21,\r
+                               .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
                                .bRequest      = 0x09,\r
                                .wValue        = 0x02,\r
                                .wIndex        = 0x01,\r
                                .bRequest      = 0x09,\r
                                .wValue        = 0x02,\r
                                .wIndex        = 0x01,\r