Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 927
cp.engr Avatar asked Jul 22 '16 15:07

cp.engr


People also ask

Do you need drivers for USB?

Yes, a compatible driver is required for USB 3.0 SuperSpeed products such as Flash Drives and Card Readers. This should be included by the manufacturer of the PC or laptop, motherboard or add-in (PCI) card that has the USB 3.0 ports.

When should you write a device driver?

A printer, a scanner, a webcam, a storage controller etc. You want to write a device driver so that generic applications can talk to your device without having to modify the applications.

Which driver is responsible for USB port?

The USB function client driver is responsible for implementing controller-specific operations. These include implementing endpoint data transfers, USB device state changes (reset, suspend, resume), attach/detach detection, port/charger detection.


1 Answers

"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.

like image 97
Ben Voigt Avatar answered Sep 28 '22 14:09

Ben Voigt