Working with USB Interfaces

The framework represents each USB interface as a framework USB interface object. When a driver creates a framework USB device object, the framework creates a framework USB interface object for each USB interface that the device's first USB configuration contains.

Most USB devices have only one interface, and the interface has only one alternate setting. Drivers for such devices typically do not need to use the object methods that the framework's USB interface object defines.

If your driver supports USB devices that provide multiple interfaces or alternate settings, interface object methods enable the driver to perform the following operations:

Obtaining Interface Information

After your driver has called WdfUsbTargetDeviceCreateWithParameters, it can call WdfUsbTargetDeviceGetInterface to obtain a handle to a framework USB interface object that represents one of the device's USB interfaces. Then your driver can call several methods that the USB interface object defines for obtaining information about the USB interface.

Your driver can call the following methods anytime after it has called WdfUsbTargetDeviceCreateWithParameters:

WdfUsbInterfaceGetInterfaceNumber

Returns the USB interface number that is associated with a USB interface object.

WdfUsbInterfaceGetDescriptor

Retrieves that USB interface descriptor that is associated with one of the alternate settings of a USB interface.

WdfUsbInterfaceGetNumEndpoints

Returns the number of endpoints that are associated with one of the alternate settings of a USB interface.

WdfUsbInterfaceGetEndpointInformation

Retrieves information about an endpoint and its associated pipe.

Your driver can call the following methods after it has called WdfUsbTargetDeviceSelectConfig:

WdfUsbInterfaceGetConfiguredSettingIndex

Returns an index value that identifies the alternate setting that is currently selected for a USB interface.

WdfUsbInterfaceGetNumConfiguredPipes

Returns the number of pipes that are configured for a specified USB device interface.

WdfUsbInterfaceGetConfiguredPipe

Returns a handle to the framework pipe object that is associated with a specified USB device interface and pipe index.

Selecting an Alternate Setting for a USB Interface

After a driver has called WdfUsbTargetDeviceCreateWithParameters, the driver can call WdfUsbInterfaceGetNumSettings to obtain the number of alternate settings that a USB interface supports.

After a driver has called WdfUsbTargetDeviceSelectConfig to select a configuration for a USB device, the driver can call WdfUsbInterfaceSelectSetting to select an alternate setting for one of the configuration's USB interfaces.

The device's alternate settings must be numbered contiguously, starting with zero.

For related information, see How to select an alternate setting in a USB interface.

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.