USB
  "too many initializers" compile error when using report ID in HID descriptor

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   "too many initializers" compile error when using report ID in HID descriptor
tosa
New Member
posted July 28, 2010 07:03 PM     Click Here to See the Profile for tosa   Click Here to Email tosa     Edit/Delete Message
Hi,

1) The following code gives "too many initializers" error. If I comment out the report IDs and change the descriptor length to 0x22 then is compiles okay. The descriptor length should be 0x26 when including the report IDs.

2)If report ID not used, I can still compile the code with any value for the descriptor length (although only using the correct length gives proper transactions over USB). Why don't I get a compile error?

Thanks!


code const device_descriptor DEVICEDESC =
{
18, // bLength
0x01, // bDescriptorType
0x1001, // bcdUSB USB 1.1 (01.10)
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
EP0_PACKET_SIZE, // bMaxPacketSize0
0xAA09, // idVendor 0x09AA
0x1920, // idProduct 0x2019
0x0000, // bcdDevice
0x01, // iManufacturer
0x02, // iProduct
0x00, // iSerialNumber
0x01 // bNumConfigurations
}; //end of DEVICEDESC

// From "USB Device Class Definition for Human Interface Devices (HID)".
// Section 7.1:
// "When a Get_Descriptor(Configuration) request is issued,
// it returns the Configuration descriptor, all Interface descriptors,
// all Endpoint descriptors, and the HID descriptor for each interface."
code const hid_configuration_descriptor HIDCONFIGDESC =
{

{ // configuration_descriptor hid_configuration_descriptor
0x09, // Length
0x02, // Type
0x2900, // Totallength (= 9+9+9+7+7) 0x0029; this is the sum of the length of all descriptors except the hid_report_descriptor
0x01, // NumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x80, // bmAttributes
0x20 // MaxPower (in 2mA units)
},

{ // interface_descriptor hid_interface_descriptor
0x09, // bLength
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x02, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x00, // bInterfaceSubClass
0x00, // bInterfaceProcotol
0x00 // iInterface
},

{ // class_descriptor hid_descriptor
0x09, // bLength
0x21, // bDescriptorType
0x0101, // bcdHID 1.01
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
// HID_REPORT_DESCRIPTOR_SIZE_LE // wItemLength (tot. len. of hid_report_descriptor; this includes the identifier byte - THIS IS DEPENDENT ON THE NUMBER OF REPORTS!) 0x6200
0x2200
},

// IN endpoint (mandatory for HID)
{ // endpoint_descriptor hid_endpoint_in_descriptor
0x07, // bLength
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
1 // bInterval
},

// OUT endpoint (optional for HID)
{ // endpoint_descriptor hid_endpoint_out_descriptor
0x07, // bLength
0x05, // bDescriptorType
0x01, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
1 // bInterval
}

};

code const hid_report_descriptor HIDREPORTDESC =
{
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
0x09, 0x01, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
// 7 bytes

0x85, 1,
0x95, 0x3F,
0x75, 0x08, // REPORT_SIZE (8)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x01, // USAGE (Vendor Usage 1)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
// 13 bytes min; 16 bytes max

0x85, 1,
0x95, 0x3F,
0x75, 0x08, // REPORT_SIZE (8)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x01, // USAGE (Vendor Usage 1)
0x81, 0x02, // INPUT (Data,Var,Abs)
// 13 bytes min; 16 bytes max

0xC0 // end Application Collection
//1 byte
};

IP: Logged

classics
Member
posted July 28, 2010 07:33 PM     Click Here to See the Profile for classics   Click Here to Email classics     Edit/Delete Message
What toolchain?

In Keil those should be marked 'const code' or they will be in RAM and code will be generated to fill the ram during the startup.a51 code.

IP: Logged

tosa
New Member
posted July 28, 2010 07:40 PM     Click Here to See the Profile for tosa   Click Here to Email tosa     Edit/Delete Message
I'm using the compiler defaults in Keil C51 (but variable location small or large gives same results).

Isn't my code marked 'code const', or is there someplace else that this needs to be done? 'const code' doesn't compile.

[This message has been edited by tosa (edited July 28, 2010).]

IP: Logged

Tsuneo
Member
posted July 29, 2010 08:21 AM     Click Here to See the Profile for Tsuneo   Click Here to Email Tsuneo     Edit/Delete Message
What is "hid_report_descriptor" definition?
Doesn't the definition have array size?

Tsuneo

IP: Logged

tosa
New Member
posted July 29, 2010 12:43 PM     Click Here to See the Profile for tosa   Click Here to Email tosa     Edit/Delete Message
Isn't the bold number the byte length of the HID report descriptor? So that should be 0x2200 or 0x2600, depending on whether or I use the report ID bytes or not?

{ // class_descriptor hid_descriptor
0x09, // bLength
0x21, // bDescriptorType
0x0101, // bcdHID 1.01
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
// HID_REPORT_DESCRIPTOR_SIZE_LE // wItemLength (tot. len. of hid_report_descriptor; this includes the identifier byte - THIS IS DEPENDENT ON THE NUMBER OF REPORTS!) 0x6200
0x2200
},

[This message has been edited by tosa (edited July 29, 2010).]

IP: Logged

tosa
New Member
posted July 29, 2010 04:52 PM     Click Here to See the Profile for tosa   Click Here to Email tosa     Edit/Delete Message
Found the problem...the array size was also being defined by the HID_REPORT_DESCRIPTOR_SIZE definition, which I didn't change. Thanks for your help!

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b