AT91 USB Composite Driver Implementation
AT91 USB Composite Driver Implementation
1. Introduction The USB Composite Device is a general way to integrate two or more functions into one single device.
It is defined in the USB Specification Revision 2.0, as "A device that has multiple interfaces controlled independently of each other".
This document introduces basics for USB composite device and gives examples to implement the composite device
that has two functions included, based on the Atmel® AT91 SAM Softpack for its ARM® Thumb® based microcontrollers.
To add more than one functions to the host via one USB port, the USB composite device works.
The available functions are listed as following:
• MSD: To extend hard disk storage capacity.
• HID: USB mouse, USB keyboard, Game controller ...
• Audio: USB Speaker or Recorder for host.
• CDC: To work as virtual COM port, modems or networking devices such as ADSL or Cable modem.
For more detailed information, please refer to the Application Notes of the class related device implementations.
Normally when you use USB functions, you will need one USB cable for each function, which means when you use several functions, many cables are needed.
The composite device helps to reduce the number of cables used at the same time.
This Application Note details the following composite solutions:
• HID + MSD: Adds keys, navigation pads or even handwrite pad with a storage disk.
• HID + Audio: Integrates game controller with Audio codec.
• CDC + MSD: Add more serial ports or modems when extending the storage of your laptop.
• CDC + Audio: Modem and an audio speaker at the same time. Or extend your serial port when you are playing music.
• CDC + HID: Extends the interface mostly for laptops, which allows extra serial port and mouse/keyboard.
• CDC + CDC: To extends two or more serial ports through one single USB cable, mostly for laptop.
Note that the composite device has several functions that work concurrently.
The host can see all of these functions available simultaneously.
Some of the cellphones that can manually select their connection types as “Modem” or “USB Disk”
is just product with two different USB devices pre-selected and not “composite” one.
3. USB Composite Device Basics
3.1 Purpose The Universal Serial Bus (USB) offers an easy way to connect PC with portable devices and to expand external peripherals.
Usually a USB device provides a single function to the host,
such as a storage disk, serial RS-232 port, digital microphone, or speakers, so one function occupies one USB port.
Nevertheless, to allow several functions through a single physical port, the USB specification mentions two kinds of devices:
• Composite device: a device has multiple logical interfaces controlled independently of each other.
A single physical logical address is used for the device.
• Compound device: a separate hub with multiple functions attached.
Composite devices are an efficient solution to reduce the number of hub and USB cables.
To give an example:
a device being at the same time modem and audio speaker requires only a single USB cable.
3.2 Architecture
3.2.1 Communication flow
Figure 3-3 highlights logical communication flows between several clients (host side) and functions (device side),
over a single physical USB connection.
The highlighted layer is the function layer. In host side, there is some client software that can operate with the different functions in the same physical device simultaneously. E.g. when a composite device with card reader and printing function is connected to a PC, a new printer device and storage disks may appear for you to explore your pictures on your media card, and to print them with the printer.
3.2.2 Interfaces Interface descriptors for composite devices correspond to the concatenation of interfaces descriptors defined for each functions available in the system.
E.g., a composite with HID+CDC needs three interface descriptors (Section 4.7.3 on page 15), while HID+MSD (Section 4.7.1 on page 13) only needs two.
There are some general rules to assemble the interfaces:
• bInterfaceNumber should start from zero and then increase by one;
• the interfaces that use the same function should be placed together, that is, the values of bInterfaceNumber should be contiguous;
• if two or more interfaces are associated to one device function (such as CDC), the Interface Association Descriptor (IAD) is used,
please refer to Section 3.2.4.1 on page 6 for more details.
3.2.2.1 Composite with SINGLE-interface functions
This kind of composite device includes the functions that have only one interface, such as HID+MSD.
The default endpoint (endpoint 0) is shared by all functions.
Each function has one interface only, to handle class-specific requests, control commands and data.
The interface and endpoint settings are function specific.
Figure 3-1. USB Composite Device with SINGLE-interface-functions

3.2.2.2 Composite with MULTI-interface functions
This kind of composite device includes the functions that are composed of more than one interface,
such as CDC class function, Audio Class function, etc..
The default endpoint (endpoint 0) is usually shared by single-interface-function and the control interface of the multi-interface-function.
There may be other endpoints such as an interrupt IN endpoint for CDC in the control interface for the function to accept control commands or update status.
The interface and endpoint settings are function specific.
The multi-interface function also needs a Interface Association Descriptor (IAD, See Section 3.2.4.1 on page 6) to associate its interfaces.
Figure 3-2. USB Composite Device with MULTI-interface-functions

