Hebei Huali Machinery Company produces hand handwheel, knob, bakelite hand wheel, hinge, chain, handgrip, button and other Machine Tool Accessory,Tel 0318-2222299
Sign in  |  Register
河北华利机械配件有限公司

USB interface technology in a variety of gamepad control system application

2013-07-11 14:24:30

 Zhao Jing, Chen Dehuang

 
    First Aeronautic Institute of Air Force Electronic Engineering, Henan 464000
 
Abstract: In order to make the game more convenient control box to connect with the gamepad, many game manufacturers have developed a game controller based on USB interface. If the product fails, manufacturers need a fast detection system to determine the handle and control box are working correctly, and then repair the product. Therefore, the USB interface connected to the handle with the board, combined with a computer program to simulate the handle on the test, no doubt is a fast and accurate method. This design is a video game testing control system. After factory testing, the system can meet the test requirements, the completion of the design task, and has good scalability.
 
Keywords: FPAG, USB. HOST
 
CLC: TP336 Document code: A
 
1 Introduction
 
    In the video game development process, and the game gamepad cable between the control box is usually connected using cable. Although each game manufacturers in the process has been greatly improved, but is still easily broken cables consumer electronics products such common faults. In order to solve the shortcomings of the traditional connection, and now a lot of video game manufacturers have preferred to use the USB bus as both cable. USB bus in Chinese means Universal Serial Bus, was in 1995 by Compaq, Microsoft, IBM, DEC and other companies to promote a new type of communication standards. The bus interface with easy installation, high-bandwidth, easy expansion point of concern, has become the development trend of modern data transmission.
 
    Typically the USB interface of a video game controller handle includes handle and two parts. Controllers and home TV interface, controlled via a USB interface handles the control box. If the product fails, manufacturers need a fast detection system to determine which handle and control box fails, then repair the product. This design focuses on: ① achieve USB interface and computer communications, and realize gamepad custom commands issued and effective implementation; ② achieve USB HOST interface was designed and implemented for the identification gamepad, enumeration and communication; ③ FPGA prevent cache access violation. In the design process, and fully consider these design elements, the products meet the design requirements, to meet the need to use.
 
2 overall system design
 
    This design uses FPGA as the core control devices using Cypress's 68013 USB controller chip and SL811HS HOST controller chip to complete the system functions.
 
    According to design requirements, the control board needs three USB ports, respectively USB_A, USB_B and USB_HOST. Which, USB_A and USB_B is USB USB slave port uses Cypress's 68013 chip complete with computer and game controller communications; USB_HOST port is the main port, using SL811HS chip, complete down to enumerate gamepad functionality. Since SL811HS is a controlled programmable chips function needs additional controller.
 
    Selection of the outer controller, mainly based on the actual board functional requirements. In this design choice TMS320C5402 DSP chip. This series DSP with high operational flexibility and speed. It has an advanced correction Harvard architecture, dedicated hardware logic of the CPU, on-chip memory, on-chip peripherals and specialized instruction set. C54x series offers a number of peripheral interfaces: two general-purpose I / O port, the host communication interface (HPI), 4 种 serial ports to meet the requirements for use in many areas.
 
    In this system, the computer using the Microsoft Visual C + + software development system application that simulates handle operation. These operating instructions represent the interface through USB_A sent to FPAC within the internal buffer. Meanwhile, game controller also send control commands via USB_HOST interfaces internal to the FPGA. At this point, FPAG according to the received time to judge the two commands sent via USB_B Lang commands to the game control box.
 
If the computer sends commands to control the game running, it indicates that the game control box without failure, otherwise the control box there is a fault; if the computer can properly control under the premise of the handle does not work, then the handle failures. Thus, the complete gamepad functionality testing.
 
    From the system design point of view, a variety of USB interface communication difficulty lies in the implementation and FPAG internal cache for the control and prevention of conflicts timing design. For USB communication includes USB SI. AVE and USB HOST modes, and USB SLAVE interface design, in addition to the basic request to meet the bus, but also realize the game between the handle and the control box customized response to the request, therefore, USB SLAVE firmware programming exists relatively great difficulty.
 
3 USB SLAVE from interface design
 
USB interface control chip contains two categories: one is the need for an external controller chip, such as the company's D12 PHILIP chips; there is a class built-in controller. Cypress Semiconductor's EZ - USB FX2 is the world's first integrated USB2.0 microprocessor, which integrates a USB2.0 transceiver, SIE (Serial Interface Engine), enhanced 8051 microcontroller and programmable peripheral interface. This ingenious structure allows FX2 data rate of 56Mbytes / s, ie USB2.0 maximum bandwidth allowed. In FX2, the smart SIE can bury a lot of hardware at USBl.1 and USB2.0 protocol, thereby reducing development time and ensuring the compatibility of USB. GPIF (General Programmable Inter-face) and master / slave endpoint FJFO (8-bit or 16-bit data bus) as ATA, UTOPIA, EPP, computer MCIA and DSP to provide a simple and seamless connection interface.
 
The system uses CYC68013 chip requires only a few properly configure the USB port pull-up resistor, the computer can identify the USB device connected to the people, but whether or not this is a high-speed USB device is full speed. Subsequently, USB device identification and communication must rely on the firmware and drivers.
 
