Custom USB devices (Part 2)

For those trying to decide how to start off with custom USB devices, here's what I think of the main ways you can go....

1 - CDC
This is a serial port emulator. Its a simple way of attaching a USB device and making it look like a normal COM port

Good:
Simple for beginners to understand, you can ignore most of the USB part entirely and pretend you're still running an old style serial port.

Bad:
Great if you're making something that has an ASCII command terminal....otherwise its a bit of a bodge. USB is designed to do far more than COM ports were so your device might be inefficient, Also it will not appear nicely as "My Funky Device" in the device manager, it'll just come up as a new COM port. Personally I'd ditch this for most devices

2 - HID
This is a standard was of talking to generic devices like keyboards and mice. It can be used to attach just about anything you like though and supports most of the USB transfer types such as 'bulk' and 'interrupt'

Good:
Doesn't need a driver as its built in to all new versions of windows

Bad:
Might be a bit restrictive, especially when it comes to displaying things in device manager (I haven't found a way to name them nicely yet). When I attached 24 HID devices (same VID_PID combination, uniquely serial numbered) it all went horribly wrong, most of them didn't come up then my PC crashed

3 - Custom Driver
This is a driver (.sys and .inf) that is either made by you or supplied by a 3rd party. I used the Microchip USB driver for most of our products

Good:
No bodges are involved here, you can write everything in the way you want and my mass USB test worked a lot better than with HID. Modifying the .inf file lets your device appear nicely in the device manager.

Bad:
Modifying a .inf file will break any driver signing you have and that means a trip to through the WHQL process unless you want warnings every time your users install the driver (never done this myself yet). 3rd party drivers may hove bugs or issues that you can't get fixed. Writing the driver yourself looks pretty hard

4 - WinUsb
This is a newer option. WinUsb is a 'generic' driver from Microsoft. It comes with Vista and can be distributed easily for XP. Really it's like option 3 but loads of people use it and is should be fairly well supported.

Good:
Rapidly becoming a standard way of running USB, can display your devices nicely in device manager, lots of help in news groups etc to help you out. No need to distribute or write your own driver. You can probably switch to this from option 3 without any changes to your firmware

Bad:
Still need WHQL to sign your modified .inf file

Comments

Popular posts from this blog

JTAG Progromming on a PIC

Using Plink.exe from C# (accessing a linux PC)

Evohome problems on Danfoss RAS-C2 valves