DatasheetBay.com



AN3631 (Freescale Semiconductor) : Total 14 Pages

No Preview Available !

[ Download PDF for PC ]

Freescale Semiconductor
Application Note
Document Number: AN3631
Rev. 0, 03/2008
www.DataSheet4U.com
Simplified Device Data
Structures for the High-End
ColdFire Family USB Modules
by: Melissa Hunter
Applications
Microcontroller Solutions Group
Some of the high-end ColdFire products (such as the
Contents
MCF532x, MCF537x, MCF5253, and MCF5445x
1 USB Device Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
devices) contain an EHCI-compatible host or
dual-role/OTG USB controller. The dual-role module
1.1 Endpoint Queue Head (dQH) . . . . . . . . . . . . . . . . . 2
1.2 Endpoint Transfer Descriptor (dTD) . . . . . . . . . . . . 4
2 USB Device Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
can be used as a USB host, a USB device, or as an
2.1 USB Device Initialization . . . . . . . . . . . . . . . . . . . . . 7
On-the-Go device. When the dual-role module is used as
3
2.2 Device Enumeration . . . . . . . . . . . . . . . . . . . . . . . . 9
Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . 13
a device, it uses data structures to control USB data
movement. These data structures are similar in some
ways to the embedded host controller interface (EHCI)
data structures that are used when operating in host
mode.
The purpose of this application note is to discuss a
simplified version of the device mode data structures
used by the dual-role USB controller. This document
also walks through a real-world example to show how
the USB controller is programmed and to provide
examples of how the data structures are used.
This document is intended as a guide for developing a
simple driver for communicating with a USB host. The
simplified version of the data structures discussed in this
© Freescale Semiconductor, Inc., 2008. All rights reserved.



No Preview Available !

[ Download PDF for PC ]

USB Device Overview
document do not support all of the capability of the USB controller. To simplify the data strwuwcwtu.Dreasta, Sheet4U.com
isochronous transfers are not discussed. Transfer sizes are also restricted to smaller than 4 KB. When using
the full data structures discussed in the device reference manual, both isochronous traffic and transfers
larger than 4 KB are supported.
1 USB Device Overview
For device operations, the USB module uses two different types of data structures — endpoint queue heads
(dQHs) and endpoint transfer descriptors (dTDs).
One dQH is defined for each endpoint and each direction. For example, there is one dQH used for endpoint
0 OUT transactions and a second dQH used for endpoint 0 IN transactions. These dQHs are stored in
memory as an eight element array as shown in Figure 1.
ENDPOINTLISTADDR
ENDPOINTLISTADDR + 0x040
ENDPOINTLISTADDR + 0x080
ENDPOINTLISTADDR + 0x0C0
ENDPOINTLISTADDR + 0x100
ENDPOINTLISTADDR + 0x140
ENDPOINTLISTADDR + 0x180
ENDPOINTLISTADDR + 0x1C0
Endpoint Queue Heads
Endpoint QH0 - Out
Endpoint QH0 - In
Endpoint QH1 - Out
Endpoint QH1 - In
Endpoint QH2 - Out
Endpoint QH2 - In
Endpoint QH3 - Out
Endpoint QH3 - In
Transfer Buffer
Pointer
Transfer Buffer
Pointer
Endpoint
Transfer
Descriptors
(dTDs)
Transfer
Buffer
Transfer
Buffer
Transfer
Buffer
Transfer
Buffer
Figure 1. Endpoint Queue Head Diagram
1.1 Endpoint Queue Head (dQH)
There is one dQH used for each direction of each endpoint as shown in Figure 1. The dQH defines the max
packet length along with other options for the endpoint. When a packet is transferred, the overlay area of
the dQH acts as a staging area for the dTD so the device controller can access needed information with
minimal latency.
Figure 2 shows a simplified dQH structure where the fields relating to isochronous transactions and large
transfers (transfers that require more than one buffer pointer) have been removed or set to static values.
This is a simplified version of the dQH structure specified in the device reference manual.
Simplified Device Data Structures for the High-End ColdFire Family USB Modules, Rev. 0
2 Freescale Semiconductor



No Preview Available !

[ Download PDF for PC ]

