Electronic – USB descriptor tool

usb

Could anyone recommend any Wizard-like tool for creating USB device descriptors?

Most (all?) USB firmware examples I've so far looked into define the descriptors as simple byte array in .c file, filled manually (with a little help from macros).

It's not a black magic, obviously, still I believe that a simple specialized tool could be useful. Googling for it gave no useful results, however…

Best Answer

A wizard-like tool may be cute the first time you use it, but then it gets in the way. A better method is a decent structure of the descriptors in memory, and a few helpful macros and other preprocessing logic so that you can supply the information at a higher level and the right bytes and bits automatically get filled in.

My USB stack for the PIC 18 works like that. You can install that and a bunch of other stuff from my software downloads page. The static USB setup is defined in two files. The templates for these are named QQQ_USB.INS.ASPIC and QQQ_USB0.INS.ASPIC in the SOURCE > PIC directory. First you define the VID/PID, which endpoints you use, and which transfer types per endpoint in the usb.ins.aspic file. Then you modify the descriptors in usb0.ins.aspic with the little bit you need to customize. Since it already knows things like the transfer types and buffer sizes, you leave those symbols alone and just change what's unique to your implementation. In most cases, that's only adjusting the manufacturer name and the product name. These you write as ordinary strings and a macro takes care of the proper formatting.