USB driver development Technology Summary (III)

Source: Internet
Author: User

3. Write client programs

1 Device Interface

The adddevice code of the driver calls iocreatedevice to create a device object. There are two methods to provide names available for Win32 programs. The old method is to provide a clear Symbolic Link name, and the new method is to use the device interface to identify devices that support the defined API.

The iocreatedevice call has a devicename parameter, which can be used to specify a name for the device. This name identifies the device to the kernel instead of Win32. Therefore, you need to create a symbolic link to make the kernel device name available to Win32.

The old method calls iocreatesymboliclink and uses parameters to pass the appropriate symbolic link name and device link name. The main idea of the new method is to define an available application programming interface for the device object. The Globally Unique Identifier (guid) is used to identify this interface. Guid must be generated using the guidgen tool and the device interface defined by yourself is declared in guid. h. Call the ioregisterdeviceinterface function in the adddevice routine to register its interface, and then call iosetdeviceinterfacestate to enable this device interface.
2. the user-State program calls the driver.

EZ-USB series ezusb. sys is a driver that can be directly used without modification. If there are no special requirements when developing external devices, you can use this driver as the device's USB interface driver, of course, the premise is that the device must use EZ-USB USB control chip.

Use iocreatesymboliclink in ezusb. sys to create a symbolic link and provide the device names available to user-mode programs. Therefore, the user State program first obtains the handle of the device driver by calling a Win32 function createfile (). Then, it uses the deviceiocontrol () function to return the handle through the createfile () function, to submit the I/O Control Code and related input and output buffer to the driver to complete the USB data transmission task in windows.

3. Relationship between firmware code, drivers, and client programs

Firmware code is very important. It mainly implements device initialization and configuration. The driver is mainly responsible for processing various IRPs, and the client sends IRPs to implement specific functions.

For example, the data is output from ep2out to the chip, and the data is read from ep2in to the host. The output buffer address of the two ends of the 2131 chip is 7dc0 and the input buffer address is 7e00, which requires the firmware program to copy all the data in the input buffer of the two ends to the output buffer. After the client sends a read/write command, it obtains the device handle through the createfile () function, and then calls the deviceiocontrol () function to submit the I/O Control Code and related input/output buffer to the driver. The driver is responsible for processing IRPs and data communication.

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.