This section provides code samples and guidance for developing USB (Universal Serial Bus) drivers and applications for Windows. Explore the resources below to understand and implement USB functionality on your hardware.
Understanding the USB architecture and the Windows Driver Model (WDM) or Windows Driver Frameworks (WDF) is crucial for successful USB development. These samples illustrate common tasks and concepts.
Demonstrates how to enumerate and communicate with a generic USB device using WDF. Covers basic read/write operations and device information retrieval.
Learn More | Download SampleA reference implementation for a USB Audio Class driver, showcasing how to handle audio streams and device configurations.
Learn More | Download SampleProvides an example of creating a driver for a USB HID device, commonly used for keyboards, mice, and game controllers.
Learn More | Download SampleIllustrates the implementation of a USB Mass Storage Class driver, enabling devices like USB drives to be recognized by the operating system.
Learn More | Download SampleA user-mode application sample that demonstrates how to capture video streams from a USB Video Class device.
Learn More | Download SampleThis sample focuses on the core functionality of interacting with USB devices in user mode or kernel mode using the Windows Driver Frameworks. It includes:
// Example snippet (illustrative, not fully functional)
NTSTATUS
UsbdSample_ConfigureDevice(
_In_ WDFUSBDEVICE UsbDevice
)
{
NTSTATUS status;
WDF_USB_DEVICE_CREATE_CONFIG config;
WDF_USB_DEVICE_CREATE_CONFIG_INIT(&config,
WdfUsbDesignatorTypeVendorDefined,
0,
0); // Replace with actual configuration
status = WdfUsbTargetDeviceCreateWithParameters(
UsbDevice,
&config,
WDF_NO_OBJECT_ATTRIBUTES,
WDF_NO_HANDLE // pUsbTargetDevice
);
if (!NT_SUCCESS(status)) {
// Handle error
return status;
}
// ... Further configuration and pipe handling ...
return STATUS_SUCCESS;
}
This sample provides a template for drivers that handle USB audio devices. Key features include:
Develop drivers for HID-compliant devices. This sample covers:
Implement drivers for devices that emulate USB Mass Storage Class devices. This sample demonstrates:
This user-mode sample application allows you to test and interact with UVC-compliant cameras.