Usbinterfacedescriptor – Comtrol eCos User Manual

Page 686

Advertising
background image

USB Enumeration Data

calculate this: the first argument to the macros specify the number of interfaces, the second the number of end-
points. The

number_interfaces

field is self-explanatory. If the peripheral involves multiple configurations

then each one must have a unique id, and this will be used in the set-configuration control message. The id

0

is

reserved, and a set-configuration control message that uses this id indicates that the peripheral should be inactive.
Configurations can have a string description if required. The

attributes

field must have the

REQUIRED

bit set;

the

SELF_POWERED

bit informs the host that the peripheral has its own power supply and will not draw any power

over the bus, leaving more bus power available to other peripherals; the

REMOTE_WAKEUP

bit is used if the periph-

eral can interrupt the host when the latter is in power-saving mode. For peripherals that are not self-powered, the

max_power

field specifies the power requirements in units of 2mA.

usb_interface_descriptor

A USB configuration involves one or more interfaces, typically corresponding to different streams of data. For
example, one interface might involve video data while another interface is for audio. Multiple interfaces in a single
configuration will be active at the same time.

const usb_interface_descriptor usb_interface = {

length:

USB_INTERFACE_DESCRIPTOR_LENGTH,

type:

USB_INTERFACE_DESCRIPTOR_TYPE,

interface_id:

0,

alternate_setting:

0,

number_endpoints:

2,

interface_class:

USB_INTERFACE_DESCRIPTOR_CLASS_VENDOR,

interface_subclass: USB_INTERFACE_DESCRIPTOR_SUBCLASS_VENDOR,

interface_protocol: USB_INTERFACE_DESCRIPTOR_PROTOCOL_VENDOR,

interface_str:

0

};

const usbs_enumeration_data usb_enum_data = {

...

total_number_interfaces:

1,

interfaces:

&usb_interface,

...

};

Again, the

length

and

type

fields are specified by the standard. Each interface within a configuration requires

its own id. However, a given interface may have several alternate settings, in other words entries in the interfaces
array with the same id but different

alternate_setting

fields. For example, there might be one setting which

requires a bandwidth of 100K/s and another setting that only needs 50K/s. The host can use the standard set-
interface control message to choose the most appropriate setting. The handling of this request is the responsibility
of higher-level code, so the application may have to

install

its own handler.

The number of endpoints used by an interface is specified in the

number_endpoints

field. Exact details of

which endpoints are used is held in a separate array of endpoint descriptors. The class, subclass and protocol fields
are used by host-side code to determine which host-side device driver should handle this specific interface. Usually
this is determined on a per-peripheral basis in the usb_device_descriptor structure, but that can defer the details to
individual interfaces. A per-interface string is allowed as well.

For USB peripherals involving multiple configurations, the array of usb_interface_descriptor structures should first
contain all the interfaces for the first configuration, then all the interfaces for the second configuration, and so on.

582

Advertising