Getting started with USB development
A Universal Serial Bus (USB) device defines its capabilities and features through configurations, interfaces, alternate settings, and endpoints. This topic provides a high-level overview of those concepts. For details, see the USB specifications at Universal Serial Bus Documents.
In this section
Topic | Description |
---|---|
USB device layout | A USB device defines its capabilities and features through configurations, interfaces, alternate settings, and endpoints. This topic provides a high-level overview of those concepts. |
Standard USB descriptors | A USB device provides information about itself in data structures called USB descriptors. This section provides information about device, configuration, interface, and endpoint descriptors and ways to retrieve them from a USB device. |
USB endpoints and their pipes | A USB device has endpoints that are used to for data transfers. On the host side, endpoints are represented by pipes. This topic differentiates between those two terms. |
USB in Windows - FAQ | This topic presents frequently asked questions for driver developers who are new to developing and integrating USB devices and drivers with Windows operating systems. |
Common USB scenarios
1—Get the device handle for communication and use the retrieved handle or object to send data transfers.
Client driver | UWP app | Windows desktop app |
---|---|---|
KMDF: WdfUsbTargetDeviceCreateWithParameters UMDF: IWDFUsbTargetDevice |
UsbDevice How to connect to a USB device |
WinUsb_Initialize Write a Windows desktop app based on the WinUSB template |
USB descriptor retrieval to get information about the device's configuration(s), interface(s), setting(s), and their endpoint(s).
2—Configure the device to select an active USB configuration and setting per interface.
Client driver | UWP app | Windows desktop app |
---|---|---|
KMDF: WdfUsbTargetDeviceSelectConfig WdfUsbTargetDeviceCreateUrb USBD_SelectConfigUrbAllocateAndBuild WdfUsbInterfaceSelectSetting How to select a configuration for a USB device. How to select an alternate setting in a USB interface. UMDF: Configuration selection is not supported IWDFUsbInterface::SelectSetting |
UsbInterfaceSetting.SelectSettingAsync How to select a USB interface setting |
WinUsb_SetCurrentAlternateSetting |
3—Send control transfers for configuring the device and performing vendor commands that are specific to particular device.
4—Send bulk transfers, typically used by mass storage devices that transfer large amount of data.
5—Send interrupt transfers. Data is read to retrieve hardware interrupt data.
Client driver | UWP app | Windows desktop app |
---|---|---|
Same as bulk transfers | UsbInterruptInPipe.DataReceived UsbInterruptOutPipe.OutputStream How to send a USB interrupt transfer request |
Same as bulk transfers |
6—Send isochronous transfers, mostly used for media streaming devices.
7—USB selective suspend to allow the device to enter a low power state and bring the device back to working state.
Client driver | UWP app | Windows desktop app |
---|---|---|
KMDF: WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS WdfDeviceAssignS0IdleSettings UMDF: IWDFUsbTargetDevice::SetPowerPolicy IWDFDevice2::AssignS0IdleSettings IWDFDevice3::AssignS0IdleSettingsEx How to send a device to selective suspend |
Not supported | WinUsb_SetPowerPolicy WinUSB Power Management |