aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-02-10 11:05:18 +0900
committertmk <nobody@nowhere>2014-02-10 11:05:18 +0900
commit902afcc509cf5d84b24f71297591cb7cb3d7493d (patch)
tree9e18b65bf2ce218cd7cf722d210ef0257892746a
parent0f827cf94ccd6bef490ba889bc86c61483b1eb80 (diff)
downloadqmk_firmware-902afcc509cf5d84b24f71297591cb7cb3d7493d.tar.gz
qmk_firmware-902afcc509cf5d84b24f71297591cb7cb3d7493d.zip
Add doc 4704.txt and protocol comment
-rw-r--r--converter/ibm4704_usb/4704.txt147
-rw-r--r--protocol/ibm4704.c40
2 files changed, 180 insertions, 7 deletions
diff --git a/converter/ibm4704_usb/4704.txt b/converter/ibm4704_usb/4704.txt
new file mode 100644
index 000000000..db584970d
--- /dev/null
+++ b/converter/ibm4704_usb/4704.txt
@@ -0,0 +1,147 @@
14704 Keyboard
2=============
3Keyboard Models:
4 Model 100 6019273 50-key (grid layout)
5 Model 200 6019284 62-key Alpha(60% layout)
6 Model 300 6019303 77-key Expanded Alpha
7 Model 400 6020218 107-key Full key
8
9Resourse
10--------
11The IBM 4704: lots of pictures and info
12http://kishy.dyndns.org/?p=648#more-648
13
14Brochure:
15http://ed-thelen.org/comp-hist/IBM-ProdAnn/4700.pdf
16
17
18
19
204704 Keyboard Protocol
21======================
22On powering up the keyboard sends keyboard id; A3h for 6019284(62-key), for example.
23After that firmware enters FC command mode and waits for parameter data from host
24so that it doesn't send any scancode until you send 'FF'(End of FC command).
25
26
27Keyboard to Host
28----------------
29Data bits are LSB first and Pairty is odd. Clock has around 60us high and 30us low part.
30
31 ____ __ __ __ __ __ __ __ __ __ ________
32 Clock \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
33 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
34 Data ____/ X____X____X____X____X____X____X____X____X____X________
35 Start 0 1 2 3 4 5 6 7 P Stop
36
37Start bit: can be long as 300-350us.
38Inhibit: Pull Data line down to inhibit keyboard to send.
39Timing: Host reads bit while Clock is hi.
40Stop bit: Keyboard pulls down Data line to lo after 9th clock.
41
42
43
44Host to Keyboard
45----------------
46Data bits are LSB first and Pairty is odd. Clock has around 60us high and 30us low part.
47
48 ____ __ __ __ __ __ __ __ __ __ ________
49 Clock \______/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
50 ^ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___
51 Data ____|__/ X____X____X____X____X____X____X____X____X____X \___
52 | Start 0 1 2 3 4 5 6 7 P Stop
53 Request by host
54
55Start bit: can be long as 300-350us.
56Request: Host pulls Clock line down to request to send a command.
57Timing: After Request keyboard pull up Data and down Clock line to low for start bit.
58 After request host release Clock line once Data line becomes hi.
59 Host wirtes a bit while Clock is hi and Keyboard reads while low.
60Stop bit: Host releases or pulls up Data line to hi after 9th clock and waits for keybaord pull down the line to lo.
61
62
63
64Scancodes
65---------
66Keyboard doesn't send Break code for all keys except for Alt by default.
67
68 6019284 62-key:
69 ,-----------------------------------------------------------.
70 | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|???|BS |
71 |-----------------------------------------------------------|
72 |Tab | Q| W| E| R| T| Y| U| I| O| P| ¢| \| PD2|
73 |-----------------------------------------------------------|
74 |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| {}| PD3|
75 |-----------------------------------------------------------|
76 |Shif| <>| Z| X| C| V| B| N| M| ,| ,| /|???|Shift |
77 |-----------------------------------------------------------|
78 |Reset|blk|Alt | Space |Alt |blk|Enter|
79 `-----------------------------------------------------------'
80 +----------+---------------------+----------+----------+
81 |` 00|PD1 04|Caps 20|LShift 30|Reset 31|
82 |1 18|q 05|a 21|<> 3E|Rblank 41|
83 |2 19|w 06|s 22|z 32|Alt 3F|
84 |3 1A|e 13|d 23|x 33|Space 40|
85 |4 10|r 14|f 24|c 34|Alt 3F|
86 |5 11|t 15|g 25|v 35|Lblank 42|
87 |6 12|y 16|h 26|b 36|Enter 2F|
88 |7 08|u 17|j 27|n 37| |
89 |8 09|i 01|k 28|m 38| |
90 |9 0A|o 02|l 29|, 39| |
91 |0 0F|p 03|; 2A|. 3A| |
92 |- 1F|¢ 1B|' 2B|/ 3B| |
93 |= 0D|\ 1C|{} 2C|??? 3C| |
94 |??? 0C|PD2 1D|PD3 2D|RShift 3D| |
95 |BS 0E| | | | |
96 +----------+---------------------+----------+----------+
97 Bit7 is 'press flag' which set 1 on press and 0 on release when break code is enabled.
98
99NOTE: When break code is enabled the key sends scancode with setting 7th bit on press
100and without it on release. That is, '`' sends 80h on press and 00h on release.
101
102
103keyboard command
104----------------
105 FF Soft Reset(0008h)
106 FE Resend(00e8h)
107 FD Buzzer stop?(00edh)
108 FC Set Key flag(00f6h)
109 FB Soft Reset(0008h)
110 FA Reset(0000h)
111
112
113Keyboard response
114-----------------
115 FF Not exist. [Outgoing buffer cannot have FFh(00h in fact)]
116 FE Overflow(key event/receive data) at 00c5h, 0346h
117 FE Memory test error at 0224h
118 FD Command out of bound at 00d8h
119 Key out of bound
120 7E Read/Parity error in receive from host at 00bch
121
122
123Set Key flag command(FC)
124------------------------
125After 'Power on Reset' firmware enters this command mode and waits for data from host,
126so that you don't need to send 'FC' and it doesn't send any scancode until you send 'FF'.
127
128Data sent from host:
129
130 bit: 7 6 ... 0
131 en | |
132 | `-----`--- scan code
133 `------------- enable bit(0: enable repeat, 1: enable break)
134
135 00-77 Enable repeat(78-7F: invalid scancode)
136 80-F7 Enable break(F8-FF: invalid scancode)
137 FE Resend(011ah) no need to use
138 FF End(0114h) exits FC command mode.
139
140Response from keyboard:
141 FD Out of bound - Invalid scancode
142
143Examples:
144 To enable break code of all keys.
145
146 FC 80 81 ... F7 FF
147
diff --git a/protocol/ibm4704.c b/protocol/ibm4704.c
index d3fbcc541..10e229fd1 100644
--- a/protocol/ibm4704.c
+++ b/protocol/ibm4704.c
@@ -23,6 +23,25 @@ void ibm4704_init(void)
23 inhibit(); 23 inhibit();
24} 24}
25 25
26/*
27Host to Keyboard
28----------------
29Data bits are LSB first and Parity is odd. Clock has around 60us high and 30us low part.
30
31 ____ __ __ __ __ __ __ __ __ __ ________
32Clock \______/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
33 ^ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___
34Data ____|__/ X____X____X____X____X____X____X____X____X____X \___
35 | Start 0 1 2 3 4 5 6 7 P Stop
36 Request by host
37
38Start bit: can be long as 300-350us.
39Request: Host pulls Clock line down to request to send a command.
40Timing: After Request keyboard pull up Data and down Clock line to low for start bit.
41 After request host release Clock line once Data line becomes hi.
42 Host writes a bit while Clock is hi and Keyboard reads while low.
43Stop bit: Host releases or pulls up Data line to hi after 9th clock and waits for keyboard pull down the line to lo.
44*/
26uint8_t ibm4704_send(uint8_t data) 45uint8_t ibm4704_send(uint8_t data)
27{ 46{
28 bool parity = true; // odd parity 47 bool parity = true; // odd parity
@@ -85,13 +104,20 @@ uint8_t ibm4704_recv_response(void)
85} 104}
86 105
87/* 106/*
88Keyboard to Host: 107Keyboard to Host
89Clock ~~~~___~~_~~_~~_~~_~~_~~_~~_~~_~~_~~~~~~~~ H:60us/L:30us 108----------------
90 109Data bits are LSB first and Parity is odd. Clock has around 60us high and 30us low part.
91Data ____~~X==X==X==X==X==X==X==X==X==X________ 110
92 | 0 1 2 3 4 5 6 7 P(odd) 111 ____ __ __ __ __ __ __ __ __ __ ________
93 | LSB MSB 112Clock \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
94 Start bit(80us) 113 ____ ____ ____ ____ ____ ____ ____ ____ ____ ____
114Data ____/ X____X____X____X____X____X____X____X____X____X________
115 Start 0 1 2 3 4 5 6 7 P Stop
116
117Start bit: can be long as 300-350us.
118Inhibit: Pull Data line down to inhibit keyboard to send.
119Timing: Host reads bit while Clock is hi.
120Stop bit: Keyboard pulls down Data line to lo after 9th clock.
95*/ 121*/
96uint8_t ibm4704_recv(void) 122uint8_t ibm4704_recv(void)
97{ 123{