Texas Instruments TUSB5052 User Manual

      
User’s Guide
February 2004 MSDS Bus Solutions
SLLU021A
IMPORTANT NOTICE
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty . Except where mandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and applications using TI components. To minimize the risks associated with customer products and applications, customers should provide adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for such altered documentation.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products Applications
Amplifiers amplifier.ti.com Audio www.ti.com/audio Data Converters dataconverter.ti.com Automotive www.ti.com/automotive
DSP dsp.ti.com Broadband www.ti.com/broadband Interface interface.ti.com Digital Control www.ti.com/digitalcontrol Logic logic.ti.com Military www.ti.com/military Power Mgmt power.ti.com Optical Networking www.ti.com/opticalnetwork Microcontrollers microcontroller.ti.com Security www.ti.com/security
Telephony www.ti.com/telephony Video & Imaging www.ti.com/video Wireless www.ti.com/wireless
Mailing Address: Texas Instruments
Post Office Box 655303 Dallas, Texas 75265
Copyright 2004, Texas Instruments Incorporated
About This Manual
This user’s guide contains pertinent information about the bootcode process of the TUSB5052.
How to Use This Manual
This document contains the following chapters:
Notational Conventions
Preface

- Chapter 1—Introduction
- Chapter 2—TUSB5052 USB Firmware Flow
- Chapter 3—Function
- Chapter 4—Bootcode Defaults
- Chapter 5—Header Format and Vendor USB Request
- Chapter 6—Programming Considerations and Bootcode File List
Notational Conventions
This document uses the following conventions.
- Program listings, program examples, and interactive displays are shown
in a special typeface similar to a typewriter’s. Examples use a bold version of the special typeface for emphasis; interactive displays use a bold version of the special typeface to distinguish commands that you
enter from items that the system displays (such as prompts, command output, error messages, etc.).
Here is a sample program listing:
0011 0005 0001 .field 1, 2 0012 0005 0003 .field 3, 4 0013 0005 0006 .field 6, 3 0014 0006 .even
Here is an example of a system prompt and a command that you might enter:
C: csr −a /user/ti/simuboard/utilities
iii
FCC Warning
In syntax descriptions, the instruction, command, or directive is in a bold
-
typeface font and parameters are in an italic typeface. Portions of a syntax that are in bold should be entered as shown; portions of a syntax that are in italics describe the type of information that should be entered. Here is an example of a directive syntax:
.asect ”section name”, address .asect is the directive. This directive has two parameters, indicated by sec-
tion name and address. When you use .asect, the first parameter must be an actual section name, enclosed in double quotes; the second parameter must be an address.
- Square brackets ( [ and ] ) identify an optional parameter. If you use an
optional parameter, you specify the information within the brackets; you don’t enter the brackets themselves. Here’s an example of an instruction that has an optional parameter:
LALK 16-bit constant [, shift]
The LALK instruction has two parameters. The first parameter, 16-bit con­stant, is required. The second parameter, shift, is optional. As this syntax
shows, if you use the optional second parameter, you must precede it with a comma.
Square brackets are also used as part of the pathname specification for VMS pathnames; in this case, the brackets are actually part of the path­name (they are not optional).
FCC Warning
- Braces ( { and } ) indicate a list. The symbol | (read as or) separates items
within the list. Here’s an example of a list:
{ * | *+ | *− }
This provides three choices: *, *+, or *−. Unless the list is enclosed in square brackets, you must choose one item
from the list.
- Some directives can have a varying number of parameters. For example,
the .byte directive can have up to 100 parameters. The syntax for this di­rective is:
.byte value
[, ... , valuen]
1
This syntax shows that .byte must have at least one value parameter, but you have the option of supplying additional value parameters, separated by commas.
This equipment is intended for use in a laboratory test environment only. It gen­erates, uses, and can radiate radio frequency energy and has not been tested for compliance with the limits of computing devices pursuant to subpart J of part 15 of FCC rules, which are designed to provide reasonable protection against radio frequency interference. Operation of this equipment in other en­vironments may cause interference with radio communications, in which case the user at his own expense will be required to take whatever measures may be required to correct this interference.
iv
Contents

