the university of north carolina at chapel hill keyboard interface anselmo lastra

14
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

Upload: abraham-matthews

Post on 23-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Keyboard Interface

Anselmo Lastra

Page 2: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

2

PS/2 Keyboard

• Uses a synchronous serial protocol♦ What does that mean?

Page 3: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

3

Physical Interface

• Two lines♦ Clock (10-20KHz)♦ Data

• Asserted low• There’s documentation in

NEXYS board manual, starting on P. 7

Page 4: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

4

Bidirectional

• Kybd-to-host and host-to-kybd on same wires♦ CAPS LOCK light for example

• To send, host takes data line low♦ Sometimes take clk low first

• Then kybd starts clocking♦ Host sends data synced to kybd clock

• You shouldn’t need to send to kybd

Page 5: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

5

Protocol

• 11 bits♦ Start – always 0♦ 8 bits of data♦ Odd parity bit♦ Stop bit – always 1

• Clocked by keyboard• Value should be latched on

negedge of keyboard clock♦ Slow enough that you could easily build

simple FSM and clock on your 50 MHz clock

Illustration from http://www.beyondlogic.org/keyboard/keybrd.htm

Page 6: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

6

What is Sent

• ASCII is not sent• Scan codes for keys♦ Least significant bit first

Illustration from http://www.beyondlogic.org/keyboard/keybrd.htm

Page 7: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

7

Scan Codes

• Normally translated by software♦ You remap your keys, for example

• Software takes care of♦ Shift, caps lock, control

Page 8: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

8

Some Scan Codes Long

• Two code sequence common• Have a look at Break key!

Page 9: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

9

Even More Complicated

• Scan code generated when you press

• And when you release♦ Two bytes: F0 followed by key scan code♦ Example:

• Space pressed, 29 sent• Space released, F0 29 sent

• If you hold key, scan code repeated

Page 10: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

10

Resources

• Informationhttp://www.beyondlogic.org/keyboard/keybrd.htm

• Scan codeshttp://www.barcodeman.com/altek/mule/scandoc.php

• There is also Verilog for keyboard interfaces available on web.

Page 11: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

11

My Verilog

• Have Verilog for keyboard• Have not ported to new FPGA• To use♦ You should memory-map the character

code register♦ Maybe add a single bit register to

indicate that new character has arrived

Page 12: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Mouse

• Very similar interface (clk & data)

• 3 words sent w/ mouse movement or button press

12

Page 13: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Movement

• Movement is relative• XS, YS are sign (+ is up/right)• XV, YV are overflow (too fast)• L, R are buttons (the 0 is

middle?)

13

Page 14: The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Keyboard Interface Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Scroll Wheel, etc.

• Extensions to original 2 button PS/2 mouse

• Seehttp://www.computer-engineering.org/ps2mouse/

14