Fix PS/2 protocol build options

This commit is contained in:
tmk 2012-10-14 20:03:26 +09:00
parent 9f05dc6f44
commit 1ac674db66
11 changed files with 500 additions and 317 deletions

View file

@ -1,7 +1,7 @@
PS/2 to USB keyboard converter
==============================
This firmware converts PS/2 keyboard protocol to USB and for now supports only Scan Code Set 2.
This will works on USB AVR(ATMega32U4, AT90USB) or V-USB.
This firmware converts PS/2 keyboard protocol to USB and supports only Scan Code Set 2.
This will works on USB AVR(ATMega32U4, AT90USB) or V-USB(ATMega168, 328...).
Features
@ -19,25 +19,29 @@ Keymap customization
PS/2 signal handling implementations
------------------------------------
Following three methods are used to implement PS/2 signal handling.
a. Simple and stupid wait & read loop(intensive use of cycles)
This is implemented with (expected) portable C code for reference. See ps2.c.
b. Interrupt driven
See ps2_intr.c
c. Using USART hardware module(no cycle needed)
This uses AVR USART function to recevie PS/2 signal and be used in V-USB converter.
See ps2_usart.c.
a. Simple and stupid busy-wait(ps2.c)
This is expected to implemented with portable C code for reference.
b. Interrupt driven(ps2.c)
Uses external interrupt to detect falling edge of clock line.
c. USART hardware module(ps2_usart.c)
Uses AVR USART engine to recevie PS/2 signal. Recomended and default.
This is required to work with V-USB, preceding two methods tend to
miss signal edges while V-USB handles USB.
To select method edit Makefile.
Build Converter
---------------
Connect PS/2 keyboard into Teensy with 4 lines(Vcc, GND, Data, Clock).
For a. Simple and stupid and b. Interrupt implementaion:
By default Clock is on PF0 and Data on PF1.
You can change this pin configuration by editing config_pjrc.h.
In this photo Vcc is yellow, GND is green, Data is red and Clock is black.
http://img17.imageshack.us/img17/7243/201101181933.jpg
For c. USART implementation:
In case of Teensny(ATMega32u4) CLock is on PD5 and Data on PD2.
Connect Wires
-------------
In case of Teensy2.0(ATMega32U4):
0. Connect Vcc and GND.
1. Connect Clock and Data line.
For a. Clock is on PF0 and Data on PF1.
For b. Clock is on PD1 and Data on PD2.
For c. Clock is on PD5 and Data on PD2.
2. Optionally you need pull-up register. 1K-10K Ohm is OK.
To change pin configuration edit config.h.
Build Frimware
@ -45,12 +49,12 @@ Build Frimware
1. Edit Makefile for build options and MCU setting.
Use 'atmega32u4' for Teensy 2.0 or 'at90usb1286' for Teensy++ 2.0.
2. make
Just type 'make' in a terminal.
Use '-f Makefile.pjrc_intr' option to use b. Interrupt.
Use '-f Makefile.pjrc_usart' option to use c. USART.
Use '-f Makefile.vusb' option to build V-USB converter.
3. program with Teensy Loader.
http://www.pjrc.com/teensy/loader.html
Just type `make` in a terminal.
Use `-f Makefile.vusb` option to build V-USB converter.
Use `-f Makefile.jis` option to use JIS keyboard.
3. program MCU.
In case of Teensy use `Teensy Loader`.(http://www.pjrc.com/teensy/loader.html)
Otherwise you want to use `avrdude` or `dfu-programmer`.
Demonstration of Features
@ -83,34 +87,36 @@ Fn layer function:
Keymap
------
You can change a keymap by editing code of keymap.c like following.
How to define the keymap is probably obvious. You can find key symbols in usb_keycodes.h.
To define keymap layer switching may needs a bit of your effort at this time.
You can change a keymap by editing code of keymap. See common/keycode.h for key symbols.
/* Default Layer: plain keymap
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak|
* `---' `---------------' `---------------' `---------------' `-----------' `-----------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -|
* |-----------------------------------------------------------| |-----------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| |
* |-----------------------------------------------------------| `-----------' |-----------| +|
* |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| |
* |-----------------------------------------------------------| ,---. |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
*/
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
V-USB Support
-------------
You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
Circuit
-------
+---+ +---------------+
USB GND | | ATmega168 |
=== C3 | |
5V <-------+--------+---|Vcc,AVCC | PS/2
R1 | | ====
D- <----+--+-----R2-----|INT1 RXD|------->DATA
D+ <----|---+----R3-----|INT0 XCK|------->CLOCK
Z1 Z2 | | ->5V
GND<----+---+--+--+-----|GND | ->GND
| | | |
| C2-+--|XTAL1 |
| X1 | |
+--C3-+--|XTAL2 |
+---------------+
R1: 1.5K Ohm
R2,R3: 68 Ohm
Z1,Z2: Zenner 3.6V
C1,C2: 22pF
C3: 0.1uF
X1: Crystal 20MHz(16MHz/12MHz)
EOF