1 Introduction 1-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1 Bootcode Main Program 1-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Interrupt Service Routine 1-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Control (Setup) Endpoint Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Input Endpoint 0 Interrupt Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 Output Endpoint 0 Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.6 Output Endpoint 1 Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 TUSB5052 USB Firmware Flow 2-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1 Control Write Transfer With Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Control Write Without Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Control Read Transfer 2-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 Function 3-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1 Bootcode Functional Module List 3-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.1 Bootcode.c File 3-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.2 I2C.c File 3-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.3 Header.c File 3-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Bootcode Defaults 4-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1 Default Hub Settings 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Default Bootcode Settings 4-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 Header Format and Vendor USB Request 5-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1 Header Format 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.1 Product Signature 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.2 Descriptor 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.3 Descriptor Prefix 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.4 Descriptor Content 5-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Examples 5-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.1 USB Info Basic Descriptor 5-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Built-In Vendor-Specific USB Requests 5-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.1 Get Bootcode Status 5-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.2 Execute Firmware 5-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.3 Get Firmware Revision 5-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.4 Prepare for Header Update 5-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4 Update Header 5-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Reboot 5-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6 Force Execute Firmware 5-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7 External Memory Read 5-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
v
Contents
5.8 External Memory Write 5-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.9 I2C Memory Read 5-8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.10 I2C Memory Write 5-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.11 Internal ROM Memory Read 5-9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6 Programming Considerations and Bootcode File List 6-1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1 Programming Considerations 6-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.1 USB Requests 6-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.2 Interrupt Handling Routine 6-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 File List 6-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.1 Bootcode.c Main Program 6-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
6.2.2 I2C.c I
6.3 header.c I
C Routines 6-25. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
C Header Routines 6-32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 tusb5052.h UMP-Related Header File 6-38. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5 usb.h USB-Related Header File 6-52. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6 types.h Type Definition Header File 6-55. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
6.7 i2c.h I
C-Related Header File 6-56. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.8 header.h I2C Header-Process-Related Header File 6-58. . . . . . . . . . . . . . . . . . . . . . . . . .
vi
Contents

1−1 Main Routine 1-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1−2 Interrupt Service Routine 1-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1−3 Control (Setup) Endpoint Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1−4 Input Endpoint 0 Interrupt Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1−5 Output Endpoint 0 Interrupt Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1−6 Output Endpoint 1 Interrupt Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2−1 Control Write Transfer With Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2−2 Control Read Without Data 2-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2−3 Control Read 2-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2−1 Boot Code Response to Control Write Without Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2−2 Boot Code Response to Control Read 2-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−1 Hub Descriptor 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−2 Device Descriptor 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−3 Configuration Descriptor 4-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−4 Interface Descriptor 4-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−5 Interrupt Endpoint 1 Descriptor 4-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−6 Device Descriptor 4-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−7 Configuration Descriptor 4-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−8 Interface Descriptor 4-5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4−9 Output Endpoint 1 Descriptor 4-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5−1 USB Info Basic Descriptor 5-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5−2 USB Info Basic and Firmware Basic Descriptor 5-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6−1 Vector Interrupt Values and Sources 6-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
vii
viii
Chapter 1