USB Device Overview
www.DataSheet4U.com
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 offset
0 0 zlt 0 0
Maximum Packet Length
ios 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0x00
Current dTD Pointer
0 0 0 0 0 0x04
Next dTD Pointer
T 0x08
0x0C
0x10
dTD Overlay Area
0x14
0x18
0x1C
0x20
0x24
Setup Buffer Bytes 3–0
0x28
Setup Buffer Bytes 7–4
0x2C
Device controller read/write; all others read-only.
Figure 2. Endpoint Queue Head Layout (dQH)
1.1.1 Endpoint Capabilities/Characteristics (Offset = 0x0)
The first longword of the dQH specifies static information about the endpoint. In other words, this
information does not change over the lifetime of the endpoint.
Table 1. Endpoint Capabilities/Characteristics
Bit Name
Description
31–30
29
28–27
26–16
15
14–0
— Write as 00.
zlt Zero length termination select. Clearing this bit indicates that zero length packets will be
used to terminate transfers that are a multiple of the max packet size as per the USB
specification. For regular operation this bit must be cleared.
— Write as 00.
Maximum Set to the maximum packet size in bytes of the associated endpoint. The maximum value
Packet Length this field may contain is 0x400 (1024).
ios Interrupt on setup. If this bit is set, the device controller will issue an interrupt whenever a
setup packet is received on this endpoint. This bit is only used for control endpoints.
— Write as 0x000.
1.1.2 Current dTD Pointer (Offset = 0x4)
This longword is the address in memory of the dTD that is currently being processed. This field is written
by the device controller when it reads in the dTD. Software does not need to initialize this longword when
creating a new dQH.
Simplified Device Data Structures for the High-End ColdFire Family USB Modules, Rev. 0
Freescale Semiconductor
3



No Preview Available !

[ Download PDF for PC ]

USB Device Overview
1.1.3 dTD Overlay Area (Offset = 0x8–0x20)
www.DataSheet4U.com
The eight longwords in this area are a working copy of the dTD that is currently being processed or was
last processed. When a transfer is in progress, the controller will write incremental status information to
the dTD overlay area. When the transfer is complete, the results are written back to the original dTD
location (the address pointed to by the current dTD pointer).
These values are initialized by the device controller when it copies in the current dTD, so software does
not need to initialize these fields. The one exception is the next dTD pointer. This value should be
initialized by software whenever a new chain of dTDs needs to be processed (the current linked list is
complete or has been flushed). Software should initialize the next dTD pointer to the address of the first
dTD to be processed for the endpoint (with the T bit cleared to indicate a valid pointer). After this is done
the endpoint can be primed.
1.1.4 Setup Buffer (Offset = 0x28–0x2C)
The USB device controller manages setup packets differently than other packets. Whenever a setup packet
is received, the incoming data is stored in a dedicated 8-byte setup buffer. The setup buffer is used only for
OUT (host to device) control endpoints. Refer to the USB OTG controller chapter of the processor user’s
manual for more information on the procedure for reading the setup buffer.
1.2 Endpoint Transfer Descriptor (dTD)
A dTD is used to define an actual data movement for a single transfer. In particular, it provides the quantity
of data to be sent or received and the location of the data. The dTDs are processed as a singly linked list.
The next dTD pointer in the dQH should be initialized to point to the first dTD in the linked list, and then
the endpoint can be primed to start processing of the first dTD. After the first dTD is processed, the
controller will use the next dTD pointer in the first dTD to find the second dTD. The controller will
continue traversing the linked list until a dTD with an invalid next dTD pointer is reached or the endpoint
is flushed to abandon processing of the current dTD. dTDs must be aligned on 32-byte boundaries.
Figure 3 shows the simplified structure for a dTD. This is a simplified version of the dTD defined in the
processor reference manual that can be used to transfer up to 4 KB of data.
Simplified Device Data Structures for the High-End ColdFire Family USB Modules, Rev. 0
4 Freescale Semiconductor





[ Download PDF for PC ]





0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  

This is a individually operated, non profit site. If this site is good enough to show, please introduce this site to others.
* 2015 :: DatasheetBay.com :: DatasheetBay