Analysis of USB 2.0 Driver Based on VxW0rks

Source: Internet
Author: User
Analysis of USB 2.0 Driver Based on VxW0rks
[Date:] Source: World of electronic products Author: [Font: large, medium, and small]

 

Introduction

Universal Serial bus is a computer peripheral serial communication interface, featuring high-speed data transmission, hot swapping, plug-and-play (PnP), and low costs. With the increasingly mature and improved USB specifications, LISB has been used as its standard peripheral interface in measuring instruments. The VxWorks operating system has been widely used in the field of instruments and meters with its excellent reliability and excellent real-time performance. This article focuses on the latest USB 2 in the Vx-works operating system. the O driver is analyzed to provide a technical reference for the use of USB 2.0 bus for VxWorks-based instruments. The precautions are given in combination with the problems encountered during the development of an instrument.

1 USB 2.0 Driver Model Structure

The USB architecture is based on the master-slave structure. The USB Driver Design refers to the host-side driver. Figure 1 shows the functional relationship between the modules of the USB master driver stack in the VxWorks operating system.

The underlying hardware of the stack is the USB host con-troroller. the USB master controller controls the USB in the embedded host system to implement the USB host function. Currently, there are three main types of USB controllers:

(1) (UHCI, universal host controlle interface) General master controller, first designed and developed by Intel;

(2) (OHCI, open host controller interface) is the primary controller that is first designed and formulated by Microsoft, C2ompaq, and National Semicondtlctor;

(3) (EHCI, enhanced host controller interface). This controller supports USB 2.o.

Each master controller has a corresponding master controller driver (HCD). These device drivers are related to the underlying hardware and provide unified functional interfaces for the upper layer.

The USB host driver (USBD) is independent of the underlying hardware and communicates with the underlying controller through HCD. USBD manages every USB connection connected to the host and provides a channel for communication between the high-level and USB devices. In addition, USB [) automatically manages the power of the USB device and allocates bandwidth. In the USB system, the HUB plays a key role in the normal operation of the USB system. Therefore, USBD directly controls the HUB. This means that USBD also has the ability to control the dynamic plugging of USB devices and hubs.

At the top of the Host Stack is the USB device driver. The device driver depends on the communication channel provided by USBD to connect to a USB device in the USB system.

OSAL provides operations related to the VxWorks operating system for the LJSB Host Stack, including task management, mutex and traffic signals, memory allocation, and system clock.

The structure in Figure 1 shows that the key to the design of the USB Host Stack is the design of the USB host driver (USBD). USBD provides the standard usbd api for the driver program of the USB device; provides HCDAPI for host controller drivers.

  

 

2 USB Host Stack Startup Process

The startup of the USB Host Stack is divided into three steps:

(1) initialize the LJSB host driver (USBD );

(2) load the USB master controller driver (HCD );

(3) load the driver of the USB device.

You can use a tool to configure the integrated development environment (IDE) as follows:

(1) includes the USB Host Stack component, which supports USBD by including the USB Host Stack in the project. The USB host driver must contain the USBHostStack Init component when the system starts;

(2) include the host controller (HC), and select the corresponding controller according to the specific design. Generally, the embedded module manual contains the category of its module controller. When the system starts, host controller initialization must contain the initialization components of the corresponding controller;

(3) include a device driver. Select a device driver based on the design requirements.

With the USB Host Stack in the Vxworks system generated by the above configuration, the USB Host function can be completed. 3 USB host driver (usbd) Analysis

Before using the interfaces provided by usbd, you must first initialize usbd. The initialization of usbd is divided into three steps:

(1) Call the usbd entry function lasbdinit () and usbdinit initializes the data structure used by usbd;

(2) Call the initialization function lasbhu-blnit () of the 13sb Hub (hub) to initialize the data structure of the hub driver;

(3) Use the usbhcdlnit () function to mount the corresponding host drive.

For each host driver mounted to usbd, the hub driver creates a 100-priority task for it to monitor events on the USB bus. This task remains asleep. Once a port on the hub changes, the task is immediately activated. Because the task has a priority of 100, you can immediately obtain the resource and change it to the running status to inform usbd of the bus status.

USB device drivers must be registered in usbd first. usbd maintains a device class structure for each device class. Its definition is as follows:

  

 

When a USB device is plugged in or out of the USB system, the hub driver notifies usbd (usbd) of the information inserted or removed from the USB device to obtain the device information (such as the device class number, subclass number, find the driver list of the device, find the driver of the device, and call the corresponding function of the USB device to perform corresponding operations on the device. When a device class is not in use in the system, you can use the cancel function to cancel registration. The essence of this operation is to delete the device class structure of the corresponding device class.

4 Conclusion

The USB2.0 driver in the VxWorks operating system has been successfully used in a high-performance spectrum analyzer in China. The following precautions are taken during use:

(1) The principle of the USB Host Stack can be studied by analyzing the Startup Process of the USB Host Stack;

(2) In order to consider the portability of the USB system, the source program provided by VxWorks is not processed based on the platform. When using the X86 platform, you need to modify the corresponding PCI settings to adapt to the PCI mechanism on the X86 platform. Method: modify the definition of usbPciStub. c:

  

 

(3) When using EHC, pay attention to the type of USBI.1 controller used in the system, and add the corresponding driver components to the Image of VxWorks.

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.