Why not USB?

USB pro's and con's

  • Unfortunately EBAZ4205 has no USB interface. 
  • However I found a way to implement it using a cheap external module USB3300. I ordered it and I'm now looking forward to arriving it from China.
  • Anyway to interface such an external module  I'll need to use 12 or more EBAZ4205 pins on a total of 42 (see ULPI)

PS/2 pro's and con's

  • It's a bit obsolete
  • It can use only wired mice (no wireless).
  • Many but not all the USB wired mice can be used with the PS/2 protocol.
  • It doesn't need any hardware addition to EBAZ4205
  • It uses only 2 pins (data and clock)
  • I found an AXI PS2 IP controller from DIGILENT: AXI PS/2 1.0 IP Core User Guide from DIGILENT,. I tried to use it but I didn't succeed! 
  • So I decided to use some VHDL code I found here PS/2 Mouse Interface (VHDL). Unfortunately this VHDL code manage the two buttons PS/2 mouse only and not the middle button and the wheel (so called IntelliMouse), so I had to integrate the VHDL code.
  • Then I also found a linux device driver  xilinx_ps2.c with a similar memory mapped interface that I hope to be able to adapt.

Anyway I have a lot of work to do ...

Block Diagram

This block diagram depicts what I'd like to do.

From right to left.

  • My PS/2 Mouse without cover. I disconnected the USB cable (Yes, most wired modern mice can handle both USB and PS/2). I connected a resistive partitor to adapt voltages (3.3 V on FPGA side and +5 V on Mouse side). DONE
  • FPGA VHDL code: ps2_mouse. I partially rewrote it to configure the mouse to use the third button (wheel press) and wheel rotation. It also generates an interrupt (NEW_EVENT) when a new 32 bits word (mouse X,Y,Z and buttons) is available. DONE
  • FPGA AXI_GPIO IP. It generates an interrupt when anyone of the 32 input bits change it's a standard Xilinx IP. DONE
  • Linux Device Driver. On receiving an interrupt, it shoud read and decode the 32 bits word. WORK IN PROGRESS. At the moment I managed to receive interrupts and read and decode the 32 bit word using a standalone (baremetal) C program.

PS/2 Mouse

My PS/2 Mouse.

See the two resistive partitors for clock and data on the right.

It uses an A2636 chip. See here its A2636 Datasheet

A few facts:

  • reading the datasheet I can understand that such a chip can handle USB or PS/2 communications. 
    • USB D+    <---->   PS/2 Data
    • USB D-    <---->   PS/2 Clock
  • The A2636 automatically switch to PS/2 when the two pins are pulled up to +5V with 2KOhm resistors.

PS/2 Protocol

For a complete description see: Mouse PS/2 Interface

On power-up the PS/2 Mouse starts in "reset mode". I.e. it doesn't send coordinates but continuosly  say:

Mouse: AA  Self-test passed
Mouse: 00  Mouse ID
Mouse: AA  Self-test passed
Mouse: 00  Mouse ID

...

To configure it, an initialization process must be done.

In such a process the mouse can be set:

  • as a standard mouse (two buttons) 
  • or IntelliMouse (three buttons and wheel)
  •  and other minor optional settings.

At the end of the initialization process, the PS/2 Mouse will stream 4 bytes at every change of its buttons, wheel and position X or Y to the PS2MOUSE IP block. See the following example:

  • yellow=clock, blue=data   
  • data are: start 8 bits parity stop 
  • start=0 stop=1 
  • parity=
    • 0 if the number of ones in 8 bits data is odd
    • 1 otherwise
  • data are sampled on the clock rising edge 

These 4 bytes are packed into a 32 bits word by the PS2MOUSE IP block and  read by the AXI-GPIO.

At every new 32 bits word, the AXI-GPIO generates also an interrupt which will be handled by a linux device driver.

To understand the content of the 4 bytes see Mouse PS/2 Interface

PS2MOUSEDRIVER

This is the name of the Linux Device Driver I'm developing to:

  • be alerted at every reception of a new 32 bits word
  • decode the 32 bits into movements X Y Z (Z is the mouse wheel)...
Read more »