Author Topic: about USB HID report descriptor  (Read 11295 times)

hristo

  • Member
  • ***
  • Posts: 3
about USB HID report descriptor
« on: January 26, 2013, 06:47:25 am »
Hi Jan and everyone,

Thanks for the great session about Generic HID cs.

I've used it without any problem to exchange some bytes between my
DIY device (Atmel's tiny45) with V-USB firmware and using only a Control Transfer.

The report descriptor I'm using is as follow:

PROGMEM const char usbHidReportDescriptor[22] = {   
    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x88,                    //   REPORT_COUNT (136)
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION
};

Now, because I need to exchange two kinds of data: a large one (app. 136 byte, used rarely),
and a short one (8 bytes, used more frequently), would be better, if I use a report descriptor
having one input and one output reports beside the feature report I already have?

Something like that:

PROGMEM const char usbHidReportDescriptor[48] = {
   0x06, 0xa0, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
   0x09, 0x01,       // USAGE (Vendor Usage 1)
   0xa1, 0x01,       // COLLECTION (Application)

   // Input Report
   0x09, 0x02,       // Usage ID - vendor defined
   0x15, 0x00,       // Logical Minimum (0)
   0x26, 0xFF, 0x00, // Logical Maximum (255)
   0x75, 0x08,       // Report Size (8 bits)
   0x95, 0x08,       // Report Count (8 fields)
   0x81, 0x02,       // Input (Data, Variable, Absolute)

   // Output report
   0x09, 0x03,       // Usage ID - vendor defined
   0x15, 0x00,       // Logical Minimum (0)
   0x26, 0xFF, 0x00, // Logical Maximum (255)
   0x75, 0x08,       // Report Size (8 bits)
   0x95, 0x08,       // Report Count (8 fields)
   0x91, 0x02,       // Output (Data, Variable, Absolute)

   // Feature report
   0x09, 0x04,       // Usage ID - vendor defined
   0x15, 0x00,       // Logical Minimum (0)
   0x26, 0xFF, 0x00, // Logical Maximum (255)
   0x75, 0x08,       // Report Size (8 bits)
   0x95, 0x88,       // Report Count (136 fields)
   0xb2, 0x02, 0x01, //   FEATURE (Data,Var,Abs,Buf)
   
   0xc0              // END_COLLECTION
};

Or, may be implementing an interrupt IN/OUT transfer is more reasonable in my case?

I'll be glad for any advise.

Thank You in advance,

hristo.


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: about USB HID report descriptor
« Reply #1 on: January 26, 2013, 09:49:10 pm »
Yes, you could make the short report an Input and/or Output report. The HID spec requires all HIDs to have an interrupt IN endpoint so you may as well use it.

The larger report could be an Input/Output report with a different report ID, but Feature reports work well for infrequent data.
« Last Edit: January 27, 2013, 09:16:26 am by Jan Axelson »

hristo

  • Member
  • ***
  • Posts: 3
Re: about USB HID report descriptor
« Reply #2 on: January 27, 2013, 04:25:07 am »
Thank You Jan, for this useful and fast answer.

Have a nice day.

hristo.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: about USB HID report descriptor
« Reply #3 on: January 27, 2013, 09:16:56 am »
See edited response above, doesn't change the basic advice.

hristo

  • Member
  • ***
  • Posts: 3
Re: about USB HID report descriptor
« Reply #4 on: January 27, 2013, 10:40:57 am »
V-USB configuration allows suppressing interrupt transfer despite USB
specification, and that way saves some bytes of device's flash memory.

I have enough flash memory in my disposition, so might be implementing
interrupt IN is the best choice. Unless if advantages of an interrupt IN
transfer are much more than those ones of a control transfer.

Sorry, I'm very new in USB communication.

Maybe I'll try it later, for now  I'm going to focus on basic functionality of my device.


Thank You again.

hristo.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: about USB HID report descriptor
« Reply #5 on: January 27, 2013, 12:23:22 pm »
Either will likely work for your application.