Usbendpointdescriptor – Comtrol eCos User Manual

Page 687

Advertising
background image

USB Enumeration Data

usb_endpoint_descriptor

The host also needs information about which endpoint should be used for what. This involves an array of endpoint
descriptors:

const usb_endpoint_descriptor usb_endpoints[] = {

{

length:

USB_ENDPOINT_DESCRIPTOR_LENGTH,

type:

USB_ENDPOINT_DESCRIPTOR_TYPE,

endpoint:

USB_ENDPOINT_DESCRIPTOR_ENDPOINT_OUT | 1,

attributes:

USB_ENDPOINT_DESCRIPTOR_ATTR_BULK,

max_packet_lo:

64,

max_packet_hi:

0,

interval:

0

},

{

length:

USB_ENDPOINT_DESCRIPTOR_LENGTH,

type:

USB_ENDPOINT_DESCRIPTOR_TYPE,

endpoint:

USB_ENDPOINT_DESCRIPTOR_ENDPOINT_IN | 2,

attributes:

USB_ENDPOINT_DESCRIPTOR_ATTR_BULK,

max_packet_lo:

64,

max_packet_hi:

0,

interval:

0

}

};

const usbs_enumeration_data usb_enum_data = {

...

total_number_endpoints:

2,

endpoints:

usb_endpoints,

...

};

As usual the values for the

length

and

type

fields are specified by the standard. The

endpoint

field gives both

the endpoint number and the direction, so in the above example endpoint 1 is used for OUT (host to peripheral)
transfers and endpoint 2 is used for IN (peripheral to host) transfers. The

attributes

field indicates the USB

protocol that should be used on this endpoint:

CONTROL

,

ISOCHRONOUS

,

BULK

or

INTERRUPT

. The

max_packet

field specifies the maximum size of a single USB packet. For bulk transfers this will typically be 64 bytes. For
isochronous transfers this can be up to 1023 bytes. For interrupt transfers it can be up to 64 bytes, although usually
a smaller value will be used. The

interval

field is ignored for control and bulk transfers. For isochronous

transfers it should be set to 1. For interrupt transfers it can be a value between 1 and 255, and indicates the number
of milliseconds between successive polling operations.

For USB peripherals involving multiple configurations or interfaces the array of endpoint descriptors should be
organized sequentially: first the endpoints corresponding to the first interface of the first configuration, then the
second interface in that configuration, and so on; then all the endpoints for all the interfaces in the second configu-
ration; etc.

583

Advertising