Remove custom CDC class descriptor definitions from the CDC bootloader, and switch...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / HIDParser.c
index f6c48fd..eb2f14c 100644 (file)
@@ -61,12 +61,12 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
                switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
                {
                        case HID_RI_DATA_BITS_32:
                switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
                {
                        case HID_RI_DATA_BITS_32:
-                               ReportItemData  = *((uint32_t*)ReportData);
+                               ReportItemData  = le32_to_cpu(*((uint32_t*)ReportData));
                                ReportSize     -= 4;
                                ReportData     += 4;
                                break;
                        case HID_RI_DATA_BITS_16:
                                ReportSize     -= 4;
                                ReportData     += 4;
                                break;
                        case HID_RI_DATA_BITS_16:
-                               ReportItemData  = *((uint16_t*)ReportData);
+                               ReportItemData  = le16_to_cpu(*((uint16_t*)ReportData));
                                ReportSize     -= 2;
                                ReportData     += 2;
                                break;
                                ReportSize     -= 2;
                                ReportData     += 2;
                                break;
@@ -290,6 +290,9 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
 bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
 bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
+       if (ReportItem == NULL)
+               return false;
+
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
        uint32_t BitMask      = (1 << 0);
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
        uint32_t BitMask      = (1 << 0);
@@ -320,6 +323,9 @@ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,
 void USB_SetHIDReportItemInfo(uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
 void USB_SetHIDReportItemInfo(uint8_t* ReportData,
                               HID_ReportItem_t* const ReportItem)
 {
+       if (ReportItem == NULL)
+               return;
+
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
        uint32_t BitMask      = (1 << 0);
        uint16_t DataBitsRem  = ReportItem->Attributes.BitSize;
        uint16_t CurrentBit   = ReportItem->BitOffset;
        uint32_t BitMask      = (1 << 0);
@@ -351,7 +357,7 @@ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,
                uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];
 
                if (ParserData->ReportIDSizes[i].ReportID == ReportID)
                uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];
 
                if (ParserData->ReportIDSizes[i].ReportID == ReportID)
-                 return ((ReportSizeBits >> 3) + ((ReportSizeBits & 0x07) ? 1 : 0));
+                 return (ReportSizeBits / 8) + ((ReportSizeBits % 8) ? 1 : 0);
        }
 
        return 0;
        }
 
        return 0;