Host (pci/usb) port. Over view. Host Port Selection. Configuration Spaces. PCI Configuration Space, страница 27

Upon initial startup from PM ROM, the MCU performs the following functions prior to responding to any USB control traffic from the host:

1.  Clears all 256 bytes of DM

2.  Sets the USB interface in the device Default State. (See the USB specification Chapter 9 for details on device states.)

3.  Enables its external interrupt 0 which is used to handshake between the USB Endpoint 0 hardware and the MCU.

4.  Reads the Serial EEPROM registers and overwrites the changeable fields in the USB descriptor tables for the default config device.

5.  Sets the least significant bit of DSP Mailbox register 0x24 as a signal to the DSP that the MCU has completed reading the Serial EEPROM registers and updating the USB descriptor tables.

6.  Writes the MCU OK bit (bit 2 of USB Control Register) to signal the USB Endpoint 0 hardware that the MCU has completed initialization and is ready to respond to USB commands.

Once it has finished the above sequence, the MCU enters an idle loop, waiting from an interrupt from the USB Endpoint 0 hardware. When the MCU gets an interrupt, it jumps to its interrupt service routine in which it decodes the USB command and calls the appropriate command service routine.

As stated earlier, the MCU initially sets the USB interface into the device Default State. As the enumeration process with the USB host takes place, the MCU controls the movement of the USB interface from the Default State to the Addressed State, and finally to the Configuration State.

Application-specific MCU RAM-based firmware should be based on the structures used in the MCU ROM firmware for supporting the standard USB commands and the two vendor-specific commands. Typical RAM-based code should be designed as follows:

1.  Additional Interface, Endpoint, and/or String Descriptor tables which detail the characteristics of the DSP Code download and Data Endpoints to be enumerated.

2.  A copy of the ROM code which supports the standard USB commands and the two vendor-specific commands.

3.  Any USB class-specific commands that maybe necessary for this application. These should follow the same programming models used in the ROM for either the standard commands or the vendor-specific commands.

4.  Section of code that programs the personalities of all enumerated DSP code and data Endpoints via the Endpoint Description, NAK Counter, and Endpoint Stall Policy registers.

MC U Firm wa re Prog ra m m e rs Mod e l (End p oint 0)

The MCU and Endpoint 0 hardware block communicate with each other by a series of signaling bits. For any command that meets the proper USB protocol and contains the correct address, the Endpoint 0 hardware block and MCU begin the following exchange:

1.  Endpoint 0 hardware performs unconditional and conditional setting of the following interrupt bits located in the high byte of the USB Control Register:

a.  Always sets INT and BY bits.

b.  Sets ISE if Setup Token arrived indicating new USB command.

c.  Sets IIN if Setup Token arrived or ACK received from a previous device-to-host transfer of a non-zero length data packet in response to an IN token from the host.

d.  Sets IOU if Setup Token arrived or OUT with a non-zero length Data Stage received from the host.

2.  MCU jumps to its interrupt service routine and performs the following:

a.  Clears the INT bit of USB Control Register.

b.  Determines if the interrupt is for a new command or a command in progress. If new command, clears its “command_complete” status.

c.  Reads the USB SETUP Token Command Register to determine the command request and performs general error checking of the command fields.

3. MCU vectors off to the appropriate command service routine. The action taken depends on the command being serviced.