diff options
| author | tmk <nobody@nowhere> | 2011-02-22 02:57:01 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2011-02-22 03:49:02 +0900 |
| commit | 00350c180dee31ec9d9c4aee31e06faf55bd1c6b (patch) | |
| tree | d54b35ca96ec6bce6c415423cdba4f66d198b433 | |
| parent | d2b9489a5e19fabb5d6ec285192b19dc25b36d5e (diff) | |
| download | qmk_firmware-00350c180dee31ec9d9c4aee31e06faf55bd1c6b.tar.gz qmk_firmware-00350c180dee31ec9d9c4aee31e06faf55bd1c6b.zip | |
v3.0 cleanse files
| -rw-r--r-- | ADB.txt | 173 | ||||
| -rw-r--r-- | README | 35 | ||||
| -rw-r--r-- | TODO | 103 | ||||
| -rw-r--r-- | adb.c | 213 | ||||
| -rw-r--r--[-rwxr-xr-x] | pjrc/usb.c | 0 |
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 @@ | |||
| 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 | ||
| @@ -1,16 +1,19 @@ | |||
| 1 | t.m.k. Keyboard Firmware | 1 | t.m.k. Keyboard Firmware |
| 2 | ======================== | 2 | ======================== |
| 3 | http://github.com/tmk/tmk_keyboard | 3 | This is keyboard firmware for Teensy(AVR USB MCU) and V-USB board. |
| 4 | |||
| 5 | This is keyboard firmware for AVR USB MCUs or Teensy/Teensy++. | ||
| 6 | http://www.pjrc.com/teensy | ||
| 7 | 4 | ||
| 8 | The project is heavily based on PJRC USB Keyboard/Mouse Example and | 5 | source code repository: |
| 9 | owes a debt to preceding keyboard firmware projects. | 6 | http://github.com/tmk/tmk_keyboard |
| 10 | 7 | ||
| 11 | This firmware is used in following projects: | 8 | This firmware is used in following projects: |
| 12 | HHKB mod: http://geekhack.org/showwiki.php?title=Island:12047 | 9 | HHKB mod: http://geekhack.org/showwiki.php?title=Island:12047 |
| 13 | Macway mod: http://geekhack.org/showwiki.php?title=Island:11930 | 10 | Macway mod: http://geekhack.org/showwiki.php?title=Island:11930 |
| 11 | PS2 to USB: http://geekhack.org/showwiki.php?title=Island:14618 | ||
| 12 | ADB to USB: http://geekhack.org/showwiki.php?title=Island:14290 | ||
| 13 | |||
| 14 | The project is heavily based on PJRC USB Keyboard/Mouse Example and | ||
| 15 | owes a debt to preceding keyboard firmware projects. | ||
| 16 | http://www.pjrc.com/teensy | ||
| 14 | 17 | ||
| 15 | 18 | ||
| 16 | Features | 19 | Features |
| @@ -31,12 +34,27 @@ Limitations | |||
| 31 | ----------- | 34 | ----------- |
| 32 | 35 | ||
| 33 | 36 | ||
| 37 | Files & Directories | ||
| 38 | ------------------- | ||
| 39 | Target: | ||
| 40 | hhkb/ keyboard controller for PFU HHKB pro | ||
| 41 | macway/ keyboard controller for Macway mod | ||
| 42 | ps2_usb/ PS2 to USB keyboard converter | ||
| 43 | adb_usb/ ADB to USB keyboard converter | ||
| 44 | |||
| 45 | USB Protocol Stack: | ||
| 46 | pjrc/ PJRC USB stack | ||
| 47 | vusb/ V-USB USB stack | ||
| 48 | ps2.[ch] PS/2 protocol | ||
| 49 | adb.[ch] ADB protocol | ||
| 50 | |||
| 51 | |||
| 34 | Build | 52 | Build |
| 35 | ----- | 53 | ----- |
| 36 | To compile needs AVR GCC, AVR Libc and GNU make. | 54 | To compile needs AVR GCC, AVR Libc and GNU make. |
| 37 | You can use WinAVR on Windows. http://winavr.sourceforge.net/ | 55 | You 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 | ||
| 42 | The firmware will be compiled as a file tmk_<target>.hex. | 60 | The firmware will be compiled as a file tmk_<target>.hex. |
| @@ -100,7 +118,8 @@ Build Options | |||
| 100 | Debuging & Rescue | 118 | Debuging & Rescue |
| 101 | ----------------- | 119 | ----------------- |
| 102 | Use PJRC's hid_listen.exe to see debug messages. | 120 | Use PJRC's hid_listen.exe to see debug messages. |
| 103 | Press right Control + Shift + Alt + GUI + H to debug menu. | 121 | Press <COMMAND> + H to debug menu. |
| 122 | (see config.h for <COMMAND> key combination.) | ||
| 104 | 123 | ||
| 105 | Pressing any 3 keys when connected enables debug output. | 124 | Pressing any 3 keys when connected enables debug output. |
| 106 | Pressing any 4 keys when connected makes bootloader comes up. | 125 | Pressing any 4 keys when connected makes bootloader comes up. |
| @@ -1,103 +0,0 @@ | |||
| 1 | TODO & IDEAS | ||
| 2 | ------------ | ||
| 3 | Code cleaning | ||
| 4 | keymap layer definition | ||
| 5 | Debug/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 | ||
| 17 | Document | ||
| 18 | development | ||
| 19 | Interchangable 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? | ||
| 26 | Layer switch | ||
| 27 | toggle layer switch | ||
| 28 | Debouncing 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) | ||
| 32 | Child lock | ||
| 33 | disable keyboard to protect against atacking by child | ||
| 34 | Windows key blocking | ||
| 35 | disable Windows keys for gamers | ||
| 36 | OneHand operation | ||
| 37 | RAlt + Del(or \) to Alt + Tab | ||
| 38 | Licensings(GPL) | ||
| 39 | GPL will not be infringement of PJRC license. | ||
| 40 | Extra switch | ||
| 41 | foot sw for layer switching | ||
| 42 | mouse button | ||
| 43 | PS/2->USB keyboard converter | ||
| 44 | PS/2 keyboard host protocol support | ||
| 45 | PS/2,USB detection | ||
| 46 | act as PS/2 keyboard or USB keyboard. | ||
| 47 | PS/2 keyboard device protocol support | ||
| 48 | Thinkpad keyboard support | ||
| 49 | turn to USB keyboard/mouse composite device | ||
| 50 | Other 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 | ||
| 55 | Separate keyboard support | ||
| 56 | comunicate between keyboards by I2C? | ||
| 57 | this is for ergo keyoboard style. | ||
| 58 | |||
| 59 | |||
| 60 | DONE & STATUS | ||
| 61 | ------------- | ||
| 62 | PS2 mouse bug to be FIX'd | ||
| 63 | macway/matrix: line select changes pins for mouse. | ||
| 64 | 2010/01/02 | ||
| 65 | support for HHKB pro matrix signal | ||
| 66 | exchange controller board with teensy | ||
| 67 | 2010/10/11 | ||
| 68 | OneHand operation | ||
| 69 | Matias half keyboard style | ||
| 70 | 2010/10/23 | ||
| 71 | souce code cleaning | ||
| 72 | 2010/10/23 | ||
| 73 | debug on/off | ||
| 74 | debug off by default | ||
| 75 | pressing keys during booting | ||
| 76 | 2010/10/23 | ||
| 77 | mouse 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 | ||
| 82 | debug 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 | ||
| 88 | layer switching | ||
| 89 | time before switching | ||
| 90 | timeout when not used during specific time | ||
| 91 | 2010/10/30 | ||
| 92 | Build Option | ||
| 93 | windows media keys suport | ||
| 94 | 2010/01/06 | ||
| 95 | Document | ||
| 96 | build, customize | ||
| 97 | 2010/01/06 | ||
| 98 | Trackpoint(PS/2) | ||
| 99 | receive PS/2 signal from TrackPoint | ||
| 100 | 2010/01/02 | ||
| 101 | send USB HID report | ||
| 102 | |||
| 103 | EOF | ||
| @@ -1,3 +1,39 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2011 Jun WAKO <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This software is licensed with a Modified BSD License. | ||
| 5 | All of this is supposed to be Free Software, Open Source, DFSG-free, | ||
| 6 | GPL-compatible, and OK to use in both free and proprietary applications. | ||
| 7 | Additions and corrections to this file are welcome. | ||
| 8 | |||
| 9 | |||
| 10 | Redistribution and use in source and binary forms, with or without | ||
| 11 | modification, 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 | |||
| 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 28 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 35 | POSSIBILITY 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 | /* | ||
| 233 | ADB Protocol | ||
| 234 | ============ | ||
| 235 | |||
| 236 | Resources | ||
| 237 | --------- | ||
| 238 | ADB - The Untold Story: Space Aliens Ate My Mouse | ||
| 239 | http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html | ||
| 240 | Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)] | ||
| 241 | ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf | ||
| 242 | ADB 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] | ||
| 246 | ADB Signaling | ||
| 247 | http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf | ||
| 248 | ADB Overview & History | ||
| 249 | http://en.wikipedia.org/wiki/Apple_Desktop_Bus | ||
| 250 | Microchip Application Note: ADB device(with code for PIC16C) | ||
| 251 | http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062 | ||
| 252 | AVR ATtiny2131 ADB to PS/2 converter(Japanese) | ||
| 253 | http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html | ||
| 254 | |||
| 255 | |||
| 256 | Pinouts | ||
| 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 | |||
| 284 | Commands | ||
| 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 | |||
| 319 | Communication | ||
| 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 | |||
| 363 | Keyboard 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 | |||
| 385 | Keyboard 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 | |||
| 405 | END_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 | |||