3.2.3 Endpoints
Excluding the default endpoint, composite devices shall declare a number of endpoints equal to the sum of the number of endpoint required for individual function.
E.g., a composite with HID+CDC needs six endpoint descriptors (Section 4.7.3 on page 15), while HID+MSD (Section 4.7.1 on page 13) only needs five.
Endpoint 0 (default endpoint) is used for standard, class-specific and vendor-specific requests, depending on the implementation of the functions inside.
It can be used to operate on any interface for any device function.
The other endpoints are function-specific, their usage is defined by the class of the function or defined by the vendor.
Figure 3-1 and Figure 3-2 are examples for the composite device architecture with two device functions.
Figure 3-3. USB composite composition

3.2.3.1 Interface & Endpoints compositions for AT91 chip
Since the number of endpoints and the endpoint fifo size is based on hardware,
the assignment of the endpoints should be arranged carefully.
Here are some examples on the endpoint allocation for AT91SAM7SE chip,
since it has 7 endpoints to use.
Please refer to the AT91SAM product datasheet to get the number and the size of endpoints.
Generally, ISO endpoints should be considered firstly, because they always require large FIFO size and double buffer;
the BULK endpoints come the second, which only require a double buffer with transfer speed considered;
the last ones are the Interrupt endpoints, which only require a small FIFO and the lowest speed.
Please refer to the Ping-pong mechanism in the USB device section of the AT91SAM product datasheet.
• HID: For HID device function, only two interrupt endpoints are needed, and since the size is small and speed is low, its endpoints are considered as the lowest priority.
• MSD: For MSD device function, the high speed transaction, two endpoints, bulk transfer, double/triple bank for performance.
• Audio: For Audio device function, the endpoint size should be larger than the audio frame size (here the size is 192 bytes),
more than one endpoint, isochronous transfer and at least double bank.
• CDC: CDC needs three endpoints excluding the default endpoint to work.
Two Bulk endpoints and one Interrupt endpoint. So dual-CDC device will occupy 7 endpoints.
The interrupt endpoints can be assigned to single-buffered endpoints.
3.2.3.2 Composite Composition Summary
The following is a summary of the interfaces and endpoints assigned.
You can also find reference descriptions and figures in the following sections.
Table 3-1. Interfaces and Endpoints assignments Summary

3.2.4 Specific Descriptors
Since the composite is not for specific class, most of the descriptors for functions are defined in the included class related specifications.
Only one descriptor is necessary to define a multi-interface function:
the Interface Association Descriptor (IAD).
3.2.4.1 Interface Association Descriptor
The Interface Association Descriptor (IAD) is a new standard descriptor defined in USB Engineering Change Notice,
to allow a device to describe which interfaces are associated with the same device function.
This allows the Operation System to bind all of the appropriate interfaces to the same driver instance for the function.
Please see USB ENGINEERING CHANGE NOTICE (Title: Interface Association Descriptors) for detailed information.
The IAD is used to describe that two or more interfaces are associated to the same function.
The ‘association’ includes two or more interfaces and all of their alternative setting interfaces.
A device must use an IAD for each multi-interfaced device function.
An IAD is always returned as part of the configuration information returned by a GetConfigurationDescriptor request.
It must be located before the interface descriptors (including all alternate settings) for the interfaces it associates with.
All of the interface numbers in a particular set of associated interfaces must be contiguous.
Table 3-2 shows the standard interface association descriptor includes function

3.2.5 Specific Requests
No special request is used for a composite device, all requests are defined by the device function that is integrated.
3.3 Host Drivers
Usually the Operating System supports the composite device via two part of drivers - composite driver and the function drivers depending
on the functions that are integrated.
The OS will recognize the USB device as a composite device first then distinguish the included functions and install their driver modules one by one.
Then the functions will appear as normal separated devices for OS to access.
Most OSs now include generic drivers for a wide variety of USB classes.
This makes developing a function device simpler, since the host complexity is now handled by the OS.
Manufacturers can thus concentrate on the device itself, not on developing specific host drivers.
As described before in Section 3.2.4.1 note, the IAD of multi-interface USB devices is a new feature,
there may be issues about how existing USB OS implementations will support devices with IAD.
For Linux®, it is supported now.
For Windows you can refer to Support for USB Interface Association Descriptor in Windows, but patches may needed,
only Windows XP with some hot fix or service pack 3 or later updates fully support this feature now.
Here is a brief list of the various function implementations supported by several OSs
(for CDC maybe additional .inf file is required to install the device but the driver files themselves are from windows source disk):
• Windows (see Windows Supported USB Classes for more)
– MSD: USB Storage disks
– HID: USB Keyboard, Mouse, etc.
– Audio: USB Desktop speaker, recorder.
– CDC: Abstract Control Model, Remote NDIS ...
• Linux (see Linux Device Driver Support for more)
– MSD: USB Storage disks
– HID: USB Keyboard, Mouse, etc.
– CDC: Abstract Control Model
– CDC: Ethernet Model Please refer to the sections about the functions or the class implement application notes for details about the OS compatibility on the device driver.






AT91 USB Composite Driver Implementation的更多相关文章
- USB Compound Device,USB复合设备 ; USB Composite Device,USB组合设备【转】
本文转载自:https://blog.csdn.net/autumn20080101/article/details/52776863 科普下USB复合设备和USB组合设备的区别. 关键字 Commu ...
- usb wifi driver run in ubuntu support 360/xiaodu and with 3.13.0-32-generic
(为了实现usb-wifi用在linux系统上,需求解决方案,过程记录和如何实现) 重点解决3.13.0-32-generic内核编译 mt7601 usb wifi 驱动问题. 1:首先下载MT76 ...
- Security arrangements for extended USB protocol stack of a USB host system
Security arrangements for a universal serial bus (USB) protocol stack of a USB host system are provi ...
- STM32F4 HAL Composite USB Device Example : CDC + MSC
STM32F4 USB Composite CDC + MSC I'm in the process of building a USB composite CDC + MSC device on t ...
- USB组合设备 Interface Association Descriptor (IAD)
Communication Device Class,简称CDCUSB Compound Device,USB复合设备USB Composite Device,USB组合设备 摘要USB复合设备 Co ...
- [置顶] 自娱自乐6之Linux gadget驱动5(自编gadget驱动,包涵与之通讯的主机usb驱动,已调试通过)
这个代码调试,你首先要保证你的udc驱动没用问题,这个有些矛盾,应为我本来要用gadget驱动来调试udc驱动,结果反过来了. 这是在zero基础改的,大概的改动 1. 去掉loop. 2. sink ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
- Linux下usb设备驱动详解
USB驱动分为两块,一块是USB的bus驱动,这个东西,Linux内核已经做好了,我们可以不管,我们只需要了解它的功能.形象的说,USB的bus驱动相当于铺出一条路来,让所有的信息都可以通过这条USB ...
- android的USB MTP && USB CDC/USBnet(ECM, NCM, ACM) && USB gardget
MTP的全称是Media Transfer Protocol(媒体传输协议),它是微软公司提出的一套媒体文件传输协议.早在智能手机普及前,数码相机和MP3播放器等都使用了MTP的前身PTP(Pictu ...
随机推荐
- Python 入门基础12 --函数基础5 匿名函数、内置函数
今日内容: 1.三元表达式 2.列表.元组生成式 | 字典生成式 3.递归 4.匿名函数 5.内置函数 一.三元表达式 三元运算符:就是 if...else... 语法糖 前提:if 和 else # ...
- 解决“tar:Exiting with failure status due to previous errors”【转】
问题: 当我想试着用tar命令来创建一个压缩文件时,总在执行过程中失败,并且抛出一个错误说明"tar:由于前一个错误导致于失败状态中退出"("Exiting with f ...
- 002_tmux详解
参考下赖老师的: http://mingxinglai.com/cn/2012/09/tmux/ 一. 二. http://wdxtub.com/2016/03/30/tmux-guide/ (待 ...
- Java实现继承过程概述
super(); 在调用子类的构造器的时候,如果没有显示的写出 super(); ,那么,编译器会在佛那个加上 super(); 无参构造器 如果想调用父类的有参构造器,那么,必须显示的调用,编译器不 ...
- JavaEE-案例1-网站信息展示
案例1-网站信息展示 需求: 在页面上展示一些文字信息,需要排版. 技术分析: html:超文本 标签 语言 作用:展示 超文本:超越了一般文本,描述文本的字体.颜色.图片 标签:标记 html书写规 ...
- linux进程的一些日常处理
linux 下查看一个进程运行路径的方法 在linux下查看进程大家都会想到用 ps -ef|grep XXX 可是看到的不是全路径,怎么看全路径呢? 每个进程启动之后在 /proc下面有一个于pid ...
- nginx支持ssl双向认证配置
nginx支持ssl双向认证配置 listen 443; server_name test.com; ssl on; ssl_certificate server.crt; //server端公钥 s ...
- 入门NodeJS
入门NodeJS https://www.cnblogs.com/dotnetcrazy/p/10118756.html NodeJS 1.环境配置 之前讲ES6的时候有提过一部分Node的知识,简单 ...
- bzoj 1185
题目大意: 给你n个点求最小矩形覆盖. 思路:枚举凸包上的边然后,旋转卡壳找三个相应的为止把矩形的四个点求出来. #include<bits/stdc++.h> #define LL lo ...
- vs2010 打包安装
https://jingyan.baidu.com/article/b7001fe184e4e50e7382dd4e.html 1 建立安装项目2 要安装的文件都添加到应用程序文件夹3 在应用程序文件 ...