Fixed USB_GetHIDReportSize() returning the number of bits in the specified report...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 9 Feb 2010 12:30:51 +0000 (12:30 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 9 Feb 2010 12:30:51 +0000 (12:30 +0000)
Moved the USB_GetHIDReportItemInfo() calls into the main report item passing loop in the *HostWithParser demos - it is fast enough not to effect performance, and avoids duplicate code.

Make Webserver project report the LUFA version as part of the HTTP header.

Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c
Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c
Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
LUFA/Drivers/USB/Class/Host/HIDParser.c
LUFA/Drivers/USB/Class/Host/HIDParser.h
LUFA/ManPages/ChangeLog.txt
LUFA/ManPages/LUFAPoweredProjects.txt
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
Projects/Webserver/Lib/HTTPServerApp.c
Projects/Webserver/Lib/HTTPServerApp.h

index bf39420..2470108 100644 (file)
@@ -132,15 +132,14 @@ int main(void)
                                        {\r
                                                HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];\r
                                                \r
+                                               /* Update the report item value if it is contained within the current report */\r
+                                               if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))\r
+                                                 continue;\r
+\r
+                                               /* Determine what report item is being tested, process updated value as needed */\r
                                                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&\r
                                                        (ReportItem->ItemType                     == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Get the joystick button value if it is contained within the current report, if not,\r
-                                                        * skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))\r
-                                                         continue;\r
-\r
                                                        if (ReportItem->Value)\r
                                                          LEDMask = LEDS_ALL_LEDS;\r
                                                }\r
@@ -149,12 +148,6 @@ int main(void)
                                                                  (ReportItem->Attributes.Usage.Usage == USAGE_Y))                 &&\r
                                                                 (ReportItem->ItemType                == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Get the joystick relative position value if it is contained within the current \r
-                                                        * report, if not, skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))\r
-                                                         continue;                                                       \r
-\r
                                                        int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
                                                        \r
                                                        if (ReportItem->Attributes.Usage.Usage == USAGE_X)\r
index 8fe3ede..78ec56a 100644 (file)
@@ -130,18 +130,16 @@ int main(void)
                                        {\r
                                                HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];\r
 \r
-                                               /* Check if the current report item is a keyboard scancode */\r
+                                               /* Update the report item value if it is contained within the current report */\r
+                                               if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem)))\r
+                                                 continue;\r
+\r
+                                               /* Determine what report item is being tested, process updated value as needed */\r
                                                if ((ReportItem->Attributes.Usage.Page      == USAGE_PAGE_KEYBOARD) &&\r
                                                        (ReportItem->Attributes.BitSize         == 8)                   &&\r
                                                        (ReportItem->Attributes.Logical.Maximum > 1)                    &&\r
                                                        (ReportItem->ItemType                   == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Retrieve the keyboard scancode from the report data retrieved from the device if it is\r
-                                                        * contained within the current report, if not, skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(KeyboardReport, ReportItem)))\r
-                                                         continue;\r
-\r
                                                        /* Key code is an unsigned char in length, cast to the appropriate type */\r
                                                        uint8_t KeyCode = (uint8_t)ReportItem->Value;\r
 \r
index db176e5..b641185 100644 (file)
@@ -132,15 +132,14 @@ int main(void)
                                        {\r
                                                HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];\r
                                                \r
+                                               /* Update the report item value if it is contained within the current report */\r
+                                               if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
+                                                 continue;\r
+                                               \r
+                                               /* Determine what report item is being tested, process updated value as needed */\r
                                                if ((ReportItem->Attributes.Usage.Page        == USAGE_PAGE_BUTTON) &&\r
                                                        (ReportItem->ItemType                     == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Get the mouse button value if it is contained within the current report, if not,\r
-                                                        * skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
-                                                         continue;\r
-\r
                                                        if (ReportItem->Value)\r
                                                          LEDMask = LEDS_ALL_LEDS;\r
                                                }\r
@@ -148,12 +147,6 @@ int main(void)
                                                                 (ReportItem->Attributes.Usage.Usage  == USAGE_SCROLL_WHEEL)       &&\r
                                                                 (ReportItem->ItemType                == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Get the mouse wheel value if it is contained within the current \r
-                                                        * report, if not, skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
-                                                         continue;                                                       \r
-\r
                                                        int16_t WheelDelta = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
                                                        \r
                                                        if (WheelDelta)\r
@@ -164,12 +157,6 @@ int main(void)
                                                                  (ReportItem->Attributes.Usage.Usage == USAGE_Y))                 &&\r
                                                                 (ReportItem->ItemType                == REPORT_ITEM_TYPE_In))\r
                                                {\r
-                                                       /* Get the mouse relative position value if it is contained within the current \r
-                                                        * report, if not, skip to the next item in the parser list\r
-                                                        */\r
-                                                       if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))\r
-                                                         continue;                                                       \r
-\r
                                                        int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize));\r
                                                        \r
                                                        if (ReportItem->Attributes.Usage.Usage == USAGE_X)\r
