windowsusbdriverdevice-driver

Need to write driver for USB peripheral device?


I'm working on designing a USB peripheral which will occasionally connect to a Windows PC, and transfer a few KB of data in each direction. There will be a custom PC application that controls the data transfers, using a proprietary protocol (i.e. for the USB payloads).

I see at the following link that Microsoft describes how to write a driver for a USB device. But do I need one?

Developing Windows client drivers for USB devices

The PC application is the only application that we intend to know how to communicate with the device, so there's no need for a driver from an application sharing standpoint.

Can I just bake the custom protocol directly into the application, have the application speak "raw USB" to the device, and do without a separate driver?


Solution

  • "raw USB", no, you can't do that from an application.

    But because you control the device also, you can make it appear as one of the device classes for which Windows provides a device driver that's generic enough to do just about anything you want.

    Those device classes are HID (Human Interface Device) and "WinUSB". Of these, HID is cross-platform but more limited in capability, WinUSB allows high performance data transfers as well as interrupt endpoints.

    Instructions for setting up your device's string descriptors so that Windows automatically binds it to the WinUSB driver are on MSDN

    A WinUSB device is a Universal Serial Bus (USB) device whose firmware defines certain Microsoft operating system (OS) feature descriptors that report the compatible ID as "WINUSB".

    The purpose of a WinUSB device is to enable Windows to load Winusb.sys as the device's function driver without a custom INF file. For a WinUSB device, you are not required to distribute INF files for your device, making the driver installation process simple for end users.