Standard for USB development steps

Source: Internet
Author: User
USB development steps-standard article translated from the world of electronic products author Xiaobing Universal Serial Bus (Universal Serial Bus) is an external bus structure used to connect peripheral USB devices to the host, it is mainly used for peripherals with medium speed and low speed. USB is connected to the internal system data line of the PC through the PCI bus to realize data transmission. USB is also a communication protocol. It supports data transmission between the host and the USB peripheral device. In the USB network protocol, each USB system has only one host, so many friends ask me if I can connect the USB ports of the two PCs through the A-A header, can realize communication, this is not acceptable, because the USB devices on the computer motherboard are all hosts. If two hosts are connected, a USB system has two hosts, conflict with its network protocol. Anchorchip has a device that can be directly connected (like an2720sc). In fact, it is a chip consisting of two USB devices with backbacks. It needs to sell more than 80 knives, it's too expensive! USB has the following advantages: USB provides a single, easy-to-operate standard connection type for all USB peripherals. In this way, the design of USB peripherals is simplified, and the task for users to determine which plug corresponds to which slot is also simplified, achieving a single universal data interface. USB removes the need for removing system resources from various devices, such as the mouse, modem, keyboard, and printer devices, thus reducing hardware complexity and port occupation, the whole USB system only has one port and one interrupt, saving system resources. USB supports hot plug (hot plug). In other words, you can safely plug and disconnect the USB device and dynamically load the driver without stopping the PC. Other general peripheral connection standards, such as SCSI devices, can be added or removed only when the host is turned off. USB supports PNP. When a USB device is inserted, the computer system detects the device and automatically loads the relevant driver to configure the device and make it work properly. USB provides flexibility in device power supply. USB directly connects to the hub or the device connected to the host can be powered by a USB cable, battery or other power devices, or a combination of two power supply methods. it also supports power-saving host mounting and wake-up modes. USB provides a speed of 12 Mbps at full speed and a speed of Mbps at low speed to adapt to various types of peripherals. For devices that cannot handle sudden non-continuous transmission, such as audio and video devices, USB can ensure its fixed bandwidth. To meet the requirements of various types of peripheral devices, USB provides four different data transfer types. USB enables multiple peripheral devices to communicate with the host. USB objective: 1. Easy to use 2. provide real-time data to PC 3. Flexible port scalability USB standard can. At the same time, it also has a USB check tool that can detect hid (Human Interface Device) devices. Win98 also has an "ignore Hubs" (Memphis only) detection window. A usb View tool included in w2k DDK shows all the USB buses in the system and all the devices on the USB bus. Members of the USB Forum (USB Forum) only need to pay $2500 each year to get a vendor ID. In fact, the retail price of each vendor ID is only $200, however, members of each USB forum can enjoy many benefits in terms of USB support. (For the Chinese, it is a waste of money to get a USB member.) the USB device type (device class) although the USB device shows some basic features of USB. However, USB devices can still be divided into multiple different types, and devices of the same type can have some common behavior characteristics and work protocols, thus making the writing of the device driver easier. The following table lists some basic types of USB devices. Device class (device class) constant (class constant) Audio (audio) speaker guest communication guest keyboard mouse usb_device_class_human interface display monitor usb_device_class_monitor physical response device power feedback game joystick guest Power Supply uninterruptible power supply usb_device_class_power printer usb_device_class_printer massive memory hard drive basic features of each device (Device) there will be one or more logical connection points, each of which is called an endpoint. Each endpoint has four data transmission modes: control transmission, isochronous transmission, interrupt transmission, and bulk transmission. however, all endpoint0 are used to transmit configuration and control information. The connection between the host and the device's endpoint is called Pipeline "pipe", and endpoint0 is called default pipe ). The combination of a group of endpoints of the same nature is called an interface. If a device contains more than one interface, it can be called a composite device ). In the same sense, the combination of interfaces of the same type can be called "configuration ). However, only one configuration is available at a time. Once the configuration is activated, the interfaces and endpoints in the configuration can be used at the same time. The host determines which configuration and interface are used from the descriptors sent by the device, and these descriptive words are usually transmitted in endpoint0. The USB driver in the Windows USB driver interface system does a lot of work. In fact, some hid USB devices, such as the keyboard, mouse, and game joystick, can be automatically recognized and supported by the system. other devices need to write a driver to connect the hardware and software. In the kernel mode, the driver uses IOCTL to organize and operate some requirements and commands sent from other components. IOCTL transmits data through urb (USB request blocks. Before officially introducing the USB driver, let's take a look at the physical and logical structure of the USB. There are four transmission modes under the USB data transmission mode: Control synchronization (isochronous) interruption (Interrupt) and bulk ). If you design the entire system from the hardware, you also need to select the correct transmission method, and as a driver writer, you just need to figure out the way he works. Generally, the initiative in all transmission modes is on the PC side, that is, the host side. Control Transmission: control transmission is a two-way transmission with a small amount of data. The USB system software is used to query, configure, and send Common commands to USB devices. The control transmission mode can include 8, 16, 32, and 64 bytes of data, depending on the device and transmission speed. Control transmission is typically used for transmission between the master computer and the USB peripherals (endpoint) 0, but the specified supplier's control transmission may use other endpoints. Synchronous transmission: synchronous transmission provides fixed bandwidth and latency ). It is used for stream data transmission with strict time and strong fault tolerance, or for instant applications that require a constant data transfer rate. For example, synchronous transmission mode is a good choice when you use an instant call network phone application. The bandwidth value and the maximum number of transfers required for data synchronization. For synchronous transmission, real-time data transmission is more important than perfect precision and data integrity. Interrupt transmission: interrupt transmission is used to regularly query whether the device has interrupted data to be transmitted. The structure of the device's endpoint patter determines its query frequency, from 1 to Ms. This transmission mode is typically used to transmit a small amount of scattered and unpredictable data. The keyboard, joystick, and mouse belong to this type. The interrupted transmission mode is unidirectional and only the input mode is used for the host. Bulk transmission: it is mainly used to transmit and receive data in a large amount without bandwidth and interval requirements. It is required to ensure transmission. Printers and scanners belong to this type. This type of device is suitable for very slow transmission and a large amount of delayed transmission. You can transmit and receive data after all other types of data are transferred. USB divides its effective bandwidth into different frames, each of which is usually 1 ms. Each device can send only one synchronous transfer packet per region. After the system configuration information and connection are completed, the USB host will make an overall arrangement for different transfer points and transmission methods to adapt to the overall USB bandwidth. Under normal circumstances, the transmission of synchronization mode and interrupt mode will occupy 90% of the total bandwidth, and the rest will be arranged to transmit data to the control mode. The USB device can be connected to any USB interface on the PC. The hub can be extended to connect more USB devices to the system. The hub of USB has an upstream port (to the host ), there are multiple downstream ports (connected to other devices), so that the entire system can be extended to connect 127 peripherals, the hub is also acid peripherals. For a USB system, the USB host is always on the PC side, and all other connected hosts are called devices, which cannot achieve direct communication between devices, data can be transmitted to each other only through host management and adjustment. in the system, there is usually a root hub, which generally has two downstream ports. A pc can have one or more USB Host controllers. Generally, there are two types of controllers: uhci (USB Host Controller Interface) and OHCI (Open Host Controller Interface ). Windows USB drivers support a miniclass driver for each controller type. USB physical signal the USB cable has four wires, and the two transmit 5 V power supply. Some devices directly connected to the power hub can directly use it for power supply. The other two are data lines. The data lines are single-handed. The data speed in the entire system is certain, either high speed or low speed, there is no device that can change the speed of data streams. at this point, there is a significant difference between USB and 1394. The USB bus can be suspended when it is not used, which saves energy. In some cases, the bus may also be blocked (stall). For example, when data transmission is interrupted, You can reconfigure the host to re-execute the bus. The physical protocol of the Low-layer protocol USB specifies the majority of data formats on the bus. Generally, a full-speed data shard can have a maximum of 1500 bytes, while a low-speed compaction can have a maximum of 187 bytes. Bandwidth is usually used to allocate bandwidth to different data transmission methods. At the same time, due to the regularity of the attention structure, this feature of attention can also be used for synchronous signals. A minimal USB data block is called packet, which includes the synchronous signal, packet ID, CRC, and transmitted data. There are 10 types of packet IDs: tokenout in SOF setupdatadata0 data1handshakeack Nak stallspecialpretransactions (Data Exchange) a transaction is a discontinuous exchange of data between the host and the device, usually, the switch starts from the host, and the switch starts from the token package. Next, the two sides send upstream packets. After the packets are transmitted, the device) returns a handshake packet. The USB system uses the In, out, and setup packages to specify the USB address and endpoint (up to 128, 0 is usually used for default transfer configuration information ), in addition, these specified devices must respond to the specified form through the above form of packets. Each setup package contains eight bytes of data, which is used to indicate the type of data transferred. For data packets, two types of data packets are set to be more precise when data is transmitted. The ack handshake package is used to indicate the correctness of data transmission, while stall handshake indicates that the data packet fails during transmission, and asks the host to resend the data or clear the transfer. The pre-format package is mainly used in a USB system if a device of different speed exists, A Pre package is returned for a device that is different from the bus speed to ignore the device. Different types of packages have different sizes. the maximum data packet size is 1023bytes. Start of frame (SOF) Sof, which is used to indicate the beginning of frame. Sof package contains 11 bit serial numbers, from 0 to 0x7ff (I. e. USBD_ISO_START_FRAME_RANGE-1), Sof is valid for all high-speed devices. Power each device can obtain 100mA of the current from the bus. If you apply to the system, you can obtain a maximum of 500mA of the current. In the suspended state, the current is only UA. install the driver. For Windows, use the device description or interface description to find out what kind of device is connected to the system. The hardware ID initialized by Windows contains the ID domain of the device provider (idvendor, idproduct, and bcddevice ). If you do not provide an INF file to the system, the system will automatically choose to provide a compatible ID (maybe not working very well, just as you bought a rockbench modem, however, if you use a standard modem driver, your modem may have a lot of problems, or it may run fast. Everything about the computer may happen, like Chinese football ........ in year 94, I vowed not to be angry with Chinese football any more, but I scolded the guy named Zhang yusi recently ....... forgive me for being a child !) New Features of USB sharing a physical device can use many different pipe real-time capabilities to achieve effective real-time communication with a device dynamic nature can achieve dynamic switching between interfaces the combination of different and similar feature interfaces can be combined, the default pipe can be automatically used in different power supply modes for different interfaces of the multi-energy system. The establishment and configuration of the base system become automatic and the above aspects are just a brief introduction to the USB standard. in some cases, the uniqueness of the USB host in the system, the bandwidth distribution of the device, and the electrical characteristics of the hub and USB, I will not go into details about the network hierarchy and other aspects. I will give a detailed description in the standards. I am dedicated to giving you a simple introduction in Chinese, hoping that I will not give you incorrect guidance.

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.