index 3ef9c78..6c81ae8 100644 (file)
@@ -340,8 +340,10 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, const uint8_t
 {\r
        for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)\r
        {\r
+               uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];\r
+       \r
                if (ParserData->ReportIDSizes[i].ReportID == ReportID)\r
-                 return ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];\r
+                 return ((ReportSizeBits >> 3) + ((ReportSizeBits & 0x07) ? 1 : 0));\r
        }\r
 \r
        return 0;\r
index 53601ec..b7225f3 100644 (file)
                        typedef struct\r
                        {\r
                                uint8_t                      ReportID; /** Report ID of the report within the HID interface */\r
-                               uint8_t                      ReportSizeBits[3]; /** Total number of bits in each report type for the given Report ID,\r
+                               uint16_t                     ReportSizeBits[3]; /** Total number of bits in each report type for the given Report ID,\r
                                                                                 *  indexed by the \ref HID_ReportItemTypes_t enum\r
                                                                                                                                 */\r
                        } HID_ReportSizeInfo_t;\r
index 9f9157d..1b5ede6 100644 (file)
@@ -57,6 +57,7 @@
   *  - Fixed incorrect values of USB_CONFIG_ATTR_SELFPOWERED and USB_CONFIG_ATTR_REMOTEWAKEUP tokens (thanks to Claus Christensen)\r
   *  - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF\r
   *  - Fixed SerialStream driver not setting stdin to the created serial stream\r
+  *  - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes\r
   *\r
   *  \section Sec_ChangeLog091223 Version 091223\r
   *\r
index e7561e6..bf61e9d 100644 (file)
@@ -36,6 +36,7 @@
  *  - AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/\r
  *  - Bicycle POV: http://www.code.google.com/p/bicycleledpov/\r
  *  - CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig\r
+ *  - CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/\r
  *  - ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/\r
  *  - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/\r
  *  - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master\r
index 9055920..91ed775 100644 (file)
@@ -167,10 +167,6 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
        \r
        while (WriteLength)\r
        {\r
-               /* Wait until the NVM controller is no longer busy */\r
-               if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
-                 return false;\r
-\r
                /* Write the low byte of data to the target */\r
                XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
                XPROGTarget_SendByte(*(WriteBuffer++));\r
@@ -179,6 +175,10 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint
                XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
                XPROGTarget_SendByte(*(WriteBuffer++));\r
 \r
+               /* Wait until the NVM controller is no longer busy */\r
+               if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
+                 return false;\r
+\r
                /* Need to decrement the write length twice, since we read out a whole word */\r
                WriteLength -= 2;\r
        }\r
index c2263cb..ad768c8 100644 (file)
@@ -41,7 +41,7 @@
  *  given location, and gives extra connection information.\r
  */\r
 char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
-                               "Server: LUFA RNDIS\r\n"\r
+                               "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
                                "Connection: close\r\n"\r
                                "MIME-version: 1.0\r\n"\r
                                "Content-Type: ";\r
@@ -50,7 +50,7 @@ char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"
  *  given URL is invalid, and gives extra error information.\r
  */\r
 char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
-                               "Server: LUFA RNDIS\r\n"\r
+                               "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
                                "Connection: close\r\n"\r
                                "MIME-version: 1.0\r\n"\r
                                "Content-Type: text/plain\r\n\r\n"\r
index 33a647b..b113928 100644 (file)
@@ -40,6 +40,8 @@
                #include <avr/pgmspace.h>\r
                #include <string.h>\r
                \r
+               #include <LUFA/Version.h>\r
+\r
                #include <uip.h>\r
                #include <ff.h>\r
        \r