This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about the hid report descriptor

Hi,everyone
Does the report dexcriptor support negative value.i have checked the keil usb demo of hitex board,the report descriptor is declared as unsigned char.
one more question,in the get_descriptor function,
case USB_CONFIGURATION_DESCRIPTOR_TYPE: pD = (BYTE *)USB_ConfigDescriptor; for (n = 0; n != SetupPacket.wValue.WB.L; n++) { if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) { pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength; } }
what is the wValue.WB.L in the configDescriptor indicate?Why here use the wTotalLength.Thanks!

  • Thanks!. The source code is as following!For test

            case USB_CONFIGURATION_DESCRIPTOR_TYPE:
              pD = (BYTE *)USB_ConfigDescriptor;
              for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
                if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) {
                  pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
                }
              }
              if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength == 0) {
                return (FALSE);
              }
              EP0Data.pData = pD;
              len = ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
    

  • The report descriptor is not defined as unsigned char (BYTE pointer is used for copying). You should look at the _USB_CONFIGURATION_DESCRIPTOR structure definition.

    Also check the USB documentation for the definitions of wTotalLength in config descriptor and the meaning of wValue in device request.

    USB is quite complex and you should first study the USB documentation before going into details of an USB stack implementation.

  • Thanks for you reply.
    But i think here

    for (n = 0; n != SetupPacket.wValue.WB.L; n++) {
                if (((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength != 0) {
                  pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
                }
              }
    


    the

    pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
    

    should be

    pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->bLength;
    

  • No, you are wrong. The original code is correct.

    USB Manual says the following:
    bLength - Size of descriptor
    wTotalLength - Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration.

    Since we scan through complete data for one configuration the wTotalLength is correct.