Share this

USB 2.0 driver analysis based on VxWorks operating system

2026-04-06 04:48:21 · · #1
Introduction Universal Serial Bus (LISB) is a computer peripheral serial communication interface characterized by high-speed data transmission, hot-plugging, plug-and-play (PnP), and low cost. With the increasing perfection and maturity of the USB specification, LISB has begun to be used as its standard peripheral interface in measuring instruments. The VxWorks operating system, with its good reliability and excellent real-time performance, has been widely used in the field of instrumentation. This paper analyzes the latest USB 2.0 driver under the VxWorks operating system, providing technical reference for the use of the USB 2.0 bus in VxWorks-based instruments. Based on problems encountered by the author during the development of a certain instrument, usage precautions are also given. 1 USB 2.0 Driver Model Structure The USB architecture is based on a master-slave structure. USB driver design refers to the host-side driver. Figure 1 shows the functional relationship between the modules of the USB host driver stack under the VxWorks operating system. At the bottom of the stack is the hardware: the USB host controller. The USB host controller controls the USB in the embedded host system, realizing the USB host function. Currently, there are three main types of USB controllers: (1) Universal Host Controller Interface (UHCI), designed and standardized by Intel; (2) Open Host Controller Interface (OHCI), designed and standardized by Microsoft, Co2ompaq, and National Semiconductor; and (3) Enhanced Host Controller Interface (EHCI), which supports USB 2.0. Each host controller has a corresponding host controller driver (HCD). These device drivers are related to the underlying hardware and provide a unified functional interface for the upper layers. The USB host driver (USBD) is independent of the underlying hardware and communicates with the underlying controller through the HCD. USBD manages each USB connection connected to the host and provides a channel for communication between the higher layers and USB devices. In addition, USBD automatically manages the power supply and allocates bandwidth for USB devices. In the USB system, the hub plays a key role in the normal operation of the USB system, so USBD directly controls the hub. This means that USBD also has the ability to control the dynamic plugging and unplugging of USB devices and hubs. At the top of the host stack is the USB device driver. The device driver relies on the communication channel provided by USBD to drive the USB device connected to the USB system. OSAL provides the LJSB host stack with operations related to the VxWorks operating system, including task management, mutual exclusion and semaphores, memory allocation and system clock. As can be seen from the structure in Figure 1, 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 USB device driver and the HCD API for the host controller driver. 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 host controller driver (HCD); (3) Load the USB device driver. In the integrated development environment (IDE), it can be configured by tools, and the steps are as follows: (1) Include the USB Host Stack component, and complete the support for USBD by including the USB host stack in the project. The USBHostStack Init component needs to be included to initialize the USB host driver at system startup; (2) Include the host controller (HC), and select the appropriate controller according to the specific design. Generally, the embedded module manual has its module controller category. When the system starts, the host controller initialization needs to include the corresponding controller initialization component; (3) Include device driver, select the corresponding device driver according to the design requirements. The VxWorks system generated by the above configuration has a USB host stack, which can complete the USB2.0 host function. 3 USB host driver (USBD) analysis Before using the interface provided by USBD, USBD needs to be initialized first. USBD initialization is divided into 3 steps, which are as follows: (1) Call the USBD entry function lasbdInit(), usbdInit initializes the data structure used by USBD; (2) Call the 13SB hub (HUB) initialization function lasbHu-blnit(), initialize the hub driver data structure; (3) Use the function usbHCDlnit() to attach the corresponding host driver. For each host driver attached to USBD, the hub driver will create a task with a priority of 100 to monitor events on the USB bus. This task is always in a sleep state, and once the state of a port on the hub changes, the task is immediately activated. Since the priority of this task is 100, it can immediately obtain resources and become running to inform USBD of the bus status. The USB device class driver needs to be registered in USBD first. USBD maintains a device class structure for each device class, which is defined as follows: When a USB device is inserted into or removed from the USB system, the hub driver notifies USBD of the insertion or removal of the USB device. USBD searches the device driver list based on the obtained device information (e.g., device class number, subclass number, protocol number, etc.). After finding the driver for the device, it calls the corresponding function of the USB device to perform the corresponding operation of the device. When a device class is no longer used in the system, the registration is revoked by the cancellation function. The essence of this operation is to delete the device class structure of the corresponding device class. 3. Conclusion The USB 2.0 driver under the VxWorks operating system introduced in this article has been successfully used in a high-performance spectrum analyzer in China. The following points should be noted during use: (1) By analyzing the USB host stack startup process, the principle of the USB host stack can be studied; (2) In order to consider the portability of the USB system, the source program provided by VxWorks has not been processed based on the platform. When using the X86 platform, it is necessary to modify the corresponding PCI settings to adapt to the PCI mechanism under the X86 platform. Specific method: Modify the usbPciStub.c definition: (3) When using EHC, be sure to pay attention to the type of USBI.1 controller used in the system and add the corresponding driver components to the VxWorks Image.
Read next

CATDOLL 146CM Ya TPE (Customer Photos)

Height: 146cm A-cup Weight: 26kg Shoulder Width: 32cm Bust/Waist/Hip: 64/54/74cm Oral Depth: 3-5cm Vaginal Depth: 3-15c...

Articles 2026-02-22