]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - ADB.txt
changed special mode key for macway: Left Shift + Right Shift
[max/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     Female socket from the front
27
28       4o  o3
29      2o    o1
30         ==
31
32     1: Data
33     2: Power SW(low when press Power key)
34     3: Vcc(5V)
35     4: GND
36
37
38 Commands
39 --------
40     ADB command is 1byte and consists of 4bit-address, 2bit-command
41     type and 2bit-register. The commands are always sent by Host.
42
43     Command format:
44     7 6 5 4 3 2 1 0
45     | | | |------------ address
46             | |-------- command type
47                 | |---- register
48
49     bits                commands
50     ------------------------------------------------------
51     - - - - 0 0 0 0     Send Request(reset all devices)
52     A A A A 0 0 0 1     Flush(reset a device)
53     - - - - 0 0 1 0     Reserved
54     - - - - 0 0 1 1     Reserved
55     - - - - 0 1 - -     Reserved
56     A A A A 1 0 R R     Listen(write to a device)
57     A A A A 1 1 R R     Talk(read from a device)
58
59     The command to read keycodes from keyboard is 0x2C which
60     consist of keyboard address 2 and Talk against register 0. 
61
62     Address:
63     2:  keyboard
64     3:  mice
65
66     Registers:
67     0: application(keyobard uses this to store its data.)
68     1: application
69     2: application(keyboard uses this for LEDs and state of modifiers)
70     3: status and command
71
72
73 Communication
74 -------------
75     This is a minimum information for keyboard communication.
76     See "Resources" for detail.
77
78     Signaling:
79
80     ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~
81
82         |800us     |  |7 Command 0|  |   |  |15-64  Data  0|Stopbit(0)
83         +Attention |              |  |   +Startbit(1)
84                    +Startbit(1)   |  +Tlt(140-260us)
85                                   +stopbit(0)
86
87     Bit cells:
88
89     bit0: ______~~~
90           65    :35us
91
92     bit1: ___~~~~~~
93           35 :65us
94
95     bit0 low time: 60-70% of bit cell(42-91us)
96     bit1 low time: 30-40% of bit cell(21-52us)
97     bit cell time: 70-130us
98     [from Apple IIgs Hardware Reference Second Edition]
99
100     Criterion for bit0/1:
101     After 55us if line is low/high then bit is 0/1.
102
103     Attention & start bit:
104     Host asserts low in 560-1040us then places start bit(1).
105
106     Tlt(Stop to Start):
107     Bus stays high in 140-260us then device places start bit(1).
108
109     Global reset:
110     Host asserts low in 2.8-5.2ms. All devices are forced to reset.
111
112     Send request from device(Srq):
113     Device can request to send at commad(Global only?) stop bit.
114     keep low for 300us to request.
115
116
117 Keyboard Data(Register0)
118     This 16bit data can contains two keycodes and two released flags.
119     First keycode is palced in upper byte. When one keyocode is sent,
120     lower byte is 0xFF.
121     Release flag is 1 when key is released.
122
123     1514 . . . . . 8 7 6 . . . . . 0
124      | | | | | | | | | +-+-+-+-+-+-+-   Keycode2
125      | | | | | | | | +---------------   Released2(1 when the key is released)
126      | +-+-+-+-+-+-+-----------------   Keycode1
127      +-------------------------------   Released1(1 when the key is released)
128
129     Keycodes:
130     Scancode consists of 7bit keycode and 1bit release flag.
131     Device can send two keycodes at once. If just one keycode is sent
132     keycode1 contains it and keyocode2 is 0xFF.
133
134     Power switch:
135     You can read the state from PSW line(active low) however
136     the switch has a special scancode 0x7F7F, so you can
137     also read from Data line. It uses 0xFFFF for release scancode.
138
139 Keyboard LEDs & state of keys(Register2)
140     This register hold current state of three LEDs and nine keys.
141     The state of LEDs can be changed by sending Listen command.
142     
143     1514 . . . . . . 7 6 5 . 3 2 1 0
144      | | | | | | | | | | | | | | | +-   LED1(NumLock)
145      | | | | | | | | | | | | | | +---   LED2(CapsLock)
146      | | | | | | | | | | | | | +-----   LED3(ScrollLock)
147      | | | | | | | | | | +-+-+-------   Reserved
148      | | | | | | | | | +-------------   ScrollLock
149      | | | | | | | | +---------------   NumLock
150      | | | | | | | +-----------------   Apple/Command
151      | | | | | | +-------------------   Option
152      | | | | | +---------------------   Shift
153      | | | | +-----------------------   Control
154      | | | +-------------------------   Reset/Power
155      | | +---------------------------   CapsLock
156      | +-----------------------------   Delete
157      +-------------------------------   Reserved
158
159 END_OF_ADB