Chapter 1 illustrates the bootcode process with bootcode flow charts. It contains a description of the TUSB5052 bootcode document main program and a flow chart of the interrupt service routine, control (setup) endpoint handler, input endpoint 0 interrupt handler, output endpoint 0 handler, and the output endpoint 1 handler.
Topic Page
1.1 Bootcode Main Program 1-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Interrupt Service Routine 1-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Control (Setup) Endpoint Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Input Endpoint 0 Interrupt Handler 1-6. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 Output Endpoint 0 Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.6 Output Endpoint 1 Handler 1-7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Introduction
1-1
Bootcode Main Program
1.1 Bootcode Main Program
After power-on reset, the bootcode copies predefined USB descriptors to the shared RAM. The first USB descriptor is the device descriptor . It describes the embedded function class, vendor ID, product ID, etc. The second USB descriptor is the configuration descriptor, which contains information such as how the device is powered, the number of configurations available, type and number of interfaces, and end-point descriptors. From these two descriptors, Windows loads the necessary device drivers and performs pertinent actions.
Vendor and product IDs are crucial to the bootcode. Windows gets VID and PID through the standard USB device request and then tries to match the two IDs with its own database. If Windows finds them in the database, it loads the corresponding device driver. If it is not able to match the IDs it provides a prompt directing the user to provide the driver disks, which contain the INF files.
Once the bootcode finishes copying descriptors, it looks for the EEPROM on
2
C port. If a valid signature is found, it reads the data type byte. If the data
the I type is application code, it downloads the code to an external data space. Once the code is loaded and the checksum is correct, bootcode releases control to the application code. If the data contains USB device information, the bootcode interprets the data and copies it to hub registers and to the embedded function device descriptor, if the checksum is correct. If the data does not contain USB device information, bootcode restores predefined settings to the hub register and device descriptor.
After the bootcode updates the hub register and device descriptor, it sets up for a USB transaction and connects itself to the USB. It remains there until the host drivers download the application code. Once complete, it disconnects from the USB and releases control to the application code. Figure 1−1 illustrates bootcode operation.
1-2
Figure 1−1.Main Routine
Copy default descriptors and initialize necessary variables
Bootcode Main Program
No
Does EEPROM
contain valid
signature?
Yes
Does EEPROM
contain
firmware?
No
Read and copy VID and PID
from EEPROM to TUSB5052
USB data initialization
Yes
Download firmware to xdata RAM
Is firmware
loaded and ready
Disable all interrupts and switch
xdata space to code space
Run firmware
to run?
Yes
No
Load firmware
from USB
Introduction
1-3
Interrupt Service Routine
1.2 Interrupt Service Routine
Interrupt service is generated from external interrupt 0. TUSB5052 uses this interrupt for internal peripherals. This interrupt consists of input/output endpoints, setup packet, I
The main service routine confirms the source of interrupt then notifies corresponding functions. Once interrupt is performed, the main service routine clears INTVEC registers to inform hardware that the service is complete, then releases control back to the main program. Figure 1−2 illustrates how each service is processed.
2
C, UART, printer port, and DMA.
1-4
Figure 1−2.Interrupt Service Routine
Disable global interrupt
Interrupt Service Routine
Is output
endpoint 0
interrupt?
No
Is output
endpoint 1
interrupt?
No
Is input
endpoint 0
interrupt?
No
Yes
Yes
Yes
Output endpoint 0 handler
Output endpoint 1 handler
Input endpoint 0 handler
Is setup
packet received
interrupt?
No
Clear interrupt vector and
enable global interrupt
End of interrupt
Yes
Setup packet interrupt handler
Introduction
1-5
Control (Setup) Endpoint Handler
1.3 Control (Setup) Endpoint Handler
Once bootcode receives a setup packet from the host, a control packet interrupt handler acquires control from the interrupt service routine. This handler processes the incoming packet, performs the appropriate action, then returns control to the interrupt service routine, as shown in Figure 1−3.
Figure 1−3.Control (Setup) Endpoint Handler
Setup packet handler
Process standard USB
request and configuration
End of interrupt
Stall IEP0 if the incoming setup
packet is illegal
1.4 Input Endpoint 0 Interrupt Handler
Figure 1−4 illustrates the process of sending data back to the host. If the last packet is sent, the handler stalls the input endpoint, which prevents the host from getting more data.
Figure 1−4.Input Endpoint 0 Interrupt Handler
Input endpoint 0 handler
Is this
the last
packet?
Yes
The last packet was sent. Stall IEP0.
If host asks for more data, bootcode
will stall. This scheme works fine even
in status stage because stall will be
clear once setup packet is received.
No
In data stage now, call
FillEp0TxFifoWithNextDataPacket()
routine to send out next data packet
End of interrupt
1-6
1.5 Output Endpoint 0 Handler
Figure 1−5 demonstrates the process bootcode uses to deal with an output endpoint 0 interrupt. Because bootcode does not support control write with a data stage, it merely clears the NAK bit in the handler.
Figure 1−5.Output Endpoint 0 Interrupt Handler
Output endpoint 0 handler
Clear NAK bit
End of interrupt
1.6 Output Endpoint 1 Handler
Output Endpoint 0 Handler
Bootcode does not support control
write with data stage. Therefore, this
interrupt only happens in status stage
of control read. Clear the NAK bit in
OEP0 so next OEP0 can receive next
OUT packet in status stage, or
bootcode does nothing.
The application code is downloaded from output endpoint 1, as shown in Figure 1−6. This endpoint supports double buffered. Therefore, it switches to the other buffer as soon as the current buffer receives data from the host.
Figure 1−6.Output Endpoint 1 Interrupt Handler
Output endpoint 1 handler
Get the size of incoming packet
from current buffer and copy
it to xdata RAM
Switch the pointer to the other
buffer. Clear the NAK in
original buffer.
End of interrupt
Introduction
1-7
1-8
Chapter 2
   
