]> git.gir.st - tmk_keyboard.git/blob - ADB.txt
fixed: not to send key if fn_keycode is modifier
[tmk_keyboard.git] / ADB.txt
1 ADB Protocol
2 ============
3
4 Resources
5 ---------
6 ADB - The Untold Story: Space Aliens Ate My Mouse
7 http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html
8 Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
9 ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
10 ADB Keycode
11 http://72.0.193.250/Documentation/macppc/adbkeycodes/
12 http://m0115.web.fc2.com/m0115.jpg
13 [Inside Macintosh volume V, pages 191-192]
14 ADB Signaling
15 http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
16 ADB Overview & History
17 http://en.wikipedia.org/wiki/Apple_Desktop_Bus
18 Microchip Application Note: ADB device(with code for PIC16C)
19 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062
20 AVR ATtiny2131 ADB to PS/2 converter(Japanese)
21 http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html
22
23
24 Pinouts
25 -------
26 ADB female socket from the front:
27 __________
28 | | <--- top
29 | 4o o3 |
30 |2o o1|
31 | == |
32 |________| <--- bottom
33 | | <--- 4pins
34
35
36 ADB female socket from bottom:
37
38 ========== <--- front
39 | |
40 | |
41 |2o o1|
42 |4o o3|
43 ---------- <--- back
44
45 1: Data
46 2: Power SW(low when press Power key)
47 3: Vcc(5V)
48 4: GND
49
50
51
52 Commands
53 --------
54 ADB command is 1byte and consists of 4bit-address, 2bit-command
55 type and 2bit-register. The commands are always sent by Host.
56
57 Command format:
58 7 6 5 4 3 2 1 0
59 | | | |------------ address
60 | |-------- command type
61 | |---- register
62
63 bits commands
64 ------------------------------------------------------
65 - - - - 0 0 0 0 Send Request(reset all devices)
66 A A A A 0 0 0 1 Flush(reset a device)
67 - - - - 0 0 1 0 Reserved
68 - - - - 0 0 1 1 Reserved
69 - - - - 0 1 - - Reserved
70 A A A A 1 0 R R Listen(write to a device)
71 A A A A 1 1 R R Talk(read from a device)
72
73 The command to read keycodes from keyboard is 0x2C which
74 consist of keyboard address 2 and Talk against register 0.
75
76 Address:
77 2: keyboard
78 3: mice
79
80 Registers:
81 0: application(keyobard uses this to store its data.)
82 1: application
83 2: application(keyboard uses this for LEDs and state of modifiers)
84 3: status and command
85
86
87 Communication
88 -------------
89 This is a minimum information for keyboard communication.
90 See "Resources" for detail.
91
92 Signaling:
93
94 ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~
95
96 |800us | |7 Command 0| | | |15-64 Data 0|Stopbit(0)
97 +Attention | | | +Startbit(1)
98 +Startbit(1) | +Tlt(140-260us)
99 +stopbit(0)
100
101 Bit cells:
102
103 bit0: ______~~~
104 65 :35us
105
106 bit1: ___~~~~~~
107 35 :65us
108
109 bit0 low time: 60-70% of bit cell(42-91us)
110 bit1 low time: 30-40% of bit cell(21-52us)
111 bit cell time: 70-130us
112 [from Apple IIgs Hardware Reference Second Edition]
113
114 Criterion for bit0/1:
115 After 55us if line is low/high then bit is 0/1.
116
117 Attention & start bit:
118 Host asserts low in 560-1040us then places start bit(1).
119
120 Tlt(Stop to Start):
121 Bus stays high in 140-260us then device places start bit(1).
122
123 Global reset:
124 Host asserts low in 2.8-5.2ms. All devices are forced to reset.
125
126 Send request from device(Srq):
127 Device can request to send at commad(Global only?) stop bit.
128 keep low for 300us to request.
129
130
131 Keyboard Data(Register0)
132 This 16bit data can contains two keycodes and two released flags.
133 First keycode is palced in upper byte. When one keyocode is sent,
134 lower byte is 0xFF.
135 Release flag is 1 when key is released.
136
137 1514 . . . . . 8 7 6 . . . . . 0
138 | | | | | | | | | +-+-+-+-+-+-+- Keycode2
139 | | | | | | | | +--------------- Released2(1 when the key is released)
140 | +-+-+-+-+-+-+----------------- Keycode1
141 +------------------------------- Released1(1 when the key is released)
142
143 Keycodes:
144 Scancode consists of 7bit keycode and 1bit release flag.
145 Device can send two keycodes at once. If just one keycode is sent
146 keycode1 contains it and keyocode2 is 0xFF.
147
148 Power switch:
149 You can read the state from PSW line(active low) however
150 the switch has a special scancode 0x7F7F, so you can
151 also read from Data line. It uses 0xFFFF for release scancode.
152
153 Keyboard LEDs & state of keys(Register2)
154 This register hold current state of three LEDs and nine keys.
155 The state of LEDs can be changed by sending Listen command.
156
157 1514 . . . . . . 7 6 5 . 3 2 1 0
158 | | | | | | | | | | | | | | | +- LED1(NumLock)
159 | | | | | | | | | | | | | | +--- LED2(CapsLock)
160 | | | | | | | | | | | | | +----- LED3(ScrollLock)
161 | | | | | | | | | | +-+-+------- Reserved
162 | | | | | | | | | +------------- ScrollLock
163 | | | | | | | | +--------------- NumLock
164 | | | | | | | +----------------- Apple/Command
165 | | | | | | +------------------- Option
166 | | | | | +--------------------- Shift
167 | | | | +----------------------- Control
168 | | | +------------------------- Reset/Power
169 | | +--------------------------- CapsLock
170 | +----------------------------- Delete
171 +------------------------------- Reserved
172
173 END_OF_ADB
Imprint / Impressum