Basic Mouse Conecpt:
The concept for the mouse controller is to take the serial data clocked in by the mouse and verify the data received and when requested to send it internally to the next logic block. The mouse sends a serial data stream consisting of 3 packets each with 11 bits. Of the 11 bits there is a start bit, stop bit, parity and 8 bits of data. The first packet contains the three mouse buttons, direction of x and y travel as well as if a value overflow has occurred. The second packet contains the magnitude of the x value of travel, and the final packet contains the magnitude of the y value of travel.
The serial data is clocked into the FPGA with the Mouse clock sent with
the data. This clock runs between 30 - 50us in length and can vary with
each mouse used. To start mouse transmission we must send the correct command.
The mouse clock line is held low for a period of 60 us which disables any
mouse originating data, 60 us is used because this value is longer than
the clock period and we can be sure that
there will be no transmission. Upon releasing the Clock line we apply
a 0 to the data line. On the first rising edge the mouse receives this
0
and is ready for us to send a command. Immediately following the 0
we send F4 LSB first. This is the command to start Sending us packets at
the default rate of 100 transmissions a second.
We can then prepare to accept data from the mouse. The first start bit occurs on the rising edge of the mouse clock. By using shift registers we receive each of the three packets. We then verify the data contained within the packet by checking the parity. It is then held until requested for by the system.
Data Packets:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Overflow |
Overflow |
Sign Bit |
Sign Bit |
|
Button Bit |
Button Bit |
Button Bit |
|
|
|
|
Bit [7] MSB |
Bit [6] |
Bit [5] |
Bit [4] |
Bit [3] |
Bit [2] |
Bit [1] |
Bit [0] LSB |
|
|
|
|
Bit [7] MSB |
Bit [6] |
Bit [5] |
Bit [4] |
Bit [3] |
Bit [2] |
Bit [1] |
Bit [0] LSB |
|
|
Mouse Commands:
Command | Hex Value |
Reset Mouse
Mouse Returns AA, 00 after self-test |
FF |
Resend Message | FE |
Set to Default Values | F6 |
Enable Mouse Streaming Mode
Mouse starts sending data packets at default rate |
F4 |
Disable Streaming Mode | F5 |
Set Sampling rate
XX is the number of packets per second |
F3, XX |
Read Device Type | F2 |
Set Remote Mode | EE |
Set Wrap Mode
Mouse returns data sent by system |
EC |
Read Remote Data
Mouse sends 1 data packet |
EB |
Set Stream Mode | EA |
Status Request
Mouse returns 3-bytes with current settings |
E9 |
Set Resolution
XX is 0, 1, 2, 3 |
E8, XX |
Set Scaling 2 to 1 | E7 |
Reset Scaling | E6 |
Mouse Messages:
Message Sent | Hex Value |
Resend Message | FE |
2 Bad messages in a row | FC |
Mouse Acknowledge Command
Sent by mouse after each command byte |
FA |
Mouse passed self-test | AA |
Refernce Sources
APPLICATION NOTE #4 Mouse implementation on Altera UP1 boards: McDermott, Ashley. Koziar, Kory. Stangeland, Duane
PS2 Mouse Interface to UP1 Board: Rob Chapman
James Hamblen and Michael Furman, Rapid Prototyping of Digital Systems, Kluwer Academic Publishers, Boston, 2000, Ch.11
Altera Corporation, University Program Design Laboratory Package User Guide, version 1, San Jose, CA, August 1997
If you have comments or suggestions, email the iAMP team at:
Todd Carter Dan Ross Stephen TangAny user will include the following notice with any copies
they make of the Copyrighted Materials, including any technical or educational
publications that incorporate any portion of the Copyrighted Materials:
"Altera is a trademark and service mark of Altera Corporation in the United
States and other countries. Altera products are the intellectual property
of Altera Corporation and are protected by copyright laws and one or more
U.S. and foreign patents and patent applications."