Wednesday, 30 December 2015

USB composite device driver


I am wondering if it possible to create a USB device (in following the device) composed from




  • a custom circuit (eg arduino) and

  • a flash storage


in such a manner that the device is recognized as a standard usb flash storage (and as such is operable with standart OS drivers), while said storage holds the utilities to operate with the custom circuit (dispalying the data colled by the circuit); and if so, how?


My first thought was to smack a cheap usb-hub and usb-pen before my circuit but that solution, is not pleasing to me.


My goal is to eliminate the need to carry an extra flash-drive just for the operating software, and use default os drivers, make it plug-and-just-work:



  1. i plug the device in

  2. the os (windows) mounts a new flash-drive without needing a special driver

  3. is start (manually or via autorun) my custom.exe from that flash-drive


  4. i recive data measured by the circuit



Answer



Your first step is to find a USB microcontroller that has all the peripherals you need to accomplish your task.


The second step is to correctly set up your USB descriptors. The descriptors will tell the PC that your device is a composite device. I have not seen very much support for multiple configurations. So you will need one configuration descriptor.


Typically, composite devices are described by using multiple interface descriptors. So your one config descriptor will say it has 2 interface descriptors. The first interface descriptor will be for your Mass Storage Device. The second interface descriptor will be your custom interface.


EDIT: here's a couple links that might help you out with the descriptors. The USB Generic Parent Driver is what Windows uses to enumerate composite devices. Lots of good stuff here. http://msdn.microsoft.com/en-us/library/windows/hardware/ff539234%28v=vs.85%29.aspx


Here's a link to an Atmel app note which shows an example of a composite device. http://www.atmel.com/images/doc7805.pdf


Microchip has a free USB stack for their microcontrollers. It also contains examples for composite devices. Unfortunately, the link to the Microchip examples is the type that will likely change over the course of time, so your best bet is to google "Microchip Application Libraries"





With that said, you probably don't need a custom interface. If you're just passing around bytes, you can use standard HID drivers to transport your data to and from the device, no custom drivers necessary. However, host-side software will be required to use the OS-specified interface for reading/writing HID reports (in the case of Windows, this is usually ReadFile and WriteFile from the Windows API)


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...