PS2 interfaces and protocols

Source: Internet
Author: User
Physical Features of 1 PS/2 interfaces and 1.1 Interfaces

The PS/2 interface is used for many modern mouse and keyboard, which was initially developed and used by IBM. The PS/2 interface physically has two types of connectors: 5-pin din and 6-pin mini-din. Figure 1 defines the pins of the two connectors. in use, the host provides + 5 V power to the mouse, place the cursor over the host power over the ground 。

1.2 Interface Protocol principle

The PS/2 mouse interface adopts a bidirectional Synchronous Serial protocol, that is, each time a pulse is sent on the clock line, one data point is sent on the data line, the host has control over the bus, that is, it can suppress mouse transmission at any time. The method is to keep the clock line down, the mouse cannot generate the clock signal and send data. In both directions, the clock signal is generated by the mouse, that is, the host does not generate the communication clock signal 。

If the host needs to send data, it must control the mouse to generate a clock signal. The method is as follows: the host first pulls down the clock line at least 100 μs to suppress communication, and then pulls down the data line, finally, release the clock line. Control the mouse to generate the clock signal in this chronological order. When the mouse detects the timing status, generates a clock signal within 10 ms. 3. A time series segment. The time series for transmitting data frames between the host and the mouse. 2. Figure 3 shows the time series. 2.2 data packets are structured on the host.ProgramThe clock pulse of each data bit triggers the interrupt, and the data bit judgment and receiving are realized in the Interrupt Routine, the system can properly control and receive mouse data. However, this solution is insufficient because every clock has to be interrupted once, which consumes a lot of Host resources due to frequent interruptions 。

2 PS/2 mouse working mode and Protocol packet format Four working modes of 2.1 PS/2 mouse

PS/2 the four modes of operation for the mouse are reset mode. This mode is used when the mouse is powered on or the host sends the reset command 0xff to it. The default mode for the stream mode mouse is, after the mouse is powered on or reset, it automatically enters this mode. The mouse basically works in this mode. In remote mode, the mouse enters this mode only after the host sends the mode setting command 0xf0; wrap mode. This mode is only used to test whether the connection between the mouse and the host is correct 。

The PS/2 Mouse sends its status data to the host in a timely manner during the working process. The format of the sent data packet is shown in table 1 。

Bit0, bit1, and bit2 in byte1 indicate the status of the left, right, and middle keys, respectively. The status value 0 indicates release, 1 indicates pressing. byte2 and byte3 indicate the moving metering values of the X axis and Y axis respectively, and are binary supplementary values. The four lower bits of byte4 indicate the moving metering values of the wheel and the binary complement values, the four-digit high is used as the extension symbol. This type of data packet is generated by the three-key 3D mouse with a scroll wheel. If the three-Key mouse without a scroll wheel is used, the resulting data packet is not the same as the rest of the byte4 。

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.