Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB HID Vendor Descriptor fails in windows. #7

Open
youpko opened this issue Aug 18, 2020 · 1 comment
Open

USB HID Vendor Descriptor fails in windows. #7

youpko opened this issue Aug 18, 2020 · 1 comment

Comments

@youpko
Copy link

youpko commented Aug 18, 2020

I am working on a USB project where I want to use the USB HID Vendor method communicate with the host PC (windows)

My project consists of the following 3 USB functions

  • HID Joystick - Working normally.
  • HID Vendor - Windows error code 10. Insufficient resources to allocate needed memory
  • MSD SPI Flash - Works normally.

I configured everything with the harmony configuration.
for the HID Vendor descriptor I looked in to the example apps and copied the descriptor to my project but it doesn't work.

Example HID descriptor,

0x06, 0x00, 0xFF,     // Usage Page = 0xFF00 (Vendor Defined Page 1)
0x09, 0x01,             // Usage (Vendor Usage 1)
0xA1, 0x01,             // Colsslection (Application)
0x19, 0x01,             // Usage Minimum
0x29, 0x40,             // Usage Maximum 	//64 input usages total (0x01 to 0x40)
0x15, 0x01,             // Logical Minimum (data bytes in the report may have minimum value = 0x00)
0x25, 0x40,             // Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
0x75, 0x08,             // Report Size: 8-bit field size
0x95, 0x40,             // Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
0x81, 0x00,             // Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.
0x19, 0x01,             // Usage Minimum
0x29, 0x40,             // Usage Maximum 	//64 output usages total (0x01 to 0x40)
0x91, 0x00,             // Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.
0xC0 

But it fails with: Windows error code 10. Insufficient resources to allocate needed memory

After searching the microchip forums I found the following descriptor

    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    
    0x85, 0x01,                    //   Report ID (1) 
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
    0x29, 0x40,                    //   USAGE_MAXIMUM (Vendor Usage 64)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)

    0x85, 0x02,                    //   Report ID (2) 
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
    0x29, 0x40,                    //   USAGE_MAXIMUM (Vendor Usage 64)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    
    0x85, 0x03,                    //   Report ID (3) 
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x09, 0x01,                    //   USAGE (Vendor Usage 1)
    0xB1, 0x02,                    //   Feature (Data,Var,Abs)
    
    0xC0                           // END_COLLECTION

But it fails with: Extra end collection found or end collection not found.

It feels like I am missing something obvious but after a couple of days of struggling I cant seem to figure it out.

@youpko
Copy link
Author

youpko commented Oct 1, 2020

After being away for a while i found the problem.

In the usb_device_init_data.c are the function registration tables. And when using multiple HID interfaces in the harmony configurator the .funcDeriverInit is initialised wrong all of the interfaces uses the hidInit0 struct and not the correct for the interface number.

The following image shows the harmony generated code on the left and my edit on the right that fixes the problem.
81fe273006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant