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的更多相关文章

  1. USB Compound Device,USB复合设备 ; USB Composite Device,USB组合设备【转】

    本文转载自:https://blog.csdn.net/autumn20080101/article/details/52776863 科普下USB复合设备和USB组合设备的区别. 关键字 Commu ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. USB组合设备 Interface Association Descriptor (IAD)

    Communication Device Class,简称CDCUSB Compound Device,USB复合设备USB Composite Device,USB组合设备 摘要USB复合设备 Co ...

  6. [置顶] 自娱自乐6之Linux gadget驱动5(自编gadget驱动,包涵与之通讯的主机usb驱动,已调试通过)

    这个代码调试,你首先要保证你的udc驱动没用问题,这个有些矛盾,应为我本来要用gadget驱动来调试udc驱动,结果反过来了. 这是在zero基础改的,大概的改动 1. 去掉loop. 2. sink ...

  7. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

  8. Linux下usb设备驱动详解

    USB驱动分为两块,一块是USB的bus驱动,这个东西,Linux内核已经做好了,我们可以不管,我们只需要了解它的功能.形象的说,USB的bus驱动相当于铺出一条路来,让所有的信息都可以通过这条USB ...

  9. android的USB MTP && USB CDC/USBnet(ECM, NCM, ACM) && USB gardget

    MTP的全称是Media Transfer Protocol(媒体传输协议),它是微软公司提出的一套媒体文件传输协议.早在智能手机普及前,数码相机和MP3播放器等都使用了MTP的前身PTP(Pictu ...

随机推荐

  1. alert换行警示

    alert("再次向您问好!在这里,我们向您演示" + '\n' + "如何向警告框添加折行.")

  2. HDU 1176 免费馅饼 DP类似数塔题

    解题报告: 小明走在一条小路上,这条小路的长度是10米,从左到右依次是0到10一共十个点,现在天上会掉馅饼,给出馅饼掉落的坐标和时间,一开始小明的位置是在坐标为5的位置, 他每秒钟只能移动一米的距离, ...

  3. Chrome插件笔记之content_scripts

    一.概论 说这个之前先看一个段子,讲的是甲方有一奇葩客户,这客户看一网站某些样式很别扭不得劲,非要让乙方修改,乍一听没毛病,但关键是这网站不是乙方家的,根本没有修改权限,怎么办,客户就是上帝,上帝的要 ...

  4. 服务器环境配置安装(mysql+redis+nodejs+nginx)

    公司用来测试的服务器挂了,最后重装了系统,需要重新配置程序运行环境,linux上安装不是很熟悉,特此记录一下. 首先获取系统版本信息: 参考:获取Linux系统版本信息 一.mysql 1. 安装 安 ...

  5. F. Ivan and Burgers(线性基,离线)

    题目链接:http://codeforces.com/contest/1100/problem/F 题目大意:首先输入n,代表当前有n个数,然后再输入m,代表m次询问,每一次询问是询问区间[l,r], ...

  6. zabbix3.0配置服务器流量告警

    zabbix配置流量告警 zabbix虽然已经对服务器的网卡流量进行了监控,但为了防止某台机器流量过高导致网络慢,或者因为中病毒或木马等原因,导致流量很高,可使用zabbix的流量告警功能来对流量进行 ...

  7. jquery实现模拟select下拉框效果

    <IGNORE_JS_OP style="WORD-WRAP: break-word"> <!DOCTYPE html PUBLIC "-//W3C// ...

  8. Java学习--编译器javac

    Java的源程序为.java文件, 编译后生成.class文件(字节码文件); javac(java compiler的简写)是java语言的编译器. Hello.java public class ...

  9. Linux屏幕记录命令script

    Script -a action.log –t 2> time.log按ctrl+d 退出录制回访 scriptreplay time.log action.log或者直接用查看命令cat,ta ...

  10. (五)消费Dubbo服务

    前面我们搞了发布Dubbo服务,发布的服务就是用来消费的,所以我们这里来调用服务,消费下: 创建maven项目 dubbo-demo-consumer pom.xml配置下: <dependen ...