There are three types of control transfers in standard USB requests. Figure 2−1 through Figure 2−3 and Table 2−1 and Table 2−2 demonstrate the process bootcode uses to respond to each control transfer.
Topic Page
2.1 Control Write Transfer With Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Control Write Without Data 2-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Control Read Transfer 2-3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TUSB5052 USB Firmware Flow
2-1
Control Write Transfer With Data (Bootcode does not support this)
2.1 Control Write Transfer With Data (Bootcode does not support this)
Figure 2−1.Control Write Transfer With Data
Setup stage Data stage Status stage
SETUP(0) OUT(1) OUT(0) OUT(0/1) IN(1)
INT INT INT
1. Hardware generates interrupt to MCU.
2. Set NAK on both endpoints.
3. Set DIR bit in USBCTL to indicate the data direction and SIR bit to indicate setup interrupt is being served.
4. Decode the setup packet.
5. If another setup packet arrives, abandon this one.
6. Execute appropriate routines.
a) Clear NAK bit in OUT
endpoint.
b) Clear NAK bit in IN endpoint
for status stage.
.
1. Hardware generates interrupt to MCU.
2. Copy data from OUT buffer.
3. Clear the NAK bit.
4. If all data has been received, stall output endpoint. .
More
packets
INT
1. Hardware handles this but does not generate interrupt to MCU.
2.2 Control Write Without Data
Table 2−1.Boot Code Response to Control Write Without Data
Control Write Without Data Action In Boot Code
Clear feature of device Stall endpoint Clear feature of interface Stall endpoint Clear feature of endpoint Clear stall on requested endpoint Set feature of device Set remote wake-up feature Set feature of interface Stall endpoint Set feature of endpoint Stall requested endpoint Set address Set device address Set descriptor Stall endpoint Set configuration Set bConfiguredFlag Set interface Stall endpoint Synchronization frame Stall endpoint
2-2
Figure 2−2.Control Read Without Data
Setup stage Status stage
SETUP(0) IN(1)
INT
Control Read Transfer
1. Hardware generates interrupt to MCU.
2. Set NAK on both endpoints.
3. Set DIR bit in USBCTL to indicate the data direction and SIR bit to indicate setup interrupt is being served.
4. Decode the setup packet.
5. If another setup packet arrives, abandon this one.
6. Execute appropriate routines. a) Clear NAK bit in OUT endpoint.
b) Clear NAK bit in IN endpoint for status stage.
.
1. Hardware handles this but does not generate interrupt to MCU.
2.3 Control Read Transfer
Table 2−2.Boot Code Response to Control Read
Control Read Action In Boot Code
Get status of device Return remote wake-up and power status Get status of interface No action and return zero Get status of endpoint Return the endpoint status (stall or not) Get descriptor of device Return device descriptor Get descriptor of configuration Return configuration descriptor Get descriptor of string Illegal requests, stall endpoint Get descriptor of interface Illegal requests, stall endpoint Get descriptor of endpoint Illegal requests, stall endpoint Get configuration Return bConfiguredFlag value Get interface No action and return zero
TUSB5052 USB Firmware Flow
2-3
Control Read Transfer
Figure 2−3.Control Read
Setup stage Data stage Status stage
SETUP(0) IN(1) IN(0) IN(0/1) OUT(1)
INT INT INT
1. Hardware generates interrupt
to MCU.
2. Set NAK on both endpoints.
3. Set DIR bit in USBCTL to
indicate the data direction and SIR bit to indicate setup interrupt is being served.
4. Decode the setup packet.
5. If another setup packet
arrives, abandon this one.
6. Execute appropriate routines.
a) Clear NAK bit in OUT
endpoint for status stage. b) Copy data to IN endpoint buffer and set byte count.
.
1. Hardware generates interrupt to MCU.
2. Copy data to IN buffer.
3. Clear the NAK bit.
4. If all data has been received, stall IN endpoint. .
More
packets
INT
1. Hardware handles this but does not generate interrupt to MCU.
2-4
Chapter 3

