Usbdevicedescriptor – Comtrol eCos User Manual

Page 684

Advertising
background image

USB Enumeration Data

};

int

main(int argc, char** argv)

{

usbs_sa11x0_ep0.enumeration_data = &usb_enum_data;

...

usbs_start(&usbs_sa11x0_ep0);

...

}

For most applications the enumeration data will be static, although the usbs_enumeration_data structure can be
filled in at run-time if necessary. Full details of the enumeration data can be found in the Universal Serial Bus
specification obtainable from the USB Implementers Forum web site (http://www.usb.org/), although the meaning
of most fields is fairly obvious. The various data structures and utility macros are defined in the header files

cyg/io/usb/usb.h

and

cyg/io/usb/usbs.h

. Note that the example code below makes use of the gcc labelled

element extension.

usb_device_descriptor

The main information about a USB peripheral comes from a single usb_device_descriptor structure, which is
embedded in the usbs_enumeration_data structure. A typical example might look like this:

const usbs_enumeration_data usb_enum_data = {

{

length:

USB_DEVICE_DESCRIPTOR_LENGTH,

type:

USB_DEVICE_DESCRIPTOR_TYPE,

usb_spec_lo:

USB_DEVICE_DESCRIPTOR_USB11_LO,

usb_spec_hi:

USB_DEVICE_DESCRIPTOR_USB11_HI,

device_class:

USB_DEVICE_DESCRIPTOR_CLASS_VENDOR,

device_subclass:

USB_DEVICE_DESCRIPTOR_SUBCLASS_VENDOR,

device_protocol:

USB_DEVICE_DESCRIPTOR_PROTOCOL_VENDOR,

max_packet_size:

8,

vendor_lo:

0x42,

vendor_hi:

0x42,

product_lo:

0x42,

product_hi:

0x42,

device_lo:

0x00,

device_hi:

0x01,

manufacturer_str:

1,

product_str:

2,

serial_number_str:

0,

number_configurations:

1

},

...

};

The length and type fields are specified by the USB standard. The

usb_spec_lo

and

usb_spec_hi

fields

identify the particular revision of the standard that the peripheral implements, for example revision 1.1.

The device class, subclass, and protocol fields are used by generic host-side USB software to determine which host-
side device driver should be loaded to interact with the peripheral. A number of standard classes are defined, for

580

Advertising