What are the implementation steps of the USB device stream interface driver?

Last Update Time: 2020-10-30 11:10:26

      From the WinCE USB device driver model and structural analysis, we can clearly see the implementation between the host and peripherals. On the host side, the default PIPE is used to access a common logical device through the USBD module and the HCD module. In fact, USBD and HCD are a set of logical interfaces that access all USB devices. They are responsible for managing the connection, loading, Removal, data transfer and general configuration. Among them, HCD is the host control driver, which provides the underlying function access service for USBD. USBD is the USB bus driver, which is located on the upper layer of HCD, and uses HCD services to provide higher-level functions. Therefore, implementing the USB load stream driver generally requires the following steps:

      (1) Select the file name prefix that represents the device. The prefix is very important, and the device manager uses the prefix to identify the device in the registry. At the same time, when naming the stream interface, this prefix is also used as the prefix of the entry point function. If the device prefix is XXX, the stream interface corresponds to XXX_Close, XXX_Init, etc.

      (2) Set each entry point function of the driver. The so-called entry point refers to the standard file I / O interface provided to the device manager. After generating a DLL, replace XXX in the name with the device file name prefix. Therefore, each loadable stream interface driver must implement a set of standard functions such as XXX_Init (), XXX_IOControl (), and XXX_PowerUp () to complete standard file I / O functions and power management.

      (3) Create a .DEF file. After the device manager initializes the stream interface functions compiled by the USB device, a .def file must also be created. The DEF file defines the interface set to be exported by the DLL, and most of the load-streaming drivers are in the form of DLL. Therefore, the file names of the DLL and DEF should be unified. The DEF file tells the linker what functions it needs to output, and finally compiles the driver into the kernel, so that the USB device stream interface driver can be called by the application.

(4) Establish entries for the driver in the registry. Establish a driver entry point in the registry so that the device manager can identify and manage the driver. In addition, the registry can store additional information, which can be used after the driver is running.

During the development of the USB driver, many wrongdoings made me miserable. What I feel most deeply is that WinCE provides a universal serial bus driver (USBD) module, a complete set of USBD interface functions, and a sample host controller driver (HCD) module. Therefore, we only need to use the different functions provided by USBD according to the USB device hardware characteristics to realize the interaction between the stream interface function and the peripheral device. In the absence of special circumstances, my biggest gain is that copying these common source programs can greatly shorten the development cycle and enable faster embedded development.

 

If you want to know more, our website has product specifications for the USB device stream interface driver you can go to ALLICDATA ELECTRONICS LIMITED to get more information