Chapter 3 contains a bootcode module list with a functional description of each bootcode module.
Topic Page
3.1 Bootcode Functional Module List 3-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Function
3-1
Bootcode Functional Module List
3.1 Bootcode Functional Module List
3.1.1 Bootcode.c File
- VOID FillEp0TxWithNextDataPacket (VOID)
This function is alerted by an interrupt service routine if there is an IN token addressed to endpoint 0 from the host. This routine packetizes the remainder of the data and sends one packet to the host. If the data is more than packet size, the next packet is sent during the next interrupt immediately after hardware receives the next IN token.
- VOID TransmitBufferOnEp0(PBYTE pbBuffer)
This checks the length and then requests the FillEp0TxWithNextDataPacket() function to send data out.
- VOID TransmitNullResponseOnEp0(VOID)
This sends a zero length packet to the host, which is used as an acknowledgement in the status page
- VOID Stall EndPoint0(VOID)
This stalls both input and output endpoint0, preventing the host from sending or receiving data from endpoint0. It is sometimes used to indicate there is an error in the transaction.
- VOID Endpoint0Control(VOID)
This supplies and executes standard USB and several vendor-specific requests.
- VOID UsbDataInitialization(VOID)
This enables interrupts and initializes USB registers.
- VOID CopyDefaultSettings(VOID)
This copies default descriptors and initializes variables.
- VOID SetupPacketInterruptHandler(VOID)
This is called by the interrupt service routine when a setup packet is received. This function presets some variables before it calls the Endpoint0Control() function.
- VOID Ep0InputInterruptHandler(VOID)
This is transmitted by the interrupt service routine when an IN token is received. If there is more data to send, it notifies the FillEp0TxWithNextDataPacket() function to send data. Immediately following the last packet of data is sent, it stalls the endpoint, which prevents the host from getting data.
- VOID Ep0OutputInterruptHandler (VOID)
This is transmitted during the status stage of the control read transfer in the bootcode. Bootcode always stalls the output endpoint due to the lack of control write with data stage support.
- VOID Ep1OutputInterruptHandler(VOID)
This function is transmitted if there is an OUT token to endpoint 1. The first packet of data contains the size and checksum of the application code. Since endpoint1 is a double buffer, this routine keeps tracking the buffer sequence.
3-2
3.1.2 I2C.c File
Bootcode Functional Module List
Interrupt [0x03] VOID EX0_int(VOID)
-
All UMP-related interrupts are performed in this routine. It reads in vector numbers in order to determine the type of interrupt and notifies the appropriate functions.
- VOID main(VOID)
This is performed by the interrupt service routine when a setup packet is received. It presets some variables then contacts the Endpoint0Control() function.
- VOID I2CSetBusSpeed(BYTE bBusSpeed)
2
This function sets the I
C speed. If bBusSpeed is 1, the I2C bus operates
at 400 kHz.
- BYTE I2CSetMemoryType(VOID)
This function sets the I2C memory type. The ranges are from 0x01, Type I, to 0x03, Type III device.
- BYTE I2CWaitForRead(VOID)
2
Wait routine for I
- BYTE I2CWaitForWrite(VOID)
C read
Wait routine for I2C write
3.1.3 Header.c File
- BYTE I2CRead(BYTE bDeviceAddress, WORD wAddress, WORD
wNumber, PBYTE pbDataArray)
This routine reads from one to wNumber of bytes.
- BYTE I2CWrite(BYTE bDeviceAddress, WORD wAddress, WORD
wNumber, PBYTE pbDataArray)
This routine writes from one to wNumber of bytes. It is possible that some
2
C devices have physical limitations for the number of bytes that can be
I written each time. See the I2C device data sheet.
- BYTE headerCheckProductIDonI2C(VOID)
2
This function checks for a valid ID on the I
- BYTE headerSearchForValidHeader(VOID)
C device.
Checks for a valid signature.
- BYTE headerGetDataType(WORD wNumber)
Delivers the data type indexed by a wNumber.
- BYTE LoadFirmwareBasicFromI2C(VOID)
Loads the firmware from the I
- BYTE LoadUsbInfoBasicFromI2C(VOID)
Loads the USB data from the I
2
C device.
2
C device.
- BYTE headerProcessCurrentDataType(VOID)
- WORD headerReturnFirmwareRevision(VOID)
Checks the data type and processes the data.
This function returns the current firmware revision.
Function
3-3
3-4
Chapter 4
 
