Interface Selection Structures

Various structures are needed when you select a configuration. An array of USB_INTERFACE_LIST_ENTRY structures, shown in Table 21.7, is passed to USBD_CreateConfigurationRequestEx. The InterfaceDescriptor field points to the interface descriptor that you want enabled in the configuration. When the Select Configuration URB has completed, the Interface pointer is valid and refers to valid data.

Table 21.7 USB INTERFACE LIST ENTRY fields

InterfaceDescriptor Points to interface descriptor
Interface USB_INTERFACE_INFORMATION pointer

The Select Configuration URB fills a USB_INTERFACE_INFORMATION structure for each interface that it enables. Table 21.8 shows this structure, whose size increases as there are more pipes.

Table 21.8 USB INTERFACE INFORMATION fields

InterfaceNumber Interface number
AlternateSetting Alternate setting
Class Subclass Protocol USB class codes
NumberOfPipes Number of pipes
PipeInformation Array of USB_PIPE_INFORMATION structures

Table 21.9 shows the USB_PIPE_INFORMATION structure. All fields apart from MaximumTransferSize and PipeFlags fields are filled in by the Select Configuration URB.

Table 21.9 USB_PIPE INFORMATION fields

MaximumPacketSize Maximum packet size
EndpointAddress Endpoint number The top bit is set for input pipes.
Interval Polling interval in ms for Interrupt pipes
PipeType UsbdPipeTypeControl UsbdPipeTypeIsochronous UsbdPipeTypeBulk UsbdPipeTypeInterrupt
PipeHandle Handle for later USBDI calls
MaximumTransferSize Maximum transfer size
PipeFlags Flags

String Descriptor

A device may optionally provide string descriptors. Each string descriptor contains just one Unicode string, so the driver must request each string one by one. String index zero is special. Instead of a string, it contains a list of two-byte language ID codes. Language ID 0x0009 is usually used for generic English.

As has been seen, various other descriptors contain string index numbers. If these numbers are non-zero, there is an associated string. When you request a string descriptor using the GetDescriptor URB, you must specify both the string index and the language ID that you want.

A USB_STRING_DESCRIPTOR structure simply has one useful field, bString, that contains the Unicode string for which you asked. The maximum string length (MAXIMUM_USB_STRING_ LENGTH) is 255 characters. When you request string index zero, bString instead contains the supported language ID.

Isochronous Packet Descriptor

The USBD_ISO_PACKET_DESCRIPTOR structure is used to describe an isochronous transfer packet. An isochronous transfer request URB has a single transfer buffer that may contain several individual packets.

For writes, set the Offset field of each packet descriptor to indicate the offset into this buffer of this packet.

For reads, the packet descriptor Length field is filled with the number of bytes read and the Status field returns the status of this transfer packet.

USBDI URB Reference

URB Setup Functions

All these URBs use standard USB control transfers over the default pipe. I will later explain the details of how to set or clear features, or do class or vendor defined control transfers over the default pipe.

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату
×