AT91 USB Composite Driver Implementation

Source: Internet
Author: User

AT91 USB Composite Driver Implementation

1. Introduction The USB Composite device is a general-to-integrate, or more functions-to-one single Device.

It is defined in the USB Specification Revision 2.0, as "A device which has multiple interfaces controlled independently of Each of the other ".

This document introduces basics for USB composite device and gives examples to implement the composite device

That has both 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 is 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 the USB functions, you'll need one USB cable for each function, which means when you use several funct Ions, many cables is 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 or more serial ports through one single USB cable, mostly for laptop.

Note that the composite device has several functions this 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 the 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-to-connect PC with portable devices and to expand external p Eripherals.

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 the kinds of Devic Es:

Composite Device: A device has multiple logical interfaces controlled independently of each of the other.

A Single physical logical address was used for the device.

Compound device: A separate hub with multiple functions attached.

Composite devices is an efficient solution to reduce the number of the hub and USB cables.

To give an example:

A device being at the same time modem and audio speaker requires with 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 are some client software that can operate with the different functions in the same physical device Simu ltaneously. e.g. when a composite device with card reader and printing function are connected to a PC, a new printer device and storage Disks may appear for your 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 def Ined for each functions available in the system.

e.g., a composite with HID+CDC needs three interface descriptors (sections 4.7.3 on page), while HID+MSD (Section 4.7.1 on page] only needs.

There is 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 being placed together, that's, the values of binterfacenumber should be C ontiguous;

If or more interfaces is associated to one device function (such as CDC), the Interface Association descriptor (IAD ) is used,

Refer to Sections 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 has only one interface, such as HID+MSD.

The default endpoint (endpoint 0) is a shared by all functions.

Each function has a 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 is 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-in Terface-function.

There may is other endpoints such as a 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 sections 3.2.4.1 on page 6) to Associa Te 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 EN Dpoint required for individual function.

e.g., a composite with HID+CDC needs six endpoint descriptors (sections 4.7.3 on page), while hid+msd (Section 4.7.1 on page] only needs five.

Endpoint 0 (default Endpoint) is used for standard, class-specific and vendor-specific requests, depending on the implemen Tation of the functions inside.

It can used to operate on any interface for any device function.

The other endpoints was function-specific, their usage is defined by the class of the function or defined by the vendor.

Figure 3-1 and Figure 3-2 is examples for the composite device architecture with the 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 is some examples on the endpoint allocation for At91sam7se chip,

Since it has 7 endpoints.

Refer to the At91sam product datasheet to get the number and the size of endpoints.

Generally, ISO endpoints should is 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 is the Interrupt endpoints, which only require a small FIFO and the lowest speed.

Please refer the ping-pong mechanism in the USB device section of the At91sam product datasheet.

hid:for HID device function, only of interrupt endpoints is needed, and since the size is small and speed is Low, its endpoints is considered as the lowest priority.

msd:for MSD device function, the high speed transaction, both 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 byt ES),

More than one endpoint, isochronous transfer and at least double bank.

CDC: CDC needs three endpoints excluding the default endpoint to work.

Bulk endpoints and one Interrupt endpoint. So DUAL-CDC device would 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 isn't for specific class, and most of the descriptors for functions is defined in the included class rel Ated specifications.

Only one descriptor are 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, a device to describe which interfaces is 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 the USB ENGINEERING Change NOTICE (Title:interface Association Descriptors) for detailed information.

The IAD is used to describe that, or more interfaces be associated to the same function.

The ' association ' includes, or more interfaces, and all of the their alternative setting interfaces.

A device must use the IAD for each multi-interfaced device function.

An IAD was always returned as part of the configuration information returned by a getconfigurationdescriptor request.

It must is located before the interface descriptors (including all alternate settings) for the interfaces it associates WI Th.

All of the interface numbers in a particular set of associated interfaces must is 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, and all requests be defined by the device function which is integrated.

3.3 Host Drivers

Usually the Operating System supports the composite device via both part of Drivers-composite driver and the function dri Vers depending

On the functions is integrated.

The OS would 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 would appear as normal separated devices for OS to access.

Most OSs now include the generic drivers for a wide variety of USB classes.

This makes developing a function device simpler, since the host complexity was now handled by the OS.

Manufacturers can thus concentrate on the device itself, not on developing specific host drivers.

As described before in sections 3.2.4.1 note, the IAD of multi-interface USB devices is a new feature,

There may is issues about how existing USB OS implementations would support devices with IAD.

For Linux®, it's supported now.

For the Windows can refer to the support for USB Interface Association descriptor in Windows, but patches may needed,

Only the Windows XP with some hot fix or service Pack 3 or later updates fully support this feature now.

Here are a brief list of the various function implementations supported by several OSs

(For CDC maybe additional. inf file was required to install the device but the driver files themselves was from Windows Sou RCE 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 refer to the sections of the functions or the class implement application notes for detail s about the OS compatibility on the device driver.

AT91 USB Composite Driver Implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.