Chapter 4 lists the defaults used for hub and bootcode settings. There are tables in each category that list the offset, field, size, and value, and provide short descriptions for the hub, device, configuration, interface, and interrupt endpoint1 descriptors.
Topic Page
4.1 Default Hub Settings 4-2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Default Bootcode Settings 4-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bootcode Defaults
4-1
Default Hub Settings
4.1 Default Hub Settings
Table 4−1.Hub Descriptor
Offset Field Size Value Description
0 bLength 1 0x09 Size of this descriptor in bytes 1 bDescriptorType 1 0x29 Device descriptor type 2 bNbrPorts 1 6 Number of downstream ports 3 wHubCharacteristics 2 0x0D [1:0] Power switching = 01 (individual)
[2] compound device = 1 [4:3] over-current protection mode = 01 (individual)
[15:5] reserved = 0 4 bPwrOn2PwrGood 1 0x32 Time (in 2ms intervals) from power on to power good 6 bHubContrCurrent 1 0x32 Maximum current requirements of the hub controller
electronics in mA 7 DeviceRemovable 1 0x60 Device removable 8 PortPwrCtrlMask 1 0xFF Port power control mask
Table 4−2.Device Descriptor
Offset Field Size Value Description
0 bLength 1 18 Size of this descriptor in bytes 1 bDescriptorType 1 1 Device descriptor type 2 BcdUSB 2 0x0110 USB spec 1.1 4 bDeviceClass 1 0xFF Vendor-specific class 5 bDeviceSubClass 1 0 None 6 bDeviceProtocol 1 0 None 7 bMaxPacketSize0 1 8 Max. packet size for endpoint zero 8 ID Vendor 2 0x0451 USB assigned vendor ID = TI
10 ID Product 2 0x2260 2 Functions and 6 ports 12 BCD Device 2 0x0100 Device release number = 1.0 14 iManufacturer 1 0 Index of string descriptor describing manufacturer 15 iProduct 1 0 Index of string descriptor describing product 16 iSerialNumber 1 0 Index of string descriptor describing device serial number 17 bNumConfigurations 1 1 Number of possible configurations
4-2
Default Hub Settings
Table 4−3.Configuration Descriptor
Offset Field Size Value Description
0 bLlength 1 9 Size of this descriptor in bytes 1 bDescriptorType 1 2 Configuration descriptor type 2 wTotalLength 2 25 = 9 + 9 + 7 Total length of data returned for this configuration.
Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or
vendor-specific) returned for this configuration. 4 bNumInterfaces 1 1 Number of interfaces supported by this configuration 5 bConfigurationValue 1 1 Value to use as an argument to the
SetConfiguration() request to select this
configuration. 6 iConfiguration 1 0 Index of string descriptor describing this
configuration 7 bmAttributes 1 0xA0 Configuration characteristics
D7: Reserved (set to one) D6: Self-powered D5: Remote wake-up is supported D4−D0: Reserved (reset to zero)
8 bMaxPower 1 0 This device consumes no power from the bus.
Table 4−4.Interface Descriptor
Offset Field Size Value Description
0 bLength 1 9 Size of this descriptor in bytes 1 bDescriptorType 1 4 Interface descriptor type 2 bInterfaceNumber 1 0 Number of interfaces. Zero-based value identifying the
index in the array of concurrent interfaces supported by this configuration.
3 bAlternateSetting 1 0 Value used to select alternate setting for the interface
identified in the prior field
4 bNumEndpoints 1 1 Number of endpoints used by this interface (excluding
endpoint zero). If this value is zero, this interface uses
the default control pipe. 5 bInterfaceClass 1 0x09 Vendor-specific class 6 bInterfaceSubClass 1 0 7 bInterfaceProtocol 1 0 8 iInterface 1 0 Index of string descriptor describing this interface
Bootcode Defaults
4-3
Default Bootcode Settings
Table 4−5.Interrupt Endpoint 1 Descriptor
Offset Field Size Value Description
0 bLength 1 7 Size of this descriptor in bytes 1 bDescriptorType 1 5 Endpoint descriptor type 2 bEndpointAddress 1 0x81 Bits 3−0:The endpoint number
Bit 7: Direction
0 = OUT endpoint 1 = IN endpoint
3 bmAttributes 1 3 Bits 1−0:Transfer type
10 = Bulk 11 = Interrupt
4 wMaxPacketSize 2 1 Max packet size this endpoint is capable of sending or
receiving when this configuration is selected.
6 bInterval 1 0xFF Interval for polling endpoint for data transfers, expressed
in milliseconds
4.2 Default Bootcode Settings
Table 4−6.Device Descriptor
Offset Field Size Value Description
0 bLength 1 18 Size of this descriptor in bytes 1 bDescriptorType 1 1 Device descriptor type 2 BcdUSB 2 0x0110 USB spec 1.1 4 bDeviceClass 1 0xFF Vendor-specific class 5 bDeviceSubClass 1 0 None 6 bDeviceProtocol 1 0 None 7 bMaxPacketSize0 1 8 Max packet size for endpoint zero
8 ID Vendor 2 0x0451 USB assigned vendor ID = TI 10 ID Product 2 0x5052 TI part number=TUSB5052 12 BCD Device 2 0x0100 Device release number = 1.0 14 iManufacturer 1 0 Index of string descriptor describing manufacturer 15 iProduct 1 0 Index of string descriptor describing product 16 iSerialNumber 1 0 Index of string descriptor describing device serial number 17 bNumConfigurations 1 1 Number of possible configurations
4-4
Default Bootcode Settings
Table 4−7.Configuration Descriptor
Offset Field Size Value Description
0 bLlength 1 9 Size of this descriptor in bytes 1 bDescriptorType 1 2 Configuration descriptor type 2 wTotalLength 2 25 = 9 + 9 + 7 Total length of data returned for this configuration.
Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or
vendor-specific) returned for this configuration. 4 bNumInterfaces 1 1 Number of interfaces supported by this configuration 5 bConfigurationValue 1 1 Value to use as an argument to the
SetConfiguration() request to select this
configuration 6 iConfiguration 1 0 Index of string descriptor describing this
configuration 7 bmAttributes 1 0xC0 Configuration characteristics
D7: Reserved (set to one) D6: Self-powered D5: Remote wake-up is supported D4−D0: Reserved (reset to zero)
8 bMaxPower 1 0 This device consumes no power from the bus.
Table 4−8.Interface Descriptor
Offset Field Size Value Description
0 bLength 1 9 Size of this descriptor in bytes 1 bDescriptorType 1 4 Interface descriptor type 2 bInterfaceNumber 1 0 Number of interfaces. Zero-based value identifying the
index in the array of concurrent interfaces supported by this configuration.
3 bAlternateSetting 1 0 Value used to select alternate setting for the interface
identified in the prior field
4 bNumEndpoints 1 1 Number of endpoints used by this interface (excluding
endpoint zero). If this value is zero, this interface uses
the default control pipe. 5 bInterfaceClass 1 0xFF Vendor-specific class 6 bInterfaceSubClass 1 0 7 bInterfaceProtocol 1 0 8 iInterface 1 0 Index of string descriptor describing this interface
Bootcode Defaults
4-5
Default Bootcode Settings
Table 4−9.Output Endpoint 1 Descriptor
Offset Field Size Value Description
0 bLength 1 7 Size of this descriptor in bytes 1 bDescriptorType 1 5 Endpoint descriptor type 2 bEndpointAddress 1 0x01 Bits 3−0:The endpoint number
Bit 7: Direction
0 = OUT endpoint 1 = IN endpoint
3 bmAttributes 1 2 Bits 1−0:Transfer type
10 = Bulk 11 = Interrupt
4 wMaxPacketSize 2 64 Maximum packet size this endpoint is capable of sending
or receiving when this configuration is selected.
6 bInterval 1 0 Interval for polling endpoint for data transfers, expressed
in milliseconds
4-6
Loading...
+ 70 hidden pages