diff options
Diffstat (limited to 'keyboard')
49 files changed, 1846 insertions, 173 deletions
diff --git a/keyboard/IIgs/Makefile b/keyboard/IIgs/Makefile index c18e9720c7..3bf380e64b 100644 --- a/keyboard/IIgs/Makefile +++ b/keyboard/IIgs/Makefile @@ -42,7 +42,7 @@ TARGET = IIgs_Standard # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -88,8 +88,8 @@ PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/alps64/Makefile b/keyboard/alps64/Makefile new file mode 100644 index 0000000000..e90dcedb67 --- /dev/null +++ b/keyboard/alps64/Makefile @@ -0,0 +1,134 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = alps64 + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap_common.c \ + matrix.c \ + led.c + +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_plain.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +MCU = atmega32u2 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +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) +COMMAND_ENABLE = yes # Commands for debug and configuration +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/alps64/config.h b/keyboard/alps64/config.h new file mode 100644 index 0000000000..824d3e8302 --- /dev/null +++ b/keyboard/alps64/config.h @@ -0,0 +1,70 @@ +/* +Copyright 2015 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6464 +#define DEVICE_VER 0x0001 +#define MANUFACTURER TMK +#define PRODUCT Alps64 +#define DESCRIPTION TMK keyboard firmware for Alps64 + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/alps64/keymap_common.c b/keyboard/alps64/keymap_common.c new file mode 100644 index 0000000000..fdb1769e1c --- /dev/null +++ b/keyboard/alps64/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2012,2013 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/alps64/keymap_common.h b/keyboard/alps64/keymap_common.h new file mode 100644 index 0000000000..957db57922 --- /dev/null +++ b/keyboard/alps64/keymap_common.h @@ -0,0 +1,70 @@ +/* +Copyright 2012,2013 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include <stdint.h> +#include <stdbool.h> +#include <avr/pgmspace.h> +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* Alps64 keymap definition macro */ +#define KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \ + K30, K40, K50, K60, K70, K00, K10, K20 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \ +} + +/* AEK US */ +#define KEYMAP_AEK( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \ + K30, K40, K50, K60, K00, K10, K20 \ +) KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \ + K30, K40, K50, K60, APP, K00, K10, K20 \ +) + +#endif diff --git a/keyboard/alps64/keymap_hasu.c b/keyboard/alps64/keymap_hasu.c new file mode 100644 index 0000000000..d297d72fea --- /dev/null +++ b/keyboard/alps64/keymap_hasu.c @@ -0,0 +1,151 @@ +#include "keymap_common.h" + +/* + * Hasu + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = KEYMAP_AEK( \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN1, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \ + LCTL,LGUI,LALT, FN4, RALT,FN5, FN0), + + /* HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del | + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [1] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, DEL, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT, \ + LCTL,LGUI,LALT, TRNS, RALT,RGUI,TRNS), + + /* Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [2] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, DEL, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), + + /* Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [3] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS), + + /* Layer 4: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [4] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, TRNS, TRNS,TRNS,TRNS), +}; + + +/* id for user defined function/macro */ +enum function_id { + NONE, +}; + +enum macro_id { + ALT_TAB, +}; + + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), // HHKB layer + [1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // HHKB layer + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer(IJKL) + [6] = ACTION_LAYER_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), +}; + + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} diff --git a/keyboard/alps64/keymap_plain.c b/keyboard/alps64/keymap_plain.c new file mode 100644 index 0000000000..a54899196a --- /dev/null +++ b/keyboard/alps64/keymap_plain.c @@ -0,0 +1,12 @@ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP( \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,ESC, \ + LCTL,LGUI,LALT, SPC, APP, RALT,RGUI,RCTL), +}; +const uint16_t PROGMEM fn_actions[] = {}; diff --git a/keyboard/alps64/led.c b/keyboard/alps64/led.c new file mode 100644 index 0000000000..d20c51aabe --- /dev/null +++ b/keyboard/alps64/led.c @@ -0,0 +1,34 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <avr/io.h> +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1<<USB_LED_CAPS_LOCK)) { + // output high + DDRC |= (1<<5); + PORTC |= (1<<5); + } else { + // Hi-Z + DDRC &= ~(1<<5); + PORTC &= ~(1<<5); + } +} diff --git a/keyboard/alps64/matrix.c b/keyboard/alps64/matrix.c new file mode 100644 index 0000000000..5638d7f69d --- /dev/null +++ b/keyboard/alps64/matrix.c @@ -0,0 +1,200 @@ +/* +Copyright 2012 Jun Wako <wakojun@gmail.com> + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +/* + * scan matrix + */ +#include <stdint.h> +#include <stdbool.h> +#include <avr/io.h> +#include <util/delay.h> +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0) +#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0) +#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0) + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + + //debug + debug_matrix = true; + LED_ON(); + _delay_ms(500); + LED_OFF(); +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + _delay_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + _delay_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + return 1; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<<col)); +} + +inline +matrix_row_t matrix_get_row(uint8_t row) +{ + return matrix[row]; +} + +void matrix_print(void) +{ + print("\nr/c 0123456789ABCDEF\n"); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + phex(row); print(": "); + pbin_reverse16(matrix_get_row(row)); + print("\n"); + } +} + +/* Column pin configuration + * col: 0 1 2 3 4 5 6 7 + * pin: B0 B1 B2 B3 B4 B5 B6 B7 + */ +static void init_cols(void) +{ + // Input with pull-up(DDR:0, PORT:1) + DDRB &= ~0b11111111; + PORTB |= 0b11111111; +} + +/* Returns status of switches(1:on, 0:off) */ +static matrix_row_t read_cols(void) +{ + // Invert because PIN indicates 'switch on' with low(0) and 'off' with high(1) + return ~PINB; +} + +/* Row pin configuration + * row: 0 1 2 3 4 5 6 7 + * pin: D0 D1 D2 D3 D4 D5 D6 C2 + */ +static void unselect_rows(void) +{ + // Hi-Z(DDR:0, PORT:0) to unselect + DDRD &= ~0b01111111; + PORTD &= ~0b01111111; + DDRC &= ~0b00000100; + PORTC &= ~0b00000100; +} + +static void select_row(uint8_t row) +{ + // Output low(DDR:1, PORT:0) to select + switch (row) { + case 0: + DDRD |= (1<<0); + PORTD &= ~(1<<0); + break; + case 1: + DDRD |= (1<<1); + PORTD &= ~(1<<1); + break; + case 2: + DDRD |= (1<<2); + PORTD &= ~(1<<2); + break; + case 3: + DDRD |= (1<<3); + PORTD &= ~(1<<3); + break; + case 4: + DDRD |= (1<<4); + PORTD &= ~(1<<4); + break; + case 5: + DDRD |= (1<<5); + PORTD &= ~(1<<5); + break; + case 6: + DDRD |= (1<<6); + PORTD &= ~(1<<6); + break; + case 7: + DDRC |= (1<<2); + PORTC &= ~(1<<2); + break; + } +} diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index b48ee3fde6..6b0f1a0e8d 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -42,7 +42,7 @@ TARGET = gh60_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -128,8 +128,8 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc index 9655ff65a9..11bd3b7840 100644 --- a/keyboard/gh60/Makefile.pjrc +++ b/keyboard/gh60/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = gh60_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -97,11 +97,11 @@ NKRO_ENABLE = yes # USB Nkey Rollover(+500) # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk plain: OPT_DEFS += -DKEYMAP_PLAIN plain: all diff --git a/keyboard/ghost_squid/Makefile.lufa b/keyboard/ghost_squid/Makefile.lufa index 61893893a4..54adb1e3d8 100644 --- a/keyboard/ghost_squid/Makefile.lufa +++ b/keyboard/ghost_squid/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = ghostsquid_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -110,8 +110,8 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/hbkb/Makefile.lufa b/keyboard/hbkb/Makefile.lufa index 0d103c8766..322f219d69 100644 --- a/keyboard/hbkb/Makefile.lufa +++ b/keyboard/hbkb/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = hbkb_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -113,8 +113,8 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/hhkb/Makefile b/keyboard/hhkb/Makefile index dc5c06a948..5a179bd24d 100644 --- a/keyboard/hhkb/Makefile +++ b/keyboard/hhkb/Makefile @@ -42,7 +42,7 @@ TARGET = hhkb_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -120,6 +120,10 @@ NKRO_ENABLE = yes # USB Nkey Rollover #KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor #HHKB_JP = yes # HHKB JP support +#OPT_DEFS += -DNO_ACTION_TAPPING +#OPT_DEFS += -DNO_ACTION_LAYER +#OPT_DEFS += -DNO_ACTION_MACRO + # # Keymap file @@ -142,11 +146,11 @@ endif # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION debug-on: all diff --git a/keyboard/hhkb/Makefile.pjrc b/keyboard/hhkb/Makefile.pjrc index b6ce9c7504..7d0f8c3a9c 100644 --- a/keyboard/hhkb/Makefile.pjrc +++ b/keyboard/hhkb/Makefile.pjrc @@ -7,7 +7,7 @@ TARGET = hhkb_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -61,8 +61,8 @@ PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/hhkb/Makefile.rn42 b/keyboard/hhkb/Makefile.rn42 index b1eacd070f..cbb2b744c9 100644 --- a/keyboard/hhkb/Makefile.rn42 +++ b/keyboard/hhkb/Makefile.rn42 @@ -42,7 +42,7 @@ TARGET = hhkb_rn42 # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -139,13 +139,13 @@ endif # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) include rn42.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION debug-on: all diff --git a/keyboard/hhkb/doc/HHKB.txt b/keyboard/hhkb/doc/HHKB.txt index 98397b8477..3d08ceb0af 100644 --- a/keyboard/hhkb/doc/HHKB.txt +++ b/keyboard/hhkb/doc/HHKB.txt @@ -31,27 +31,28 @@ Two PCBs are connected by 15 lines(13 in case of Pro2). Vcc and GND use 3(2) lines each, other lines are for keyboard signaling. HHKB connector lines: - JP Pro2 Pro Function Description Teensy++ pins + JP Pro2 Pro Function Description TMK pin usage -------------------------------------------------------------------------------------------- 1 Vcc(5V) 5V 1 1 2 Vcc(5V) 5V 2 2 3 Vcc(5V) 5V - 3 3 4 TP1684 KEY: Low(0) when key pressed PE6 input(with pullup) - 4 4 5 TP1684 KEY_PREV: make threshold PE7 output + 3 3 4 TP1684 ~KEY: Low(0) when key is pressed PD7 input(with pullup) + 4 4 5 TP1684 HYS: High(1) when key is pressed PB7 output 5 5 6 HC4051 A(bit0)\ PB0 output 6 6 7 HC4051 B(bit1) > select row 0-7 PB1 output 7 7 8 HC4051 C(bit2)/ PB2 output 8 8 9 LS145 A(bit0)\ PB3 output 9 9 10 LS145 B(bit1) > select column 0-7 PB4 output 10 10 11 LS145 C(bit2)/ PB5 output - 11 11 12 LS145 D(enable) Low(0) enables selected column PB6 output + 11 11 12 LS145 ~D(enable) Low(0) enables selected column PB6 output 12 12 13 GND GND 13 13 14 GND GND 15 GND - 14 HC4051(Z2) ~Enable of Z2 row0-7 - 15 HC4051(Z3) ~Enable of Z3 row8-15 + 14 HC4051(Z2) ~Enable of Z2 row0-7 PC6 + 15 HC4051(Z3) ~Enable of Z3 row8-15 PC7 - NOTE: guessing pin5(KEY_PREV) may work for hysteresis of capacitive sensing. + NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result. + NOTE: HYS should be given High(1) when previous KEY state is Low(0). NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK. NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them. @@ -112,7 +113,7 @@ Matrix diagram: | <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+ | 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+ +---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8 - KEY PREV | A B C +-----------------+ + KEY HYS | A B C +-----------------+ | | +-^----+ | | | | LS145 | Vcc | | |BU9831| | | | +-^--^--^--^------+ --- | | +------+ | | | A B C D +-------+ @@ -138,7 +139,7 @@ Matrix diagram: | | +----> <6-----------|-|-|-|-|----|R|-+ | | | | | A B C <7-----------|-|-|-|-|----|R|-+ +---V---^-+ | | +-^-^-^--+ | | | | | | - KEY PREV | | | | | | | | | | | + KEY HYS | | | | | | | | | | | | | | | +--------+ | | | | | | | | | | | HC4051 <8-----------|-|-|-|-|----|R|-+ | | | | | Z3 <9-----------|-|-|-|-|----|R|-+ @@ -192,7 +193,7 @@ Signals charts 0123456701234567 selected column 3) Wait 5us after column select, then set prev, strobe colD to spit out key status and read it. - prev _~~~~_____ 20us if previous key state is low + hys _~~~~_____ 20us if previous key state is low colD ~~~__~~~~~ 10us strobe key ~~~____~~~ 22us indicates current state of the key diff --git a/keyboard/hhkb/doc/HHKB_keycodes.txt b/keyboard/hhkb/doc/HHKB_keycodes.txt new file mode 100644 index 0000000000..9ec85901e0 --- /dev/null +++ b/keyboard/hhkb/doc/HHKB_keycodes.txt @@ -0,0 +1,69 @@ +HHKB keycodes +============= +2015/10/03 +Looked into unclear keycodes(usages) of Fn-chording-key on HHKB. +Followings are usages of Keyboard/Keypad Page(0x07) that HHKB spits out when Fn key is down. + +## HHK mode(Off-Off) + Key Usage + ------------------------ + ⌘ / ◇ 0x78 Stop + +## Lite Ext. mode(On-Off) + + +## Mac mode(Off-On) + Key Usage + ------------------------ + Esc 0x66 Power + A 0x81 Volume Down + S 0x80 Volume Up + D 0x7F Mute + F 0x6F F20 + Delete 0x53 Num Lock and Clear + + +## Secret mode(On-On) + Key Usage + ------------------------ + Esc 0x66 Power + Q 0x78 Stop + W 0x7E Find + E 0x74 Execute + R 0x77 Select + T 0x76 Menu + Y 0x75 Help + Z 0x7A Undo + X 0x7B Cut + C 0x7C Copy + V 0x7D Paste + B 0x79 Again + + +## Matrix Key-Mode + + + Mode + ------------------------------- + Key HHK Lite Mac Secret Desc + --------------------------------------------------------------------------------------- + ⌘ / ◇ 0x78 - - - Stop + Esc - - 0x66 0x66 Power + A - - 0x81 - Volume Down + S - - 0x80 - Volume Up + D - - 0x7F - Mute + F - - 0x6F - F20 + Delete 0x2A 0x2A 0x53 0x2A Num Lock and Clear(0x53)/Backspace(0x2A) + Q - - - 0x78 Stop + W - - - 0x7E Find + E - - - 0x74 Execute + R - - - 0x77 Select + T - - - 0x76 Menu + Y - - - 0x75 Help + Z - - - 0x7A Undo + X - - - 0x7B Cut + C - - - 0x7C Copy + V - - - 0x7D Paste + B - - - 0x79 Again + +EOF diff --git a/keyboard/hhkb/keymap_hasu.c b/keyboard/hhkb/keymap_hasu.c index 433f9cb270..a5602ded31 100644 --- a/keyboard/hhkb/keymap_hasu.c +++ b/keyboard/hhkb/keymap_hasu.c @@ -85,7 +85,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { */ [3] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,FN9, FN10,FN8, \ LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, BTN1, TRNS,TRNS), @@ -106,7 +106,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { */ [4] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN8, \ LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, TRNS, TRNS,TRNS), diff --git a/keyboard/hhkb/keymap_hhkb.c b/keyboard/hhkb/keymap_hhkb.c index 1fc016f8e2..86ad0f5eee 100644 --- a/keyboard/hhkb/keymap_hhkb.c +++ b/keyboard/hhkb/keymap_hhkb.c @@ -1,4 +1,4 @@ -/* +/* * HHKB Layout */ #include "keymap_common.h" @@ -40,7 +40,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * `-----------------------------------------------------------' * | | | | | | * `-------------------------------------------' - */ + */ KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \ TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ @@ -55,8 +55,41 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { */ #ifdef KEYMAP_SECTION_ENABLE const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_MOMENTARY(2), + [2] = ACTION_LAYER_MOMENTARY(3), + [3] = ACTION_LAYER_MOMENTARY(4), + [4] = ACTION_LAYER_MOMENTARY(5), + [5] = ACTION_LAYER_MOMENTARY(6), + [6] = ACTION_LAYER_MOMENTARY(7), + [7] = ACTION_LAYER_TOGGLE(1), + [8] = ACTION_LAYER_TOGGLE(2), + [9] = ACTION_LAYER_TOGGLE(3), + [10] = ACTION_LAYER_TAP_TOGGLE(1), + [11] = ACTION_LAYER_TAP_TOGGLE(2), + [12] = ACTION_LAYER_TAP_TOGGLE(3), + [13] = ACTION_LAYER_TAP_KEY(1, KC_A), + [14] = ACTION_LAYER_TAP_KEY(2, KC_F), + [15] = ACTION_LAYER_TAP_KEY(3, KC_J), + [16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE), + [17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON), + [18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE), + [19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH), + [20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE), + [21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE), + [22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE), + [23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER), + [24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC), + [25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE), + [26] = ACTION_MODS_ONESHOT(MOD_LCTL), + [27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC), + [28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE), + [29] = ACTION_MODS_ONESHOT(MOD_LSFT), + [30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ESC), + [31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSPACE), +}; #else const uint16_t fn_actions[] PROGMEM = { -#endif - [0] = ACTION_LAYER_MOMENTARY(1), + [0] = ACTION_LAYER_MOMENTARY(1), }; +#endif diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index fb96997944..14fae0b82c 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -132,7 +132,13 @@ uint8_t matrix_scan(void) // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE. // This takes 25us or more to make sure KEY_STATE returns to idle state. +#ifdef HHKB_JP + // Looks like JP needs faster scan due to its twice larger matrix + // or it can drop keys in fast key typing + _delay_us(30); +#else _delay_us(75); +#endif } if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); } diff --git a/keyboard/hhkb/not_supported/Makefile.iwrap b/keyboard/hhkb/not_supported/Makefile.iwrap index 2d9d82c481..1614c21d75 100644 --- a/keyboard/hhkb/not_supported/Makefile.iwrap +++ b/keyboard/hhkb/not_supported/Makefile.iwrap @@ -7,7 +7,7 @@ TARGET = hhkb_iwrap # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -94,10 +94,10 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/iwrap.mk +include $(TMK_DIR)/protocol/iwrap.mk # TODO: to be selectable: V-USB, LUFA or PJRC -#include $(TOP_DIR)/protocol/vusb.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +#include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/hhkb/not_supported/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb index 4343b210d9..1f8d84684b 100644 --- a/keyboard/hhkb/not_supported/Makefile.vusb +++ b/keyboard/hhkb/not_supported/Makefile.vusb @@ -7,7 +7,7 @@ TARGET = hhkb_vusb # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -87,11 +87,11 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/vusb.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk debug-on: EXTRAFLAGS += -DDEBUG debug-on: all diff --git a/keyboard/hid_liber/Makefile.lufa b/keyboard/hid_liber/Makefile.lufa index c99d1a32f6..5fc4156a9e 100644 --- a/keyboard/hid_liber/Makefile.lufa +++ b/keyboard/hid_liber/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = hid_liber_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -119,11 +119,11 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk ansi: OPT_DEFS += -DLAYOUT_ANSI ansi: all diff --git a/keyboard/hid_liber/Makefile.pjrc b/keyboard/hid_liber/Makefile.pjrc index 42fb6895e1..326bbe86f5 100644 --- a/keyboard/hid_liber/Makefile.pjrc +++ b/keyboard/hid_liber/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = hid_liber_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -92,11 +92,11 @@ NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk ansi: OPT_DEFS += -DLAYOUT_ANSI ansi: all diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile index e33c239afb..e740b6adbc 100644 --- a/keyboard/infinity/Makefile +++ b/keyboard/infinity/Makefile @@ -1,7 +1,7 @@ PROJECT = infinity -TMK_DIR = ../.. -MBED_DIR = $(TMK_DIR)/mbed-sdk +TMK_DIR = ../../tmk_core +MBED_DIR = $(TMK_DIR)/tool/mbed/mbed-sdk #VPATH += $(MBED_DIR):$(TMK_DIR) vpath %.s .:$(MBED_DIR):$(TMK_DIR) diff --git a/keyboard/infinity/mbed-infinity.mk b/keyboard/infinity/mbed-infinity.mk index f5fd2c9975..2c8d2e4372 100644 --- a/keyboard/infinity/mbed-infinity.mk +++ b/keyboard/infinity/mbed-infinity.mk @@ -19,29 +19,31 @@ OBJECTS += \ $(OBJDIR)/mbed-infinity/cmsis_nvic.o \ $(OBJDIR)/mbed-infinity/system_MK20D5.o \ $(OBJDIR)/mbed-infinity/USBHAL_KL25Z.o \ - $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/analogin_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_irq_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/i2c_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/pinmap.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/port_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/pwmout_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/rtc_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/serial_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/sleep.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/spi_api.o \ - $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/us_ticker.o + $(OBJDIR)/mbed-infinity/startup_MK20D5.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/analogin_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/gpio_irq_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/i2c_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/pinmap.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/port_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/pwmout_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/rtc_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/serial_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/sleep.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/spi_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/us_ticker.o INCLUDE_PATHS += \ -Imbed \ -I$(MBED_DIR)/libraries/mbed/targets \ -I$(MBED_DIR)/libraries/mbed/targets/cmsis \ -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M \ - -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M/TOOLCHAIN_GCC_ARM \ -I$(MBED_DIR)/libraries/mbed/targets/hal \ -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale \ - -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M LINKER_SCRIPT = mbed-infinity/infinity.ld diff --git a/keyboard/infinity/mbed-infinity/README b/keyboard/infinity/mbed-infinity/README index b0d226f793..43051c9003 100644 --- a/keyboard/infinity/mbed-infinity/README +++ b/keyboard/infinity/mbed-infinity/README @@ -37,3 +37,47 @@ Clock enable: SIM_SCGC4[USBOTG] = 1 + +Infinity bootloader change +========================== +After @2c7542e(2015/01) Infinity bootloader doesn't disable watchdog timer and keyboard firmware has to do it itself. mbed disables watchdog in startup sequence but unfortunately timer is timed out bofore that. + +We have to do that in earlier phase of mbed startup sequence. + + +mbed starup sequence files: +mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_M20D5.s +mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c + +Infinity booloader change commit: +https://github.com/kiibohd/controller/commit/2c7542e2e7f0b8a99edf563dc53164fe1a439483 + +discussion: +https://geekhack.org/index.php?topic=41989.msg1686616#msg1686616 + + +WORKAROUND +---------- +Call SystemInit early in Reset_Handler. + +$ diff -u ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s mbed-infinity +--- ../../mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.s 2015-03-22 10:33:22.779866000 +0900 ++++ mbed-infinity/startup_MK20D5.s 2015-03-22 10:32:56.483866000 +0900 +@@ -147,6 +147,8 @@ + * __etext: End of code section, i.e., begin of data sections to copy from. + * __data_start__/__data_end__: RAM address range that data should be + * copied to. Both must be aligned to 4 bytes boundary. */ ++ ldr r0, =SystemInit ++ blx r0 + + ldr r1, =__etext + ldr r2, =__data_start__ +@@ -161,8 +163,6 @@ + + .Lflash_to_ram_loop_end: + +- ldr r0, =SystemInit +- blx r0 + ldr r0, =_start + bx r0 + .pool diff --git a/keyboard/infinity/mbed-infinity/startup_MK20D5.s b/keyboard/infinity/mbed-infinity/startup_MK20D5.s new file mode 100644 index 0000000000..7a8d7ba45a --- /dev/null +++ b/keyboard/infinity/mbed-infinity/startup_MK20D5.s @@ -0,0 +1,259 @@ +/* File: startup_MK20D5.s + * Purpose: startup file for Cortex-M4 devices. Should use with + * GCC for ARM Embedded Processors + * Version: V1.3 + * Date: 08 Feb 2012 + * + * Copyright (c) 2012, ARM Limited + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the ARM Limited nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + .syntax unified + .arch armv7-m + + .section .stack + .align 3 +#ifdef __STACK_SIZE + .equ Stack_Size, __STACK_SIZE +#else + .equ Stack_Size, 0x400 +#endif + .globl __StackTop + .globl __StackLimit +__StackLimit: + .space Stack_Size + .size __StackLimit, . - __StackLimit +__StackTop: + .size __StackTop, . - __StackTop + + .section .heap + .align 3 +#ifdef __HEAP_SIZE + .equ Heap_Size, __HEAP_SIZE +#else + .equ Heap_Size, 0xC00 +#endif + .globl __HeapBase + .globl __HeapLimit +__HeapBase: + .if Heap_Size + .space Heap_Size + .endif + .size __HeapBase, . - __HeapBase +__HeapLimit: + .size __HeapLimit, . - __HeapLimit + + .section .isr_vector + .align 2 + .globl __isr_vector +__isr_vector: + .long __StackTop /* Top of Stack */ + .long Reset_Handler /* Reset Handler */ + .long NMI_Handler /* NMI Handler */ + .long HardFault_Handler /* Hard Fault Handler */ + .long MemManage_Handler /* MPU Fault Handler */ + .long BusFault_Handler /* Bus Fault Handler */ + .long UsageFault_Handler /* Usage Fault Handler */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long SVC_Handler /* SVCall Handler */ + .long DebugMon_Handler /* Debug Monitor Handler */ + .long 0 /* Reserved */ + .long PendSV_Handler /* PendSV Handler */ + .long SysTick_Handler /* SysTick Handler */ + + /* External interrupts */ + .long DMA0_IRQHandler /* 0: Watchdog Timer */ + .long DMA1_IRQHandler /* 1: Real Time Clock */ + .long DMA2_IRQHandler /* 2: Timer0 / Timer1 */ + .long DMA3_IRQHandler /* 3: Timer2 / Timer3 */ + .long DMA_Error_IRQHandler /* 4: MCIa */ + .long 0 /* 5: MCIb */ + .long FTFL_IRQHandler /* 6: UART0 - DUT FPGA */ + .long Read_Collision_IRQHandler /* 7: UART1 - DUT FPGA */ + .long LVD_LVW_IRQHandler /* 8: UART2 - DUT FPGA */ + .long LLW_IRQHandler /* 9: UART4 - not connected */ + .long Watchdog_IRQHandler /* 10: AACI / AC97 */ + .long I2C0_IRQHandler /* 11: CLCD Combined Interrupt */ + .long SPI0_IRQHandler /* 12: Ethernet */ + .long I2S0_Tx_IRQHandler /* 13: USB Device */ + .long I2S0_Rx_IRQHandler /* 14: USB Host Controller */ + .long UART0_LON_IRQHandler /* 15: Character LCD */ + .long UART0_RX_TX_IRQHandler /* 16: Flexray */ + .long UART0_ERR_IRQHandler /* 17: CAN */ + .long UART1_RX_TX_IRQHandler /* 18: LIN */ + .long UART1_ERR_IRQHandler /* 19: I2C ADC/DAC */ + .long UART2_RX_TX_IRQHandler /* 20: Reserved */ + .long UART2_ERR_IRQHandler /* 21: Reserved */ + .long ADC0_IRQHandler /* 22: Reserved */ + .long CMP0_IRQHandler /* 23: Reserved */ + .long CMP1_IRQHandler /* 24: Reserved */ + .long FTM0_IRQHandler /* 25: Reserved */ + .long FTM1_IRQHandler /* 26: Reserved */ + .long CMT_IRQHandler /* 27: Reserved */ + .long RTC_IRQHandler /* 28: Reserved - CPU FPGA CLCD */ + .long RTC_Seconds_IRQHandler /* 29: Reserved - CPU FPGA */ + .long PIT0_IRQHandler /* 30: UART3 - CPU FPGA */ + .long PIT1_IRQHandler /* 31: SPI Touchscreen - CPU FPGA */ + .long PIT2_IRQHandler + .long PIT3_IRQHandler + .long PDB0_IRQHandler + .long USB0_IRQHandler + .long USBDCD_IRQHandler + .long TSI0_IRQHandler + .long MCG_IRQHandler + .long LPTimer_IRQHandler + .long PORTA_IRQHandler + .long PORTB_IRQHandler + .long PORTC_IRQHandler + .long PORTD_IRQHandler + .long PORTE_IRQHandler + .long SWI_IRQHandler + .size __isr_vector, . - __isr_vector + + .section .text.Reset_Handler + .thumb + .thumb_func + .align 2 + .globl Reset_Handler + .type Reset_Handler, %function +Reset_Handler: +/* Loop to copy data from read only memory to RAM. The ranges + * of copy from/to are specified by following symbols evaluated in + * linker script. + * __etext: End of code section, i.e., begin of data sections to copy from. + * __data_start__/__data_end__: RAM address range that data should be + * copied to. Both must be aligned to 4 bytes boundary. */ + ldr r0, =SystemInit + blx r0 + + ldr r1, =__etext + ldr r2, =__data_start__ + ldr r3, =__data_end__ + +.Lflash_to_ram_loop: + cmp r2, r3 + ittt lt + ldrlt r0, [r1], #4 + strlt r0, [r2], #4 + blt .Lflash_to_ram_loop + +.Lflash_to_ram_loop_end: + + ldr r0, =_start + bx r0 + .pool + .size Reset_Handler, . - Reset_Handler + + .text +/* Macro to define default handlers. Default handler + * will be weak symbol and just dead loops. They can be + * overwritten by other handlers */ + .macro def_default_handler handler_name + .align 1 + .thumb_func + .weak \handler_name + .type \handler_name, %function +\handler_name : + b . + .size \handler_name, . - \handler_name + .endm + + def_default_handler NMI_Handler + def_default_handler HardFault_Handler + def_default_handler MemManage_Handler + def_default_handler BusFault_Handler + def_default_handler UsageFault_Handler + def_default_handler SVC_Handler + def_default_handler DebugMon_Handler + def_default_handler PendSV_Handler + def_default_handler SysTick_Handler + def_default_handler Default_Handler + + .macro def_irq_default_handler handler_name + .weak \handler_name + .set \handler_name, Default_Handler + .endm + + def_irq_default_handler DMA0_IRQHandler + def_irq_default_handler DMA1_IRQHandler + def_irq_default_handler DMA2_IRQHandler + def_irq_default_handler DMA3_IRQHandler + def_irq_default_handler DMA_Error_IRQHandler + def_irq_default_handler FTFL_IRQHandler + def_irq_default_handler Read_Collision_IRQHandler + def_irq_default_handler LVD_LVW_IRQHandler + def_irq_default_handler LLW_IRQHandler + def_irq_default_handler Watchdog_IRQHandler + def_irq_default_handler I2C0_IRQHandler + def_irq_default_handler SPI0_IRQHandler + def_irq_default_handler I2S0_Tx_IRQHandler + def_irq_default_handler I2S0_Rx_IRQHandler + def_irq_default_handler UART0_LON_IRQHandler + def_irq_default_handler UART0_RX_TX_IRQHandler + def_irq_default_handler UART0_ERR_IRQHandler + def_irq_default_handler UART1_RX_TX_IRQHandler + def_irq_default_handler UART1_ERR_IRQHandler + def_irq_default_handler UART2_RX_TX_IRQHandler + def_irq_default_handler UART2_ERR_IRQHandler + def_irq_default_handler ADC0_IRQHandler + def_irq_default_handler CMP0_IRQHandler + def_irq_default_handler CMP1_IRQHandler + def_irq_default_handler FTM0_IRQHandler + def_irq_default_handler FTM1_IRQHandler + def_irq_default_handler CMT_IRQHandler + def_irq_default_handler RTC_IRQHandler + def_irq_default_handler RTC_Seconds_IRQHandler + def_irq_default_handler PIT0_IRQHandler + def_irq_default_handler PIT1_IRQHandler + def_irq_default_handler PIT2_IRQHandler + def_irq_default_handler PIT3_IRQHandler + def_irq_default_handler PDB0_IRQHandler + def_irq_default_handler USB0_IRQHandler + def_irq_default_handler USBDCD_IRQHandler + def_irq_default_handler TSI0_IRQHandler + def_irq_default_handler MCG_IRQHandler + def_irq_default_handler LPTimer_IRQHandler + def_irq_default_handler PORTA_IRQHandler + def_irq_default_handler PORTB_IRQHandler + def_irq_default_handler PORTC_IRQHandler + def_irq_default_handler PORTD_IRQHandler + def_irq_default_handler PORTE_IRQHandler + def_irq_default_handler SWI_IRQHandler + def_irq_default_handler DEF_IRQHandler + +/* Flash protection region, placed at 0x400 */ + .text + .thumb + .align 2 + .section .kinetis_flash_config_field,"a",%progbits +kinetis_flash_config: + .long 0xffffffff + .long 0xffffffff + .long 0xffffffff + .long 0xfffffffe + + .end diff --git a/keyboard/infinity/tool/README b/keyboard/infinity/tool/README index 3dd3316568..698314e250 100644 --- a/keyboard/infinity/tool/README +++ b/keyboard/infinity/tool/README @@ -2,7 +2,7 @@ OpenOCD config files for Kinetis ================================ http://nemuisan.blog.bai.ne.jp/?eid=192848#OPENOCD -These are needed for SWD debug and programing bootloader. To flash keyboard firmware use 'dfu-util'. +These are needed for debug and programing bootloader with SWD. To flash keyboard firmware use 'dfu-util'. Flash security of Freescale kinetis ----------------------------------- @@ -21,5 +21,83 @@ Flash bootloader: Infinity SWD pinout ------------------- -SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, VCC from top. +SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, 5V from top. Note that RESET is also needed to get full control with OpenOCD. + + -------- + | ___ o |CLK + ||RST| o |DIO + ||BTN| o |GND + | --- o |5V + -------- + + +Kinetis sercure state +---------------------- +openocd 0.9.0 + +Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! ********** +Warn : **** **** +Warn : **** Your Kinetis MCU is in secured state, which means that, **** +Warn : **** with exception for very basic communication, JTAG/SWD **** +Warn : **** interface will NOT work. In order to restore its **** +Warn : **** functionality please issue 'kinetis mdm mass_erase' **** +Warn : **** command, power cycle the MCU and restart OpenOCD. **** +Warn : **** **** +Warn : *********** ATTENTION! ATTENTION! ATTENTION! ATTENTION! ********** + + +Info : MDM: Chip is unsecured. Continuing. +target state: halted +target halted due to debug-request, current mode: Thread +xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc +auto erase enabled +Info : Probing flash info for bank 0 +Warn : flash configuration field erased, please reset the device +wrote 4096 bytes from file kiibohd_bootloader.bin in 2.442562s (1.638 KiB/s) +Info : MDM: Chip is unsecured. Continuing. + + + + +Open On-Chip Debugger 0.9.0-dev-00346-g3e1dfdc-dirty (2015-03-21-20:41) +Licensed under GNU GPL v2 +For bug reports, read + http://openocd.sourceforge.net/doc/doxygen/bugs.html +Info : only one transport option; autoselect 'cmsis-dap' +Kinetis MUST need Hardware SRST Control to Recover Secure-State! +adapter_nsrst_delay: 200 +srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst +Info : add flash_bank kinetis k20.pflash +cortex_m reset_config sysresetreq +adapter speed: 1000 kHz +srst_only separate srst_nogate srst_open_drain connect_assert_srst +Info : CMSIS-DAP: SWD Supported +Info : CMSIS-DAP: Interface Initialised (SWD) +Info : CMSIS-DAP: FW Version = 1.0 +Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1 +Info : Connecting under reset +Info : DAP_SWJ Sequence (reset: 50+ '1' followed by 0) +Info : CMSIS-DAP: Interface ready +Info : clock speed 1000 kHz +Info : IDCODE 0x2ba01477 +Warn : Adapter returned success despite SSTICKYERR being set. +Warn : Adapter returned success despite SSTICKYERR being set. +Warn : Adapter returned success despite SSTICKYERR being set. +Warn : Adapter returned success despite SSTICKYERR being set. +Info : k20.cpu: hardware has 6 breakpoints, 4 watchpoints +Info : MDM: Chip is unsecured. Continuing. +Info : MDM: Chip is unsecured. Continuing. +target state: halted +target halted due to debug-request, current mode: Thread +xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc +auto erase enabled +Info : Probing flash info for bank 0 +Warn : flash configuration field erased, please reset the device +wrote 4096 bytes from file kiibohd_bootloader.bin in 2.446902s (1.635 KiB/s) +Info : MDM: Chip is unsecured. Continuing. +Info : Halt timed out, wake up GDB. +Error: timed out while waiting for target halted +Runtime Error: tool/k20dx32_flash.cfg:81: +in procedure 'mt_flash' +in procedure 'halt' called at file "tool/k20dx32_flash.cfg", line 81 diff --git a/keyboard/infinity/tool/k20dx32_flash.cfg b/keyboard/infinity/tool/k20dx32_flash.cfg index 714d9991f8..1e3deb0910 100644 --- a/keyboard/infinity/tool/k20dx32_flash.cfg +++ b/keyboard/infinity/tool/k20dx32_flash.cfg @@ -2,6 +2,22 @@ # Nemuisan's Special for MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5 +# 0.8.0 has no these procs +proc using_jtag {} { + set _TRANSPORT [ transport select ] + expr { [ string first "jtag" $_TRANSPORT ] != -1 } +} + +proc using_swd {} { + set _TRANSPORT [ transport select ] + expr { [ string first "swd" $_TRANSPORT ] != -1 } +} + +proc using_hla {} { + set _TRANSPORT [ transport select ] + expr { [ string first "hla" $_TRANSPORT ] != -1 } +} + source [find target/swj-dp.tcl] if { [info exists CHIPNAME] } { @@ -109,7 +125,6 @@ proc eraser {} { shutdown } - #debug_level 3 # HLA doesn't have cortex_m commands if {![using_hla]} { diff --git a/keyboard/kitten_paw/Makefile.lufa b/keyboard/kitten_paw/Makefile.lufa index 4a643ea790..a45a3edb96 100644 --- a/keyboard/kitten_paw/Makefile.lufa +++ b/keyboard/kitten_paw/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = kittenpaw_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -110,8 +110,8 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/kmac/Makefile.lufa b/keyboard/kmac/Makefile.lufa index 09343d4bc4..9745f43cd4 100644 --- a/keyboard/kmac/Makefile.lufa +++ b/keyboard/kmac/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = kmac_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -117,11 +117,11 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk winkey: OPT_DEFS += -DLAYOUT_WINKEY winkey: all diff --git a/keyboard/kmac/Makefile.pjrc b/keyboard/kmac/Makefile.pjrc index 22ee8de47a..b32d935bdf 100644 --- a/keyboard/kmac/Makefile.pjrc +++ b/keyboard/kmac/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = kmac_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -88,11 +88,11 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk winkey: OPT_DEFS += -DLAYOUT_WINKEY winkey: all diff --git a/keyboard/lightpad/Makefile.lufa b/keyboard/lightpad/Makefile.lufa index 7bce7ebffc..88fb90ec4b 100644 --- a/keyboard/lightpad/Makefile.lufa +++ b/keyboard/lightpad/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = lightpad_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -110,8 +110,8 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/lightsaber/Makefile.lufa b/keyboard/lightsaber/Makefile.lufa index b430efd229..99090c4367 100644 --- a/keyboard/lightsaber/Makefile.lufa +++ b/keyboard/lightsaber/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = lightsaber_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -116,11 +116,11 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk winkey: OPT_DEFS += -DLAYOUT_WINKEY winkey: all diff --git a/keyboard/lightsaber/Makefile.pjrc b/keyboard/lightsaber/Makefile.pjrc index 58735a7ef0..0f6d399470 100644 --- a/keyboard/lightsaber/Makefile.pjrc +++ b/keyboard/lightsaber/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = lightsaber_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -84,11 +84,11 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk winkey: OPT_DEFS += -DLAYOUT_WINKEY winkey: all diff --git a/keyboard/macway/Makefile.lufa b/keyboard/macway/Makefile.lufa index 359a8c246d..8fff93ada5 100644 --- a/keyboard/macway/Makefile.lufa +++ b/keyboard/macway/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = macway_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -114,8 +114,8 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/macway/Makefile.pjrc b/keyboard/macway/Makefile.pjrc index 9e84a34185..6ee25b61af 100644 --- a/keyboard/macway/Makefile.pjrc +++ b/keyboard/macway/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = macway_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -90,8 +90,8 @@ PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/mbed_onekey/Makefile b/keyboard/mbed_onekey/Makefile index b1e5f5e594..b9c88fdd31 100644 --- a/keyboard/mbed_onekey/Makefile +++ b/keyboard/mbed_onekey/Makefile @@ -1,6 +1,6 @@ PROJECT = mbed_onekey -TMK_DIR = ../.. +TMK_DIR = ../../tmk_core MBED_DIR = $(TMK_DIR)/mbed-sdk #VPATH += $(MBED_DIR):$(TMK_DIR) diff --git a/keyboard/nerd/Makefile b/keyboard/nerd/Makefile index 5fd382841f..30149345ce 100644 --- a/keyboard/nerd/Makefile +++ b/keyboard/nerd/Makefile @@ -42,7 +42,7 @@ TARGET = nerd_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -119,8 +119,8 @@ BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/onekey/Makefile b/keyboard/onekey/Makefile index 78732e470d..0b54e7d25c 100644 --- a/keyboard/onekey/Makefile +++ b/keyboard/onekey/Makefile @@ -42,7 +42,7 @@ TARGET = onekey_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -124,9 +124,9 @@ CONSOLE_ENABLE = yes # Console for debug(+400) # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/onekey/Makefile.pjrc b/keyboard/onekey/Makefile.pjrc index 24ade33505..ebf0710f73 100644 --- a/keyboard/onekey/Makefile.pjrc +++ b/keyboard/onekey/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = onekey_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -95,9 +95,9 @@ PS2_USE_BUSYWAIT = yes # uses primitive reference code # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/onekey/Makefile.vusb b/keyboard/onekey/Makefile.vusb new file mode 100644 index 0000000000..fb1fbdfea2 --- /dev/null +++ b/keyboard/onekey/Makefile.vusb @@ -0,0 +1,88 @@ +# Target file name (without extension). +TARGET = onekey_vusb + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# keyboard dependent files +SRC = keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + + +# MCU name, you MUST set this to match the board you are using +# type "make clean" after changing this, so all files will be rebuilt +#MCU = atmega168p +MCU = atmega328p + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU = 12000000 + + +# Build Options +# comment out to disable the options. +# +#MOUSEKEY_ENABLE = yes # Mouse keys +#EXTRAKEY_ENABLE = yes # Audio control and System control +#NKRO_ENABLE = yes # USB Nkey Rollover + + + +#---------------- Programming Options -------------------------- +AVRDUDE = avrdude +# Type: avrdude -c ? to get a full listing. +AVRDUDE_PROGRAMMER = usbasp +AVRDUDE_PORT = +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBasp 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=2048 + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/onekey/usbconfig.h b/keyboard/onekey/usbconfig.h new file mode 100644 index 0000000000..d0ca4c717e --- /dev/null +++ b/keyboard/onekey/usbconfig.h @@ -0,0 +1,377 @@ +/* Name: usbconfig.h + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2005-04-01 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ + */ + +#ifndef __usbconfig_h_included__ +#define __usbconfig_h_included__ + + +/* +General Description: +This file is an example configuration (with inline documentation) for the USB +driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is +also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may +wire the lines to any other port, as long as D+ is also wired to INT0 (or any +other hardware interrupt, as long as it is the highest level interrupt, see +section at the end of this file). +*/ + +/* ---------------------------- Hardware Config ---------------------------- */ + +#define USB_CFG_IOPORTNAME D +/* This is the port where the USB bus is connected. When you configure it to + * "B", the registers PORTB, PINB and DDRB will be used. + */ +#define USB_CFG_DMINUS_BIT 3 +/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. + * This may be any bit in the port. + */ +#define USB_CFG_DPLUS_BIT 2 +/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. + * This may be any bit in the port. Please note that D+ must also be connected + * to interrupt pin INT0! [You can also use other interrupts, see section + * "Optional MCU Description" below, or you can connect D- to the interrupt, as + * it is required if you use the USB_COUNT_SOF feature. If you use D- for the + * interrupt, the USB interrupt will also be triggered at Start-Of-Frame + * markers every millisecond.] + */ +#define USB_CFG_CLOCK_KHZ (F_CPU/1000) +/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, + * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code + * require no crystal, they tolerate +/- 1% deviation from the nominal + * frequency. All other rates require a precision of 2000 ppm and thus a + * crystal! + * Since F_CPU should be defined to your actual clock rate anyway, you should + * not need to modify this setting. + */ +#define USB_CFG_CHECK_CRC 0 +/* Define this to 1 if you want that the driver checks integrity of incoming + * data packets (CRC checks). CRC checks cost quite a bit of code size and are + * currently only available for 18 MHz crystal clock. You must choose + * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. + */ + +/* ----------------------- Optional Hardware Config ------------------------ */ + +/* #define USB_CFG_PULLUP_IOPORTNAME D */ +/* If you connect the 1.5k pullup resistor from D- to a port pin instead of + * V+, you can connect and disconnect the device from firmware by calling + * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). + * This constant defines the port on which the pullup resistor is connected. + */ +/* #define USB_CFG_PULLUP_BIT 4 */ +/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined + * above) where the 1.5k pullup resistor is connected. See description + * above for details. + */ + +/* --------------------------- Functional Range ---------------------------- */ + +#define USB_CFG_HAVE_INTRIN_ENDPOINT 1 +/* Define this to 1 if you want to compile a version with two endpoints: The + * default control endpoint 0 and an interrupt-in endpoint (any other endpoint + * number). + */ +#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1 +/* Define this to 1 if you want to compile a version with three endpoints: The + * default control endpoint 0, an interrupt-in endpoint 3 (or the number + * configured below) and a catch-all default interrupt-in endpoint as above. + * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. + */ +#define USB_CFG_EP3_NUMBER 3 +/* If the so-called endpoint 3 is used, it can now be configured to any other + * endpoint number (except 0) with this macro. Default if undefined is 3. + */ +/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ +/* The above macro defines the startup condition for data toggling on the + * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. + * Since the token is toggled BEFORE sending any data, the first packet is + * sent with the oposite value of this configuration! + */ +#define USB_CFG_IMPLEMENT_HALT 0 +/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature + * for endpoint 1 (interrupt endpoint). Although you may not need this feature, + * it is required by the standard. We have made it a config option because it + * bloats the code considerably. + */ +#define USB_CFG_SUPPRESS_INTR_CODE 0 +/* Define this to 1 if you want to declare interrupt-in endpoints, but don't + * want to send any data over them. If this macro is defined to 1, functions + * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if + * you need the interrupt-in endpoints in order to comply to an interface + * (e.g. HID), but never want to send any data. This option saves a couple + * of bytes in flash memory and the transmit buffers in RAM. + */ +#define USB_CFG_INTR_POLL_INTERVAL 10 +/* If you compile a version with endpoint 1 (interrupt-in), this is the poll + * interval. The value is in milliseconds and must not be less than 10 ms for + * low speed devices. + */ +#define USB_CFG_IS_SELF_POWERED 0 +/* Define this to 1 if the device has its own power supply. Set it to 0 if the + * device is powered from the USB bus. + */ +#define USB_CFG_MAX_BUS_POWER 100 +/* Set this variable to the maximum USB bus power consumption of your device. + * The value is in milliamperes. [It will be divided by two since USB + * communicates power requirements in units of 2 mA.] + */ +#define USB_CFG_IMPLEMENT_FN_WRITE 1 +/* Set this to 1 if you want usbFunctionWrite() to be called for control-out + * transfers. Set it to 0 if you don't need it and want to save a couple of + * bytes. + */ +#define USB_CFG_IMPLEMENT_FN_READ 0 +/* Set this to 1 if you need to send control replies which are generated + * "on the fly" when usbFunctionRead() is called. If you only want to send + * data from a static buffer, set it to 0 and return the data from + * usbFunctionSetup(). This saves a couple of bytes. + */ +#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 +/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. + * You must implement the function usbFunctionWriteOut() which receives all + * interrupt/bulk data sent to any endpoint other than 0. The endpoint number + * can be found in 'usbRxToken'. + */ +#define USB_CFG_HAVE_FLOWCONTROL 0 +/* Define this to 1 if you want flowcontrol over USB data. See the definition + * of the macros usbDisableAllRequests() and usbEnableAllRequests() in + * usbdrv.h. + */ +#define USB_CFG_DRIVER_FLASH_PAGE 0 +/* If the device has more than 64 kBytes of flash, define this to the 64 k page + * where the driver's constants (descriptors) are located. Or in other words: + * Define this to 1 for boot loaders on the ATMega128. + */ +#define USB_CFG_LONG_TRANSFERS 0 +/* Define this to 1 if you want to send/receive blocks of more than 254 bytes + * in a single control-in or control-out transfer. Note that the capability + * for long transfers increases the driver size. + */ +/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ +/* This macro is a hook if you want to do unconventional things. If it is + * defined, it's inserted at the beginning of received message processing. + * If you eat the received message and don't want default processing to + * proceed, do a return after doing your things. One possible application + * (besides debugging) is to flash a status LED on each packet. + */ +/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ +/* This macro is a hook if you need to know when an USB RESET occurs. It has + * one parameter which distinguishes between the start of RESET state and its + * end. + */ +/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ +/* This macro (if defined) is executed when a USB SET_ADDRESS request was + * received. + */ +#define USB_COUNT_SOF 0 +/* define this macro to 1 if you need the global variable "usbSofCount" which + * counts SOF packets. This feature requires that the hardware interrupt is + * connected to D- instead of D+. + */ +/* #ifdef __ASSEMBLER__ + * macro myAssemblerMacro + * in YL, TCNT0 + * sts timer0Snapshot, YL + * endm + * #endif + * #define USB_SOF_HOOK myAssemblerMacro + * This macro (if defined) is executed in the assembler module when a + * Start Of Frame condition is detected. It is recommended to define it to + * the name of an assembler macro which is defined here as well so that more + * than one assembler instruction can be used. The macro may use the register + * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages + * immediately after an SOF pulse may be lost and must be retried by the host. + * What can you do with this hook? Since the SOF signal occurs exactly every + * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in + * designs running on the internal RC oscillator. + * Please note that Start Of Frame detection works only if D- is wired to the + * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! + */ +#define USB_CFG_CHECK_DATA_TOGGLING 0 +/* define this macro to 1 if you want to filter out duplicate data packets + * sent by the host. Duplicates occur only as a consequence of communication + * errors, when the host does not receive an ACK. Please note that you need to + * implement the filtering yourself in usbFunctionWriteOut() and + * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable + * for each control- and out-endpoint to check for duplicate packets. + */ +#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 +/* define this macro to 1 if you want the function usbMeasureFrameLength() + * compiled in. This function can be used to calibrate the AVR's RC oscillator. + */ +#define USB_USE_FAST_CRC 0 +/* The assembler module has two implementations for the CRC algorithm. One is + * faster, the other is smaller. This CRC routine is only used for transmitted + * messages where timing is not critical. The faster routine needs 31 cycles + * per byte while the smaller one needs 61 to 69 cycles. The faster routine + * may be worth the 32 bytes bigger code size if you transmit lots of data and + * run the AVR close to its limit. + */ + +/* -------------------------- Device Description --------------------------- */ + +#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF) +/* USB vendor ID for the device, low byte first. If you have registered your + * own Vendor ID, define it here. Otherwise you may use one of obdev's free + * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF) +/* This is the ID of the product, low byte first. It is interpreted in the + * scope of the vendor ID. If you have registered your own VID with usb.org + * or if you have licensed a PID from somebody else, define it here. Otherwise + * you may use one of obdev's free shared VID/PID pairs. See the file + * USB-IDs-for-free.txt for details! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_VERSION 0x00, 0x01 +/* Version number of the device: Minor number first, then major number. + */ +#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.' +#define USB_CFG_VENDOR_NAME_LEN 6 +/* These two values define the vendor name returned by the USB device. The name + * must be given as a list of characters under single quotes. The characters + * are interpreted as Unicode (UTF-16) entities. + * If you don't want a vendor name string, undefine these macros. + * ALWAYS define a vendor name containing your Internet domain name if you use + * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for + * details. + */ +#define USB_CFG_DEVICE_NAME 'P', 'S', '/', '2', ' ', 'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', 'e', 'r' +#define USB_CFG_DEVICE_NAME_LEN 23 +/* Same as above for the device name. If you don't want a device name, undefine + * the macros. See the file USB-IDs-for-free.txt before you assign a name if + * you use a shared VID/PID. + */ +/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ +/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ +/* Same as above for the serial number. If you don't want a serial number, + * undefine the macros. + * It may be useful to provide the serial number through other means than at + * compile time. See the section about descriptor properties below for how + * to fine tune control over USB descriptors such as the string descriptor + * for the serial number. + */ +#define USB_CFG_DEVICE_CLASS 0 +#define USB_CFG_DEVICE_SUBCLASS 0 +/* See USB specification if you want to conform to an existing device class. + * Class 0xff is "vendor specific". + */ +#define USB_CFG_INTERFACE_CLASS 3 /* HID */ +#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */ +#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */ +/* See USB specification if you want to conform to an existing device class or + * protocol. The following classes must be set at interface level: + * HID class is 3, no subclass and protocol required (but may be useful!) + * CDC class is 2, use subclass 2 and protocol 1 for ACM + */ +#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 +/* Define this to the length of the HID report descriptor, if you implement + * an HID device. Otherwise don't define it or define it to 0. + * If you use this define, you must add a PROGMEM character array named + * "usbHidReportDescriptor" to your code which contains the report descriptor. + * Don't forget to keep the array and this define in sync! + */ + +/* #define USB_PUBLIC static */ +/* Use the define above if you #include usbdrv.c instead of linking against it. + * This technique saves a couple of bytes in flash memory. + */ + +/* ------------------- Fine Control over USB Descriptors ------------------- */ +/* If you don't want to use the driver's default USB descriptors, you can + * provide our own. These can be provided as (1) fixed length static data in + * flash memory, (2) fixed length static data in RAM or (3) dynamically at + * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more + * information about this function. + * Descriptor handling is configured through the descriptor's properties. If + * no properties are defined or if they are 0, the default descriptor is used. + * Possible properties are: + * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched + * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is + * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if + * you want RAM pointers. + * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found + * in static memory is in RAM, not in flash memory. + * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), + * the driver must know the descriptor's length. The descriptor itself is + * found at the address of a well known identifier (see below). + * List of static descriptor names (must be declared PROGMEM if in flash): + * char usbDescriptorDevice[]; + * char usbDescriptorConfiguration[]; + * char usbDescriptorHidReport[]; + * char usbDescriptorString0[]; + * int usbDescriptorStringVendor[]; + * int usbDescriptorStringDevice[]; + * int usbDescriptorStringSerialNumber[]; + * Other descriptors can't be provided statically, they must be provided + * dynamically at runtime. + * + * Descriptor properties are or-ed or added together, e.g.: + * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) + * + * The following descriptors are defined: + * USB_CFG_DESCR_PROPS_DEVICE + * USB_CFG_DESCR_PROPS_CONFIGURATION + * USB_CFG_DESCR_PROPS_STRINGS + * USB_CFG_DESCR_PROPS_STRING_0 + * USB_CFG_DESCR_PROPS_STRING_VENDOR + * USB_CFG_DESCR_PROPS_STRING_PRODUCT + * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER + * USB_CFG_DESCR_PROPS_HID + * USB_CFG_DESCR_PROPS_HID_REPORT + * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) + * + * Note about string descriptors: String descriptors are not just strings, they + * are Unicode strings prefixed with a 2 byte header. Example: + * int serialNumberDescriptor[] = { + * USB_STRING_DESCRIPTOR_HEADER(6), + * 'S', 'e', 'r', 'i', 'a', 'l' + * }; + */ + +#define USB_CFG_DESCR_PROPS_DEVICE 0 +#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 +#define USB_CFG_DESCR_PROPS_STRINGS 0 +#define USB_CFG_DESCR_PROPS_STRING_0 0 +#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 +#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 +#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 +//#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC +#define USB_CFG_DESCR_PROPS_HID 0 +#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_HID_REPORT 0 +#define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +/* ----------------------- Optional MCU Description ------------------------ */ + +/* The following configurations have working defaults in usbdrv.h. You + * usually don't need to set them explicitly. Only if you want to run + * the driver on a device which is not yet supported or with a compiler + * which is not fully supported (such as IAR C) or if you use a differnt + * interrupt than INT0, you may have to define some of these. + */ +/* #define USB_INTR_CFG MCUCR */ +/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE GIMSK */ +/* #define USB_INTR_ENABLE_BIT INT0 */ +/* #define USB_INTR_PENDING GIFR */ +/* #define USB_INTR_PENDING_BIT INTF0 */ +/* #define USB_INTR_VECTOR INT0_vect */ + +#endif /* __usbconfig_h_included__ */ diff --git a/keyboard/phantom/Makefile.lufa b/keyboard/phantom/Makefile.lufa index 97756de0a1..a0b3b1444d 100644 --- a/keyboard/phantom/Makefile.lufa +++ b/keyboard/phantom/Makefile.lufa @@ -42,7 +42,7 @@ TARGET = phantom_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -115,11 +115,11 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk ansi: OPT_DEFS += -DLAYOUT_ANSI ansi: all diff --git a/keyboard/phantom/Makefile.pjrc b/keyboard/phantom/Makefile.pjrc index aa01ac5ab2..7bf5f80f40 100644 --- a/keyboard/phantom/Makefile.pjrc +++ b/keyboard/phantom/Makefile.pjrc @@ -42,7 +42,7 @@ TARGET = phantom_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -86,11 +86,11 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk ansi: OPT_DEFS += -DLAYOUT_ANSI ansi: all diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 643646155f..fc26905d80 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -44,6 +44,7 @@ TARGET = planck # Directory common source filess exist TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -133,6 +134,7 @@ BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID # Search Path VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) include $(TOP_DIR)/quantum.mk diff --git a/keyboard/planck/__avr_gdbinit b/keyboard/planck/__avr_gdbinit deleted file mode 100644 index afc51e6d19..0000000000 --- a/keyboard/planck/__avr_gdbinit +++ /dev/null @@ -1,6 +0,0 @@ -define reset -SIGNAL SIGHUP -end -file planck_lufa.elf -target remote localhost:4242 -break main |