Combining USB Interfaces/Add-ons
Combining interfaces is nowadays a very important feature and is being used in a multitude of USB devices such as multi-function printers, smartphones, tablets, modems and data loggers.
What are the Advantages of a multi interface?
Allows to have different or even multiple instances of the same interfaces combined in one device.
A smartphone can have an interface for controlling the smartphone itself, an additional one for data transfer and one that allows to access to the modem of the phone to connect to the Internet.Having a device with multiple interfaces allows the user to simultaneously access his device in different ways. For example MSD or VirtualMSD can be used for firmware update or making log files available while using a host application that communicates with the device via Bulk or CDC-ACM.
J-Link is a great example for this. Different J-Link models do not only have access to the debug interface, they can also communicate via CDC-ACM with the target MCU's UART. VirtualMSD is used to update the application of the debug target MCU. Or you can access the Webserver on the J-Link via IP-over-USB in order to configure the J-Link.
Why do I have to do either?
- Enhances the customer's user experience.
- Increases the value of the USB device.
- Nowadays devices have to support different protocols or tasks. Those can be realized by using different emUSB-Device interfaces.
- Migrate an IP-based protocol to an existing USB device.
Using multi-interface with emUSB-Device
Combining different add-ons or USB classes with emUSB-Device is quite easy. Simply sequentially call the dedicated *_Add() function of the add-on.
For example adding a multi-interface device with HID and MSD enabled looks like the following:
void MainTask(void) {
USBD_Init();
_PrepareUSBInitData();
USBD_HID_Add(&_HidInitData);
USBD_MSD_Add(&_MsdInitData);
USBD_MSD_AddUnit(&_MsdUnitData);
USBD_SetDeviceInfo(&_DeviceInfo);
USBD_Start();
//CreateTasks for USB Interface for handling dedicated interfaces
[...]
}
This will make sure that all interfaces will be added to the stack. emUSB-Device will then handle the enumeration of the device and will provide the descriptors automatically to the host.
Please note that for special add-ons/USB classes a special call is needed before the dedicated *_Add() function is called. A call of USBD_EnabledIAD()
is needed before calling any *_Add() function.
The following add-on/USB classes need this call:
- CDC-ACM
- IP-over-USB
- CDC-ECM
- RNDIS
Limitation
To use multi-interface with a USB device it must be verified that the desired USB device controller has enough endpoints to support all interfaces/classes.
Furthermore we have experienced that there is an issue with some add-ons/USB classes when used with multi-interface. This error only shows up when using Windows 7 and third party USB 3.0 host controller drivers. These add-ons/USB classes make use of the "MS OS Descriptor" feature. This feature facilitates these add-ons by not providing a driver installation for Windows.
Building a multi-interface device with the mentioned add-ons shows that the device is not enumerated properly as the USB Host 3.0 drivers do not properly pass the MS OS descriptor information to Windows. As a result of this the device is not enumerated as a "Composite Device". It is rather enumerated as a single interface device. Normally the interface which is described by the MS OS Descriptor.
The following add-ons are affected by this issues:
A special tool, the Composite Device Driver Fixer, can be downloaded from our website free of charge to fix this Windows issue.