Merge branch 'm0110_next'

pull/12/head
tmk 11 years ago
commit 6ccea742de

@ -71,7 +71,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# *Comment out* to disable the options.
#
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)

@ -1,10 +1,12 @@
M0110/M0110A to USB keyboard converter
======================================
This firmware converts the protocol of Apple Macintosh keyboard M0110/M0110A into USB.
Target board of this project is [PJRC Teensy](http://www.pjrc.com/teensy/), though,
you can use other board with USB AVR like `ATmega32U4` and `AT90USB`.
This firmware converts the protocol of Apple Macintosh keyboard **M0110**, **M0110A** and **M0120** into USB. Target of this project is USB AVR controller **ATmega32U4**. Using this converter you can revive these retro keyboards with modern computer.
Pics of **M0110 + M0120** and **M0110A**.
![M0110+M0120](http://i.imgur.com/dyvXb2Tm.jpg)
![M0110A](http://i.imgur.com/HuHOEoHm.jpg)
![M0110](https://raw.github.com/tmk/tmk_keyboard/master/converter/m0110_usb/doc/m0110.jpg)
- M0110A support was contributed by [skagon@github](https://github.com/skagon).
- M0120 also is supported. keys(+ * / and ,) on M0120 are recognized as cursor keys.
@ -13,49 +15,42 @@ you can use other board with USB AVR like `ATmega32U4` and `AT90USB`.
Update
------
- 2013/08 Change port for signals PF to PD
- 2013/08: Change port for signals `PF` to `PD`
- 2013/09: Change port again, it uses inversely `PD0` for data and `PD1` for clock line now.
Connection
----------
You need 4P4C plug and cable to connect Teensy or other AVR dev board into the keyboard.
Teensy port `PD0` is assigned for `CLOCK` line and `PD1` for `DATA` by default,
you can change pin configuration with editing *config.h*.
Building Hardware
-----------------
You need **4P4C** cable and **ATMega32U4** board like PJRC [Teensy]. Port of the MCU `PD1` is assigned to `CLOCK` line and `PD0` to `DATA` by default, you can change pin configuration with editing `config.h`.
You can find 4P4C plugs on telephone handset cable. Note that it is *crossover* connection
while Macintosh keyboard cable is *straight*.
[![M0110 Converter](http://i.imgur.com/4G2ZOegm.jpg)](http://i.imgur.com/4G2ZOeg.jpg)
[![Conection](https://raw.github.com/tmk/tmk_keyboard/master/converter/m0110_usb/doc/teensy.jpg)]
### 4P4C phone handset cable
Note that original cable used with Mac is **straight** while phone handset cable is **crossover**.
In this pic:
<http://en.wikipedia.org/wiki/Modular_connector#4P4C>
1. `GND`(Black)
2. `CLOCK`(Red)
3. `DATA`(Green)
4. `+5V`(Yellow)
Close-up pic of handset cable. You can see one end of plug has reverse color codes against the other. Click to enlarge.
[![4P4C cable](http://i.imgur.com/3S9P1mYm.jpg?1)](http://i.imgur.com/3S9P1mY.jpg?1)
Note that wire colors may vary in your cable.
[Teensy]: http://www.pjrc.com/teensy/
### Pinout
### Socket Pinout
- <http://pinouts.ru/Inputs/MacKeyboard_pinout.shtml>
- <http://en.wikipedia.org/wiki/Modular_connector#4P4C>
![Jack fig](http://www.kbdbabel.org/conn/kbd_connector_macplus.png)
### Pull-up Registor
You may need pull-up registors on signal lines(`CLOCK`, `DATA`) in particular
when you have long or coiled cable. 1k-10k Ohm will be OK for this purpose.
In some cases MCU can't read signal from keyboard correctly without pull-up resistors.
You may need pull-up registors on signal lines(`CLOCK`, `DATA`) in particular when you have long or coiled cable. **1k-10k Ohm** will be OK for this purpose. In that case the converter may not read signal from keyboard correctly without pull-up resistors.
Building Frimware
-----------------
To compile firmware you need AVR GCC. You can use [WinAVR](http://winavr.sourceforge.net/) on Windows.
You can edit *Makefile* and *config.h* to change compile options and pin configuration.
To compile firmware you need AVR GCC. You can edit *Makefile* and *config.h* to change compile options and pin configuration.
$ git clone git://github.com/tmk/tmk_keyboard.git (or download source)
$ cd m0110_usb
@ -71,64 +66,69 @@ Keymap
You can change keymaps by editing *keymap.c*.
### M0110 & M0120
#### *Default*
#### *Default Layer*
,---------------------------------------------------------. ,---------------.
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Ctl| -|Lft|Rgt|
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| -|Lft|Rgt|
|---------------------------------------------------------| |---------------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9| Up|
|---------------------------------------------------------| |---------------|
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| Dn|
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| Dn|
|---------------------------------------------------------| |---------------|
|Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| |
`---------------------------------------------------------' |-----------|Ent|
|Ctl|Alt | Space |Gui |Ctl| | 0| .| |
|Ctl|Gui | Space |Alt |Ctl| | 0| .| |
`-----------------------------------------------' `---------------'
#### *HHKB/WASD Layer(WASD/IJKL)*
- `Space` and `Enter` also work as `Fn` layer switch key when holding down.
#### *Function Layer(WASD/HHKB)*
,---------------------------------------------------------. ,---------------.
|Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| -|Lft|Rgt|
|---------------------------------------------------------| |---------------|
|Caps |Hom| Up|PgU| | | |PgU| Up|Hom|Psc|Slk|Pau|Ins| | 7| 8| 9| Up|
|Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| \| | 7| 8| 9| Up|
|---------------------------------------------------------| |---------------|
|Fn0 |Lef|Dow|Rig| | | |Lef|Dow|Rig| | |Return| | 4| 5| 6| Dn|
|Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| Dn|
|---------------------------------------------------------| |---------------|
|Shift |End| |PgD| | | |PgD| |End| |Shift | | 1| 2| 3| |
|Shift |End| |PgD| | | | |End|PgD|Dow|Shift | | 1| 2| 3| |
`---------------------------------------------------------' |-----------|Ent|
|Ctl|Alt | Space |Gui |Ctl| | 0| .| |
|Ctl|Gui | Space |Alt |Ctl| | 0| .| |
`-----------------------------------------------' `---------------'
### M0110A
#### *Default*
#### *Default Layer*
,---------------------------------------------------------. ,---------------.
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Ctl| =| /| *|
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| =| /| *|
|---------------------------------------------------------| |---------------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
|-----------------------------------------------------' | |---------------|
|Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| +|
|---------------------------------------------------------| |---------------|
|Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft| Up| | 1| 2| 3| |
|---------------------------------------------------------| |-----------|Ent|
|Alt |Gui | Space | \|Lft|Rgt| Dn| | 0| .| |
|Ctrl |Gui | Space | \|Lft|Rgt|Dwn| | 0| .| |
`---------------------------------------------------------' `---------------'
#### *Cursor Layer(WASD/IJKL)*
- `Space` and `Enter` also work as `Fn` layer switch key when holding down.
- `Backslash(\)` also works as `Alt` when holding down.
#### *Function Layer(WASD/HHKB)*
,---------------------------------------------------------. ,---------------.
|Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *|
|---------------------------------------------------------| |---------------|
|Caps |Hom| Up|PgU| | | |PgU| Up|Hom|Psc|Slk|Pau| | | 7| 8| 9| -|
|Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | | 7| 8| 9| -|
|-----------------------------------------------------' | |---------------|
|Fn0 |Lef|Dow|Rig| | | |Lef|Dow|Rig| | |Return| | 4| 5| 6| +|
|Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| +|
|---------------------------------------------------------| |---------------|
|Shift |End| |PgD| | | |PgD| |End| |Shif|PgU| | 1| 2| 3| |
|Shift |End| |PgD| | | | |End|PgD|Dow|Shif|PgU| | 1| 2| 3| |
|---------------------------------------------------------| |-----------|Ent|
|Alt |Gui | Space |Ins|Hom|End|PgD| | 0| .| |
|Ctrl |Gui | Space | \|Hom|End|PgD| | 0| .| |
`---------------------------------------------------------' `---------------'
Debug
-----
You can use [PJRC HID listen](http://www.pjrc.com/teensy/hid_listen.html) to see debug output.
The converter has some functions for debug, press `<magickey>+H` simultaneously to get help.
These function is totally undocumented, tentative, inconsistent and buggy.
You can use [PJRC HID listen](http://www.pjrc.com/teensy/hid_listen.html) to see debug output. The converter has some functions for debug, press `<Command>+H` simultaneously to get help.
magickey: Shift+Option+Command(Shift+Alt+Gui or Shift+Alt+Control)
- Command: `Shift+Option+Command`(`Shift+Alt+Gui` or `Shift+Alt+Control`)

@ -32,10 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COLS 8
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
@ -48,15 +44,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LCTL)) \
)
/* boot magic key */
#define BOOTMAGIC_KEY_SALT KC_FN0
#define BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL KC_LCAP
/* ports */
#define M0110_CLOCK_PORT PORTD
#define M0110_CLOCK_PIN PIND
#define M0110_CLOCK_DDR DDRD
#define M0110_CLOCK_BIT 0
#define M0110_CLOCK_BIT 1
#define M0110_DATA_PORT PORTD
#define M0110_DATA_PIN PIND
#define M0110_DATA_DDR DDRD
#define M0110_DATA_BIT 1
#define M0110_DATA_BIT 0
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

@ -44,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* |---------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
* |-----------------------------------------------------' | |---------------|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------' |-----------|Ent|
@ -57,7 +57,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* |---------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9| /|
* |---------------------------------------------------------| |---------------|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| ,|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| ,|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| |
* `---------------------------------------------------------' |-----------|Ent|
@ -77,7 +77,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* |---------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
* |-----------------------------------------------------' | |---------------|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
@ -108,89 +108,79 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{ KC_##K68, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K6D, KC_NO, KC_NO }, \
}
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
static const uint8_t PROGMEM fn_layer[] = {
1, // Fn0
0, // Fn1
0, // Fn2
0, // Fn3
0, // Fn4
0, // Fn5
0, // Fn6
0 // Fn7
};
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_NO, // Fn2
KC_NO, // Fn3
KC_NO, // Fn4
KC_NO, // Fn5
KC_NO, // Fn6
KC_NO // Fn7
};
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
/* Default:
* ,---------------------------------------------------------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Ctl| =| /| *|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| =| /| *|
* |---------------------------------------------------------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
* |-----------------------------------------------------' | |---------------|
* |Fn0 | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Ctl |Alt | Space |Gui| \|Lft|Rgt|Dn | | 0| .| |
* |Ctl |Gui | Space |Alt| \|Lft|Rgt|Dn | | 0| .| |
* `---------------------------------------------------------' `---------------'
*/
KEYMAP(
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, LCTL,EQL, PSLS,PAST,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, CLR, EQL, PSLS,PAST,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS,
FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, FN1, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT,
LCTL,LALT, SPC, LGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT
LCTL,LGUI, FN0, LALT,FN2, LEFT,RGHT,DOWN, P0, PDOT
),
/* Cursor Layer(WASD, IJKL)
* ,---------------------------------------------------------. ,---------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *|
* |---------------------------------------------------------| |---------------|
* |Caps |Hom| Up|PgU| | | |PgU| Up|Hom|Psc|Slk|Pau| | | 7| 8| 9| -|
* |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | | 7| 8| 9| -|
* |-----------------------------------------------------' | |---------------|
* |Fn0 |Lef|Dow|Rig| | | |Lef|Dow|Rig| | |Return| | 4| 5| 6| +|
* |Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift |End| |PgD| | | |PgD| |End| |Shif|PgU| | 1| 2| 3| |
* |Shift |End| |PgD| | | | |End|PgD|Dow|Shif|PgU| | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Ctl |Alt | Space |Gui |Ins|Hom|End|PgD| | 0| .| |
* |Ctl |Gui | Space |Alt | \|Hom|End|PgD| | 0| .| |
* `---------------------------------------------------------' `---------------'
*/
KEYMAP(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST,
CAPS,HOME,UP, PGUP,NO, NO, NO, PGUP,UP, HOME,PSCR,SLCK,PAUS, P7, P8, P9, PMNS,
FN0, LEFT,DOWN,RGHT,NO, NO, NO, LEFT,DOWN,RGHT,NO, NO, ENT, P4, P5, P6, PPLS,
LSFT,END, NO, PGDN,NO, NO, NO, PGDN,NO, END, NO, PGUP, P1, P2, P3, PENT,
LCTL,LALT, SPC, LGUI,INS, HOME,END, PGDN, P0, PDOT
CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, INS, P7, P8, P9, PMNS,
LCAP,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, FN1, P4, P5, P6, PPLS,
LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT,
LCTL,LGUI, FN0, LALT,FN2, HOME,END, PGDN, P0, PDOT
),
};
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
{
return KEYCODE(layer, row, col);
}
/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
static const uint16_t fn_actions[] PROGMEM = {
#endif
[0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), // Layer switch with Tap key Space
[1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // Layer switch with Tap key Enter
[2] = ACTION_MODS_TAP_KEY(MOD_LALT, KC_BSLS), // LALT with Tap key Backslash
};
uint8_t keymap_fn_layer(uint8_t index)
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
return pgm_read_byte(&fn_layer[index]);
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}
uint8_t keymap_fn_keycode(uint8_t index)
/* translates Fn index to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return pgm_read_byte(&fn_keycode[index]);
action_t action;
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
return action;
}

@ -91,10 +91,11 @@ uint8_t m0110_error = 0;
void m0110_init(void)
{
uint8_t data;
idle();
_delay_ms(1000);
/* Not needed to initialize in fact.
uint8_t data;
m0110_send(M0110_MODEL);
data = m0110_recv();
print("m0110_init model: "); phex(data); print("\n");
@ -102,6 +103,7 @@ void m0110_init(void)
m0110_send(M0110_TEST);
data = m0110_recv();
print("m0110_init test: "); phex(data); print("\n");
*/
}
uint8_t m0110_send(uint8_t data)

Loading…
Cancel
Save