3.1 Drivers and communication program
 
    In order to simplify and accelerate the development process, using Cypress USB firmware framework provided by the company for development. Firmware Framework includes initialization, processing and USB standard USB device requests pending when the power management.
 
    Firmware frame to complete a simple task cycle. First, initialize the internal state variables and link a descriptor table, and then call the user initialization procedure TD_lnit () function. TD_Init () function is mainly used to initialize 8051 and to set the USB port FIFO and initialize 68,013 other registers. After returning from the function, once every Is device enumeration until the endpoint 0 SETUP packet is received, the frame started task scheduling. TD_Poll () function is a user function, the user operates basically in this function is completed.
 
    After completing the basic request response, the firmware enters a loop waiting for the computer program issued a gamepad custom commands. Through the USB interface on the game custom communication protocol analysis and understanding after the custom in the program to make accurate requests responded by computer simulation on the gamepad.
 
3.2 Drivers and communication program
 
    To achieve computer simulation handles functions, USB device driver development has always been a focus of the design. A stable scouring USB device driver is quick, correct the basic guarantee. As Cypress offers the driver only supports USB devices working in synchronous mode, so if the port can not be synchronized to read and write data, the data will be clogged pipes, according to a crash. Therefore, it is necessary to increase ATM driver, add Startlo routines, to avoid data loss and system crashes. Complete the driver design methods are generally three types: Based on the DDK development, based on the development phase Windriver DriverStudio based development. As for the DDK DriverStudio Windriver and to a certain degree a function of the package, they are difficult to develop than the direct use of DDK development should be small, but the development of flexibility and drive as efficient as DDK. The design uses the drive is to use the DDK development. Completed the USB firmware and driver development future, they can be more easily achieve communication with the computer USB port. Taking into account the versatility and program design for future upgrades, first developed USB and computer communications DLL (dynamic link library) files. Use VC + + software provides an API function CreateFile and CloseHandle implemented USB device on and off; DeviceIoControl function to achieve device data read and write.
 
    Such system design USB SLAVE interface design can be achieved. Computer applications written using VC interface completely replaces the handle functions. Another handle through the FPGA via USB HOST interface to connect to the game control box. USB HOST interface design using Cypress SL811 HS chip.
 
4 USB HOST host interface design
 
    While USB interface has many advantages, but it also has a disadvantage can not be ignored: USB devices are in any communication from the device, it can not take the initiative to request the start of communication, it can not terminate any communication. Related communications with the USB device is made by a master device to initiate and control, such as a computer drive or other HOST devices. No matter what kind of USB controller chip, which is from the device appear as a computer, that is, it can only respond to computer requests can not send requests to the computer. The USB HUB chip is a master chip, it broke the computer in the USB communication dominance. HUB chip can be done through the USB device enumeration, communications, development of a new generation of USB technology development trend
 
Potential. Currently, more commonly used USB HUB chip is Cypress's SL811HS chips.
 
    SL811HS contains master / slave controller, support full / low speed data transmission, and can automatically identify the low-speed or full-speed devices. Has an internal 256 bytes of internal RAM, can be used as control registers or data buffers. Interface provided SL811HS USBl.1 standards compliance, with microprocessors, microcontrollers and DSP are connected. In this design, TMS320C5402 DSP control HUB chip.
 
    SL811HS using TMS320C5402 DSP control chip. HUB chip firmware write with different USB chip, it follows USBl.1 standard Chapter 11 HUB standards. First, HUB to the default port 0 and address 0 pairs downstream USB device enumeration, enumeration if successful, it will allocate for this device to pull, followed by the port 0 and the new address for the device descriptor and configuration descriptor and so on. If detected HUB class, gets HUB ports and other features, and then enumerate USB device. If detected, the USB device directly to the device enumeration, complete communication. Next, focus on the HUB chip firmware programming.
 
    The system USB firmware mainly consists of several components: The SL811HS set initialization procedure, this part of the program is executed immediately after a system reset; find USB device connected person of the subroutine, and determine whether the device is a high-speed device or low-speed devices ; the USB device enumeration. Firmware on the USB device configuration settings related to resource allocation and USB address. The completion of these functions need to control the transfer function usbxfer implementation. Figure 3 is a main flowchart of this function.
 
    After many DSP and communication SL811HS completed the SL811HS on downstream USB device enumeration and identification. Then, the handle with the FPGA through the effective address for data communications.
 
    FPGA is the central part of the system design, it is equivalent to the hub of the communications link, so FPGA internal timing is to ensure the effective operation of the handle and the computer instructions to effectively communicate the key to the control box. For FPGA programming focuses on preventing the game from a different interface command conflicts, including the timing of conflict and memory conflicts. In the appropriate allocation of the DSP and USB interfaces and memory, the use of control logic for timing control, conflict prevention generation.
 
5 Conclusion
 
    This system is a USB interface for the game platform for testing hardware. After factory testing, the system can meet the test requirements, the completion of the design task. Also, the system hardware is based on FPGA "soft" design, therefore, be modified by software to meet the different needs of various manufacturers. Meanwhile, USB communication protocol is controlled by software, so for all manufacturers of the game with the controller handle different communication protocols resulting differences can be effectively resolved.