1 | XT keyboard protocol and signalling
|
---|
2 | ===================================
|
---|
3 |
|
---|
4 | The keyboard comnmunicates with the PC/XT through a mostly single-direction
|
---|
5 | serial link.
|
---|
6 |
|
---|
7 | Both the data and clock line are open collector. When the system is idle, both
|
---|
8 | are floating high. It is unclear wether it's up to the keyboard or PC to have
|
---|
9 | pull-up resistors, but it is safe to have both.
|
---|
10 |
|
---|
11 | When the keyboard wants to send a byte:
|
---|
12 | - It waits for the CLK and DAT lines to be high, meaning the PC is ready to
|
---|
13 | receive a byte.
|
---|
14 | - It sends the byte for the keycode. There is a start bit (DATA=1), followed by
|
---|
15 | the 7-bit keycode (LSb first), and the make/break bit (set for release, clear
|
---|
16 | for key press).
|
---|
17 |
|
---|
18 | As the 9th bit is pushed, the PC will force the clock line low until the CPU has
|
---|
19 | read the received byte and cleared the receiving register.
|
---|
20 |
|
---|
21 | Timing is not critical as this is handled on the PC side using a shift register.
|
---|
22 | The only limitation is that the clock signal is gated with the CPU clock, and
|
---|
23 | should not go faster than 2.3MHz.
|
---|
24 |
|
---|
25 | The PC stores the data on the falling edge of the clock. It can also reset the
|
---|
26 | keyboard by pulling the clock line low for too long (10ms or more). At boot and
|
---|
27 | upon reset, the keyboard is supposed to send 0xAA when it is ready to work.
|
---|
28 | However, I'm not sure my XT clone BIOS actually checks for that.
|
---|
29 |
|
---|
30 | It is up to the keyboard to manage the states of the LEDs. At power on, the LEDs
|
---|
31 | are off. They are switched by pressing CAPS and NUM locks. It's possible that
|
---|
32 | they get out of sync with the caps/num state the computer has. It is also up to
|
---|
33 | the keyboard to handle typematic (key repeat) and a keyboard buffer, if needed.
|
---|
34 |
|
---|
35 | The scancodes are the same as PS/2 keyboards scan code set 1. Unfortunately, a
|
---|
36 | lot of keyboards won't support this properly, so we use the default scan code
|
---|
37 | set 2 (used by Windows, so it should work everywhere) and translate it back
|
---|
38 | using a lookup table.
|
---|