From: Oleg Kostyuk Date: Wed, 25 Sep 2013 11:38:39 +0000 (+0300) Subject: Merge remote-tracking branch 'tmk/master' into cub_layout X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=3be39e436d1541cc5aec3b7f31de900294567e4e;hp=221af6bffbb8c5af57ae64068d34e5ea165b3a82;p=max%2Ftmk_keyboard.git Merge remote-tracking branch 'tmk/master' into cub_layout --- diff --git a/common.mk b/common.mk index 47d5c852..ee28b696 100644 --- a/common.mk +++ b/common.mk @@ -68,6 +68,14 @@ ifdef BACKLIGHT_ENABLE OPT_DEFS += -DBACKLIGHT_ENABLE endif +ifdef KEYMAP_SECTION_ENABLE + OPT_DEFS += -DKEYMAP_SECTION_ENABLE + EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x +endif + +# Version string +OPT_DEFS += -DVERSION=$(shell (git describe --dirty || echo 'unknown') 2> /dev/null) + # Search Path VPATH += $(TOP_DIR)/common diff --git a/common/action_code.h b/common/action_code.h index 45e974a6..b2a7f2b4 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -207,10 +207,10 @@ enum mods_codes { MODS_ONESHOT = 0x00, }; #define ACTION_KEY(key) ACTION(ACT_MODS, (key)) -#define ACTION_MODS(mods) ACTION(ACT_MODS, (mods)<<8 | 0) -#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, (mods)<<8 | (key)) -#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, (mods)<<8 | (key)) -#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, (mods)<<8 | MODS_ONESHOT) +#define ACTION_MODS(mods) ACTION(ACT_MODS, (mods&0x1f)<<8 | 0) +#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, (mods&0x1f)<<8 | (key)) +#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, (mods&0x1f)<<8 | (key)) +#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, (mods&0x1f)<<8 | MODS_ONESHOT) /* diff --git a/common/action_tapping.c b/common/action_tapping.c index a6292535..542949dd 100644 --- a/common/action_tapping.c +++ b/common/action_tapping.c @@ -27,9 +27,7 @@ static uint8_t waiting_buffer_tail = 0; static bool process_tapping(keyrecord_t *record); static bool waiting_buffer_enq(keyrecord_t record); static void waiting_buffer_clear(void); -#if TAPPING_TERM >= 500 static bool waiting_buffer_typed(keyevent_t event); -#endif static bool waiting_buffer_has_anykey_pressed(void); static void waiting_buffer_scan_tap(void); static void debug_tapping_key(void); @@ -109,6 +107,13 @@ bool process_tapping(keyrecord_t *keyp) return false; } #endif + /* release a key pressed before tapping */ + else if (!event.pressed && !waiting_buffer_typed(event)) { + /* Unexpected repeating occurs unless this event is processed immedately. */ + debug("Tapping: release a key pressed before tapping\n"); + process_action(keyp); + return true; + } else { // set interrupted flag when other key preesed during tapping if (event.pressed) { @@ -289,7 +294,6 @@ void waiting_buffer_clear(void) waiting_buffer_tail = 0; } -#if TAPPING_TERM >= 500 bool waiting_buffer_typed(keyevent_t event) { for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { @@ -299,7 +303,6 @@ bool waiting_buffer_typed(keyevent_t event) } return false; } -#endif bool waiting_buffer_has_anykey_pressed(void) { diff --git a/common/bootloader.c b/common/bootloader.c index 43a7e47c..cda295b1 100644 --- a/common/bootloader.c +++ b/common/bootloader.c @@ -71,7 +71,8 @@ void bootloader_jump_after_watchdog_reset(void) MCUSR &= ~(1< -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 - -- ![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* - ,---------------------------------------------------------. ,---------------. - | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Ctl| -|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| - |---------------------------------------------------------| |---------------| - |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| | - `---------------------------------------------------------' |-----------|Ent| - |Ctl|Alt | Space |Gui |Ctl| | 0| .| | - `-----------------------------------------------' `---------------' -#### *HHKB/WASD Layer(WASD/IJKL)* - ,---------------------------------------------------------. ,---------------. - |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| - |---------------------------------------------------------| |---------------| - |Fn0 |Lef|Dow|Rig| | | |Lef|Dow|Rig| | |Return| | 4| 5| 6| Dn| - |---------------------------------------------------------| |---------------| - |Shift |End| |PgD| | | |PgD| |End| |Shift | | 1| 2| 3| | - `---------------------------------------------------------' |-----------|Ent| - |Ctl|Alt | Space |Gui |Ctl| | 0| .| | - `-----------------------------------------------' `---------------' +#### *Default Layer* + ,---------------------------------------------------------. ,---------------. + | `| 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| + |---------------------------------------------------------| |---------------| + |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|Gui | Space |Alt |Ctl| | 0| .| | + `-----------------------------------------------' `---------------' + +- `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| | | | |Psc|Slk|Pau|Up |Ins| \| | 7| 8| 9| Up| + |---------------------------------------------------------| |---------------| + |Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| Dn| + |---------------------------------------------------------| |---------------| + |Shift |End| |PgD| | | | |End|PgD|Dow|Shift | | 1| 2| 3| | + `---------------------------------------------------------' |-----------|Ent| + |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 `+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 `+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`) diff --git a/converter/m0110_usb/config.h b/converter/m0110_usb/config.h index 2f63a3a4..801bc4eb 100644 --- a/converter/m0110_usb/config.h +++ b/converter/m0110_usb/config.h @@ -32,10 +32,6 @@ along with this program. If not, see . #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 . 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 diff --git a/converter/m0110_usb/doc/m0110.jpg b/converter/m0110_usb/doc/m0110.jpg deleted file mode 100644 index ef9a123a..00000000 Binary files a/converter/m0110_usb/doc/m0110.jpg and /dev/null differ diff --git a/converter/m0110_usb/doc/teensy.jpg b/converter/m0110_usb/doc/teensy.jpg deleted file mode 100644 index 96e93e7e..00000000 Binary files a/converter/m0110_usb/doc/teensy.jpg and /dev/null differ diff --git a/converter/m0110_usb/keymap.c b/converter/m0110_usb/keymap.c index 7a3bc358..02c6ef9c 100644 --- a/converter/m0110_usb/keymap.c +++ b/converter/m0110_usb/keymap.c @@ -44,7 +44,7 @@ along with this program. If not, see . * |---------------------------------------------------------| |---------------| * |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 . * |---------------------------------------------------------| |---------------| * |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 . * |---------------------------------------------------------| |---------------| * |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 . { 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; } diff --git a/keyboard/hhkb/Makefile b/keyboard/hhkb/Makefile index 1ef0a018..34bafc24 100644 --- a/keyboard/hhkb/Makefile +++ b/keyboard/hhkb/Makefile @@ -111,12 +111,13 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration -MOUSEKEY_ENABLE = yes # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -CONSOLE_ENABLE = yes # Console for debug -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # USB Nkey Rollover +KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor # Search Path @@ -128,4 +129,5 @@ include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk debug-on: EXTRAFLAGS += -DDEBUG +#debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION debug-on: all diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c index faa62dd7..f2c6caf4 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap.c @@ -48,8 +48,11 @@ along with this program. If not, see . { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \ } - -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 /* Layer 0: Default Layer * ,-----------------------------------------------------------. * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| @@ -186,7 +189,11 @@ enum macro_id { /* * Fn action definition */ -static const uint16_t PROGMEM fn_actions[] = { +#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_DEFAULT_LAYER_SET(0), // Default layer(not used) [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* @@ -310,10 +317,6 @@ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) action_t keymap_fn_to_action(uint8_t keycode) { action_t action; - if (FN_INDEX(keycode) < sizeof(fn_actions) / sizeof(fn_actions[0])) { - action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); - } else { - action.code = ACTION_NO; - } + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); return action; } diff --git a/ldscript_keymap_avr5.x b/ldscript_keymap_avr5.x new file mode 100644 index 00000000..c09693e5 --- /dev/null +++ b/ldscript_keymap_avr5.x @@ -0,0 +1,268 @@ +/* + * linker script for configurable keymap + * + * This adds keymap section which places keymap at fixed address and + * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). + */ +OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") +OUTPUT_ARCH(avr:5) +MEMORY +{ + /* With keymap section + * + * Flash Map of ATMega32U4(32KB) + * +------------+ 0x0000 + * | .vectors | + * | .progmem | + * | .init0-9 | > text region + * | .text | + * | .fini9-0 | + * | | + * |------------| _etext + * | .data | + * | .bss | > data region + * | .noinit | + * | | + * |------------| 0x6800 + * | .keymap | > keymap region(2KB) + * |------------| 0x7000 + * | bootloader | 4KB + * +------------+ 0x7FFF + */ + text (rx) : ORIGIN = 0, LENGTH = 128K + keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K + data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K + lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K + signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K +} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + /* Internal text space or external memory. */ + .text : + { + *(.vectors) + KEEP(*(.vectors)) + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + *(.progmem*) + . = ALIGN(2); + __trampolines_start = . ; + /* The jump trampolines for the 16-bit limited relocs will reside here. */ + *(.trampolines) + *(.trampolines*) + __trampolines_end = . ; + /* For future tablejump instruction arrays for 3 byte pc devices. + We don't relax jump/call instructions within these sections. */ + *(.jumptables) + *(.jumptables*) + /* For code that needs to reside in the lower 128k progmem. */ + *(.lowtext) + *(.lowtext*) + __ctors_start = . ; + *(.ctors) + __ctors_end = . ; + __dtors_start = . ; + *(.dtors) + __dtors_end = . ; + KEEP(SORT(*)(.ctors)) + KEEP(SORT(*)(.dtors)) + /* From this point on, we don't bother about wether the insns are + below or above the 16 bits boundary. */ + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + . = ALIGN(2); + *(.text.*) + . = ALIGN(2); + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + _etext = . ; + } > text + .data : AT (ADDR (.text) + SIZEOF (.text)) + { + PROVIDE (__data_start = .) ; + *(.data) + *(.data*) + *(.rodata) /* We need to include .rodata here if gcc is used */ + *(.rodata*) /* with -fdata-sections. */ + *(.gnu.linkonce.d*) + . = ALIGN(2); + _edata = . ; + PROVIDE (__data_end = .) ; + } > data + .bss : AT (ADDR (.bss)) + { + PROVIDE (__bss_start = .) ; + *(.bss) + *(.bss*) + *(COMMON) + PROVIDE (__bss_end = .) ; + } > data + __data_load_start = LOADADDR(.data); + __data_load_end = __data_load_start + SIZEOF(.data); + /* Global data not cleared after reset. */ + .noinit : + { + PROVIDE (__noinit_start = .) ; + *(.noinit*) + PROVIDE (__noinit_end = .) ; + _end = . ; + PROVIDE (__heap_start = .) ; + } > data + /* keymap region is located at end of flash + * .fn_actions Fn actions definitions + * .keymaps Mapping layers + */ + .keymap : + { + PROVIDE(__keymap_start = .) ; + *(.keymap.fn_actions) /* 32*actions = 64bytes */ + . = ALIGN(0x40); + *(.keymap.keymaps) /* rest of .keymap section */ + *(.keymap*) + /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ + } > keymap = 0x00 /* zero fill */ + .eeprom : + { + *(.eeprom*) + __eeprom_end = . ; + } > eeprom + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } > fuse + .lock : + { + KEEP(*(.lock*)) + } > lock + .signature : + { + KEEP(*(.signature*)) + } > signature + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index c1617cd0..a230d5ba 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -531,19 +531,26 @@ static void SetupHardware(void) // for Console_Task USB_Device_EnableSOFEvents(); + print_set_sendchar(sendchar); } int main(void) __attribute__ ((weak)); int main(void) { SetupHardware(); + sei(); +#if defined(INTERRUPT_CONTROL_ENDPOINT) + while (USB_DeviceState != DEVICE_STATE_Configured) ; +#endif + print("USB configured.\n"); + keyboard_init(); host_set_driver(&lufa_driver); #ifdef SLEEP_LED_ENABLE sleep_led_init(); #endif - sei(); + print("Keyboard start.\n"); while (1) { while (USB_DeviceState == DEVICE_STATE_Suspended) { suspend_power_down(); diff --git a/protocol/m0110.c b/protocol/m0110.c index 8bf7cfe4..9b53ec2c 100644 --- a/protocol/m0110.c +++ b/protocol/m0110.c @@ -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)