aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2011-02-22 02:57:01 +0900
committertmk <nobody@nowhere>2011-02-22 03:49:02 +0900
commit00350c180dee31ec9d9c4aee31e06faf55bd1c6b (patch)
treed54b35ca96ec6bce6c415423cdba4f66d198b433
parentd2b9489a5e19fabb5d6ec285192b19dc25b36d5e (diff)
downloadqmk_firmware-00350c180dee31ec9d9c4aee31e06faf55bd1c6b.tar.gz
qmk_firmware-00350c180dee31ec9d9c4aee31e06faf55bd1c6b.zip
v3.0 cleanse files
-rw-r--r--ADB.txt173
-rw-r--r--README35
-rw-r--r--TODO103
-rw-r--r--adb.c213
-rw-r--r--[-rwxr-xr-x]pjrc/usb.c0
5 files changed, 240 insertions, 284 deletions
diff --git a/ADB.txt b/ADB.txt
deleted file mode 100644
index 63005b3dd..000000000
--- a/ADB.txt
+++ /dev/null
@@ -1,173 +0,0 @@
1ADB Protocol
2============
3
4Resources
5---------
6ADB - The Untold Story: Space Aliens Ate My Mouse
7 http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html
8Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
9 ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
10ADB 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]
14ADB Signaling
15 http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
16ADB Overview & History
17 http://en.wikipedia.org/wiki/Apple_Desktop_Bus
18Microchip Application Note: ADB device(with code for PIC16C)
19 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062
20AVR ATtiny2131 ADB to PS/2 converter(Japanese)
21 http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html
22
23
24Pinouts
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
52Commands
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
87Communication
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
131Keyboard 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
153Keyboard 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
173END_OF_ADB
diff --git a/README b/README
index 3361c1f99..2aa0106b0 100644
--- a/README
+++ b/README
@@ -1,16 +1,19 @@
1t.m.k. Keyboard Firmware 1t.m.k. Keyboard Firmware
2======================== 2========================
3http://github.com/tmk/tmk_keyboard 3This is keyboard firmware for Teensy(AVR USB MCU) and V-USB board.
4
5This is keyboard firmware for AVR USB MCUs or Teensy/Teensy++.
6http://www.pjrc.com/teensy
7 4
8The project is heavily based on PJRC USB Keyboard/Mouse Example and 5source code repository:
9owes a debt to preceding keyboard firmware projects. 6http://github.com/tmk/tmk_keyboard
10 7
11This firmware is used in following projects: 8This firmware is used in following projects:
12HHKB mod: http://geekhack.org/showwiki.php?title=Island:12047 9HHKB mod: http://geekhack.org/showwiki.php?title=Island:12047
13Macway mod: http://geekhack.org/showwiki.php?title=Island:11930 10Macway mod: http://geekhack.org/showwiki.php?title=Island:11930
11PS2 to USB: http://geekhack.org/showwiki.php?title=Island:14618
12ADB to USB: http://geekhack.org/showwiki.php?title=Island:14290
13
14The project is heavily based on PJRC USB Keyboard/Mouse Example and
15owes a debt to preceding keyboard firmware projects.
16http://www.pjrc.com/teensy
14 17
15 18
16Features 19Features
@@ -31,12 +34,27 @@ Limitations
31----------- 34-----------
32 35
33 36
37Files & Directories
38-------------------
39Target:
40hhkb/ keyboard controller for PFU HHKB pro
41macway/ keyboard controller for Macway mod
42ps2_usb/ PS2 to USB keyboard converter
43adb_usb/ ADB to USB keyboard converter
44
45USB Protocol Stack:
46pjrc/ PJRC USB stack
47vusb/ V-USB USB stack
48ps2.[ch] PS/2 protocol
49adb.[ch] ADB protocol
50
51
34Build 52Build
35----- 53-----
36To compile needs AVR GCC, AVR Libc and GNU make. 54To compile needs AVR GCC, AVR Libc and GNU make.
37You can use WinAVR on Windows. http://winavr.sourceforge.net/ 55You can use WinAVR on Windows. http://winavr.sourceforge.net/
38 56
39$ cd <target> (hhkb or macway currently) 57$ cd <target>
40$ make 58$ make
41 59
42The firmware will be compiled as a file tmk_<target>.hex. 60The firmware will be compiled as a file tmk_<target>.hex.
@@ -100,7 +118,8 @@ Build Options
100Debuging & Rescue 118Debuging & Rescue
101----------------- 119-----------------
102Use PJRC's hid_listen.exe to see debug messages. 120Use PJRC's hid_listen.exe to see debug messages.
103Press right Control + Shift + Alt + GUI + H to debug menu. 121Press <COMMAND> + H to debug menu.
122(see config.h for <COMMAND> key combination.)
104 123
105Pressing any 3 keys when connected enables debug output. 124Pressing any 3 keys when connected enables debug output.
106Pressing any 4 keys when connected makes bootloader comes up. 125Pressing any 4 keys when connected makes bootloader comes up.
diff --git a/TODO b/TODO
deleted file mode 100644
index c15e546c5..000000000
--- a/TODO
+++ /dev/null
@@ -1,103 +0,0 @@
1TODO & IDEAS
2------------
3Code cleaning
4 keymap layer definition
5Debug/Config console
6 keymap/layer setting
7 layer switching timing
8 matrix display
9 help
10 display keymap
11 display matrix(row, col)
12 debug console
13 through PJRC console
14 through UART/USB CDC
15 mouse acceleration
16 store setting to EEPROM
17Document
18 development
19Interchangable protocol stack
20 USB
21 PJRC stack(default currently)
22 LUFA
23 original minimal stack for keyboard/mouse
24 PS/2
25 from keyboard-upgrade?
26Layer switch
27 toggle layer switch
28Debouncing logic
29 will be coded when bouncing occurs.
30 bouncing doesnt occur on my ALPS switch so far.
31 scan rate is too slow?(to be measure)
32Child lock
33 disable keyboard to protect against atacking by child
34Windows key blocking
35 disable Windows keys for gamers
36OneHand operation
37 RAlt + Del(or \) to Alt + Tab
38Licensings(GPL)
39 GPL will not be infringement of PJRC license.
40Extra switch
41 foot sw for layer switching
42 mouse button
43PS/2->USB keyboard converter
44 PS/2 keyboard host protocol support
45PS/2,USB detection
46 act as PS/2 keyboard or USB keyboard.
47 PS/2 keyboard device protocol support
48Thinkpad keyboard support
49 turn to USB keyboard/mouse composite device
50Other MCU/board support
51 architectures on which GCC is available.
52 AT90USBKEY and other AVR USB boards
53 Cortex-M3 ARM board(STM32)
54 http://strawberry-linux.com/catalog/items?code=32105
55Separate keyboard support
56 comunicate between keyboards by I2C?
57 this is for ergo keyoboard style.
58
59
60DONE & STATUS
61-------------
62PS2 mouse bug to be FIX'd
63 macway/matrix: line select changes pins for mouse.
64 2010/01/02
65support for HHKB pro matrix signal
66 exchange controller board with teensy
67 2010/10/11
68OneHand operation
69 Matias half keyboard style
70 2010/10/23
71souce code cleaning
72 2010/10/23
73debug on/off
74 debug off by default
75 pressing keys during booting
76 2010/10/23
77mouse horizontal wheel
78 http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521
79 http://www.keil.com/forum/15671/
80 http://www.microsoft.com/whdc/device/input/wheel.mspx
81 2010/10/13
82debug on/off
83 Fn key conbination during normal operation
84 matrix print on/off
85 key print on/off
86 mouse print on/off
87 2010/10/26
88layer switching
89 time before switching
90 timeout when not used during specific time
91 2010/10/30
92Build Option
93 windows media keys suport
94 2010/01/06
95Document
96 build, customize
97 2010/01/06
98Trackpoint(PS/2)
99 receive PS/2 signal from TrackPoint
100 2010/01/02
101 send USB HID report
102
103EOF
diff --git a/adb.c b/adb.c
index 6848fa652..6a3fb8e08 100644
--- a/adb.c
+++ b/adb.c
@@ -1,3 +1,39 @@
1/*
2Copyright (c) 2011 Jun WAKO <wakojun@gmail.com>
3
4This software is licensed with a Modified BSD License.
5All of this is supposed to be Free Software, Open Source, DFSG-free,
6GPL-compatible, and OK to use in both free and proprietary applications.
7Additions and corrections to this file are welcome.
8
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13* Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16* Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in
18 the documentation and/or other materials provided with the
19 distribution.
20
21* Neither the name of the copyright holders nor the names of
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
24
25THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36*/
1#include <stdbool.h> 37#include <stdbool.h>
2#include <util/delay.h> 38#include <util/delay.h>
3#include <avr/io.h> 39#include <avr/io.h>
@@ -191,3 +227,180 @@ static inline uint8_t wait_data_hi(uint8_t us)
191 } 227 }
192 return us; 228 return us;
193} 229}
230
231
232/*
233ADB Protocol
234============
235
236Resources
237---------
238ADB - The Untold Story: Space Aliens Ate My Mouse
239 http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html
240Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
241 ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
242ADB Keycode
243 http://72.0.193.250/Documentation/macppc/adbkeycodes/
244 http://m0115.web.fc2.com/m0115.jpg
245 [Inside Macintosh volume V, pages 191-192]
246ADB Signaling
247 http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
248ADB Overview & History
249 http://en.wikipedia.org/wiki/Apple_Desktop_Bus
250Microchip Application Note: ADB device(with code for PIC16C)
251 http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062
252AVR ATtiny2131 ADB to PS/2 converter(Japanese)
253 http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html
254
255
256Pinouts
257-------
258 ADB female socket from the front:
259 __________
260 | | <--- top
261 | 4o o3 |
262 |2o o1|
263 | == |
264 |________| <--- bottom
265 | | <--- 4pins
266
267
268 ADB female socket from bottom:
269
270 ========== <--- front
271 | |
272 | |
273 |2o o1|
274 |4o o3|
275 ---------- <--- back
276
277 1: Data
278 2: Power SW(low when press Power key)
279 3: Vcc(5V)
280 4: GND
281
282
283
284Commands
285--------
286 ADB command is 1byte and consists of 4bit-address, 2bit-command
287 type and 2bit-register. The commands are always sent by Host.
288
289 Command format:
290 7 6 5 4 3 2 1 0
291 | | | |------------ address
292 | |-------- command type
293 | |---- register
294
295 bits commands
296 ------------------------------------------------------
297 - - - - 0 0 0 0 Send Request(reset all devices)
298 A A A A 0 0 0 1 Flush(reset a device)
299 - - - - 0 0 1 0 Reserved
300 - - - - 0 0 1 1 Reserved
301 - - - - 0 1 - - Reserved
302 A A A A 1 0 R R Listen(write to a device)
303 A A A A 1 1 R R Talk(read from a device)
304
305 The command to read keycodes from keyboard is 0x2C which
306 consist of keyboard address 2 and Talk against register 0.
307
308 Address:
309 2: keyboard
310 3: mice
311
312 Registers:
313 0: application(keyobard uses this to store its data.)
314 1: application
315 2: application(keyboard uses this for LEDs and state of modifiers)
316 3: status and command
317
318
319Communication
320-------------
321 This is a minimum information for keyboard communication.
322 See "Resources" for detail.
323
324 Signaling:
325
326 ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~
327
328 |800us | |7 Command 0| | | |15-64 Data 0|Stopbit(0)
329 +Attention | | | +Startbit(1)
330 +Startbit(1) | +Tlt(140-260us)
331 +stopbit(0)
332
333 Bit cells:
334
335 bit0: ______~~~
336 65 :35us
337
338 bit1: ___~~~~~~
339 35 :65us
340
341 bit0 low time: 60-70% of bit cell(42-91us)
342 bit1 low time: 30-40% of bit cell(21-52us)
343 bit cell time: 70-130us
344 [from Apple IIgs Hardware Reference Second Edition]
345
346 Criterion for bit0/1:
347 After 55us if line is low/high then bit is 0/1.
348
349 Attention & start bit:
350 Host asserts low in 560-1040us then places start bit(1).
351
352 Tlt(Stop to Start):
353 Bus stays high in 140-260us then device places start bit(1).
354
355 Global reset:
356 Host asserts low in 2.8-5.2ms. All devices are forced to reset.
357
358 Send request from device(Srq):
359 Device can request to send at commad(Global only?) stop bit.
360 keep low for 300us to request.
361
362
363Keyboard Data(Register0)
364 This 16bit data can contains two keycodes and two released flags.
365 First keycode is palced in upper byte. When one keyocode is sent,
366 lower byte is 0xFF.
367 Release flag is 1 when key is released.
368
369 1514 . . . . . 8 7 6 . . . . . 0
370 | | | | | | | | | +-+-+-+-+-+-+- Keycode2
371 | | | | | | | | +--------------- Released2(1 when the key is released)
372 | +-+-+-+-+-+-+----------------- Keycode1
373 +------------------------------- Released1(1 when the key is released)
374
375 Keycodes:
376 Scancode consists of 7bit keycode and 1bit release flag.
377 Device can send two keycodes at once. If just one keycode is sent
378 keycode1 contains it and keyocode2 is 0xFF.
379
380 Power switch:
381 You can read the state from PSW line(active low) however
382 the switch has a special scancode 0x7F7F, so you can
383 also read from Data line. It uses 0xFFFF for release scancode.
384
385Keyboard LEDs & state of keys(Register2)
386 This register hold current state of three LEDs and nine keys.
387 The state of LEDs can be changed by sending Listen command.
388
389 1514 . . . . . . 7 6 5 . 3 2 1 0
390 | | | | | | | | | | | | | | | +- LED1(NumLock)
391 | | | | | | | | | | | | | | +--- LED2(CapsLock)
392 | | | | | | | | | | | | | +----- LED3(ScrollLock)
393 | | | | | | | | | | +-+-+------- Reserved
394 | | | | | | | | | +------------- ScrollLock
395 | | | | | | | | +--------------- NumLock
396 | | | | | | | +----------------- Apple/Command
397 | | | | | | +------------------- Option
398 | | | | | +--------------------- Shift
399 | | | | +----------------------- Control
400 | | | +------------------------- Reset/Power
401 | | +--------------------------- CapsLock
402 | +----------------------------- Delete
403 +------------------------------- Reserved
404
405END_OF_ADB
406*/
diff --git a/pjrc/usb.c b/pjrc/usb.c
index 9fd30dee3..9fd30dee3 100755..100644
--- a/pjrc/usb.c
+++ b/pjrc/usb.c