diff options
| author | tmk <nobody@nowhere> | 2012-12-27 02:41:32 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-12-27 02:41:32 +0900 |
| commit | c009f4643c17084b8f632b3292e0c7962b324ae5 (patch) | |
| tree | 10490ca64f2ee8cbe6d5f6531c954826f2c4756e /keyboard/gh60 | |
| parent | 6ebe99f37c15c80c36d942e581794dc0cf3b68a4 (diff) | |
| download | qmk_firmware-c009f4643c17084b8f632b3292e0c7962b324ae5.tar.gz qmk_firmware-c009f4643c17084b8f632b3292e0c7962b324ae5.zip | |
Added Initial files for gh60.
Diffstat (limited to 'keyboard/gh60')
| -rw-r--r-- | keyboard/gh60/Makefile.lufa | 120 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.pjrc | 90 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 50 | ||||
| -rw-r--r-- | keyboard/gh60/keymap.c | 187 | ||||
| -rw-r--r-- | keyboard/gh60/led.c | 34 | ||||
| -rw-r--r-- | keyboard/gh60/matrix.c | 225 |
6 files changed, 706 insertions, 0 deletions
diff --git a/keyboard/gh60/Makefile.lufa b/keyboard/gh60/Makefile.lufa new file mode 100644 index 000000000..0977b33f3 --- /dev/null +++ b/keyboard/gh60/Makefile.lufa | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = gh60_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap.c \ | ||
| 53 | matrix.c \ | ||
| 54 | led.c | ||
| 55 | |||
| 56 | CONFIG_H = config.h | ||
| 57 | |||
| 58 | |||
| 59 | # MCU name | ||
| 60 | #MCU = at90usb1287 | ||
| 61 | MCU = atmega32u4 | ||
| 62 | |||
| 63 | # Processor frequency. | ||
| 64 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 65 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 66 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 67 | # automatically to create a 32-bit value in your source code. | ||
| 68 | # | ||
| 69 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 70 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 71 | # does not *change* the processor frequency - it should merely be updated to | ||
| 72 | # reflect the processor speed set externally so that the code can use accurate | ||
| 73 | # software delays. | ||
| 74 | F_CPU = 16000000 | ||
| 75 | |||
| 76 | |||
| 77 | # | ||
| 78 | # LUFA specific | ||
| 79 | # | ||
| 80 | # Target architecture (see library "Board Types" documentation). | ||
| 81 | ARCH = AVR8 | ||
| 82 | |||
| 83 | # Input clock frequency. | ||
| 84 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 85 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 86 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 87 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 88 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 89 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 90 | # source code. | ||
| 91 | # | ||
| 92 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 93 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 94 | F_USB = $(F_CPU) | ||
| 95 | |||
| 96 | |||
| 97 | # Build Options | ||
| 98 | # comment out to disable the options. | ||
| 99 | # | ||
| 100 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 101 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 102 | CONSOLE_ENABLE = yes # Console for debug | ||
| 103 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | ||
| 104 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 105 | |||
| 106 | |||
| 107 | # Boot Section Size in bytes | ||
| 108 | # Teensy halfKay 512 | ||
| 109 | # Atmel DFU loader 4096 | ||
| 110 | # LUFA bootloader 4096 | ||
| 111 | OPT_DEFS += -DBOOT_SIZE=4096 | ||
| 112 | |||
| 113 | |||
| 114 | # Search Path | ||
| 115 | VPATH += $(TARGET_DIR) | ||
| 116 | VPATH += $(TOP_DIR) | ||
| 117 | |||
| 118 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 119 | include $(TOP_DIR)/common.mk | ||
| 120 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc new file mode 100644 index 000000000..dc5b2f743 --- /dev/null +++ b/keyboard/gh60/Makefile.pjrc | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = gh60_pjrc | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # keyboard dependent files | ||
| 51 | SRC = keymap.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | CONFIG_H = config.h | ||
| 56 | |||
| 57 | |||
| 58 | # MCU name, you MUST set this to match the board you are using | ||
| 59 | # type "make clean" after changing this, so all files will be rebuilt | ||
| 60 | #MCU = at90usb162 # Teensy 1.0 | ||
| 61 | MCU = atmega32u4 # Teensy 2.0 | ||
| 62 | #MCU = at90usb646 # Teensy++ 1.0 | ||
| 63 | #MCU = at90usb1286 # Teensy++ 2.0 | ||
| 64 | |||
| 65 | |||
| 66 | # Processor frequency. | ||
| 67 | # Normally the first thing your program should do is set the clock prescaler, | ||
| 68 | # so your program will run at the correct speed. You should also set this | ||
| 69 | # variable to same clock speed. The _delay_ms() macro uses this, and many | ||
| 70 | # examples use this variable to calculate timings. Do not add a "UL" here. | ||
| 71 | F_CPU = 16000000 | ||
| 72 | |||
| 73 | |||
| 74 | # Build Options | ||
| 75 | # comment out to disable the options. | ||
| 76 | # | ||
| 77 | #MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 78 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 79 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 80 | NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 81 | CONSOLE_ENABLE = yes # Console for debug | ||
| 82 | |||
| 83 | |||
| 84 | # Search Path | ||
| 85 | VPATH += $(TARGET_DIR) | ||
| 86 | VPATH += $(TOP_DIR) | ||
| 87 | |||
| 88 | include $(TOP_DIR)/protocol/pjrc.mk | ||
| 89 | include $(TOP_DIR)/common.mk | ||
| 90 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h new file mode 100644 index 000000000..6e7b1bd7a --- /dev/null +++ b/keyboard/gh60/config.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef CONFIG_H | ||
| 19 | #define CONFIG_H | ||
| 20 | |||
| 21 | |||
| 22 | /* USB Device descriptor parameter */ | ||
| 23 | #define VENDOR_ID 0xFEED | ||
| 24 | #define PRODUCT_ID 0x6060 | ||
| 25 | #define DEVICE_VER 0x0001 | ||
| 26 | #define MANUFACTURER geekhack | ||
| 27 | #define PRODUCT GH60 | ||
| 28 | |||
| 29 | |||
| 30 | /* message strings */ | ||
| 31 | #define DESCRIPTION t.m.k. keyboard firmware for GH60 | ||
| 32 | |||
| 33 | |||
| 34 | /* matrix size */ | ||
| 35 | #define MATRIX_ROWS 5 | ||
| 36 | #define MATRIX_COLS 14 | ||
| 37 | |||
| 38 | /* define if matrix has ghost */ | ||
| 39 | //#define MATRIX_HAS_GHOST | ||
| 40 | |||
| 41 | /* Set 0 if need no debouncing */ | ||
| 42 | #define DEBOUNCE 5 | ||
| 43 | |||
| 44 | |||
| 45 | /* key combination for command */ | ||
| 46 | #define IS_COMMAND() ( \ | ||
| 47 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 48 | ) | ||
| 49 | |||
| 50 | #endif | ||
diff --git a/keyboard/gh60/keymap.c b/keyboard/gh60/keymap.c new file mode 100644 index 000000000..7ccae1a81 --- /dev/null +++ b/keyboard/gh60/keymap.c | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include <stdint.h> | ||
| 18 | #include <stdbool.h> | ||
| 19 | #include <avr/pgmspace.h> | ||
| 20 | #include "keycode.h" | ||
| 21 | #include "print.h" | ||
| 22 | #include "debug.h" | ||
| 23 | #include "util.h" | ||
| 24 | #include "keymap.h" | ||
| 25 | |||
| 26 | |||
| 27 | #define KEYMAP( \ | ||
| 28 | K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ | ||
| 29 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ | ||
| 30 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \ | ||
| 31 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ | ||
| 32 | K40, K41, K42, K45, K4A, K4B, K4C, K4D \ | ||
| 33 | ) { \ | ||
| 34 | { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \ | ||
| 35 | { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \ | ||
| 36 | { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \ | ||
| 37 | { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \ | ||
| 38 | { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ | ||
| 39 | } | ||
| 40 | |||
| 41 | #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) | ||
| 42 | |||
| 43 | |||
| 44 | // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. | ||
| 45 | static const uint8_t PROGMEM fn_layer[] = { | ||
| 46 | 0, // Fn0 | ||
| 47 | 1, // Fn1 | ||
| 48 | 2, // Fn2 | ||
| 49 | 3, // Fn3 | ||
| 50 | 4, // Fn4 | ||
| 51 | 0, // Fn5 | ||
| 52 | 3, // Fn6 | ||
| 53 | 3 // Fn7 | ||
| 54 | }; | ||
| 55 | |||
| 56 | // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. | ||
| 57 | // See layer.c for details. | ||
| 58 | static const uint8_t PROGMEM fn_keycode[] = { | ||
| 59 | KC_NO, // Fn0 | ||
| 60 | KC_NO, // Fn1 | ||
| 61 | KC_SLSH, // Fn2 | ||
| 62 | KC_SCLN, // Fn3 | ||
| 63 | KC_SPC, // Fn4 | ||
| 64 | KC_NO, // Fn5 | ||
| 65 | KC_NO, // Fn6 | ||
| 66 | KC_NO // Fn7 | ||
| 67 | }; | ||
| 68 | |||
| 69 | static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 70 | /* Layer 0: Default Layer | ||
| 71 | * ,-----------------------------------------------------------. | ||
| 72 | * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | | ||
| 73 | * |-----------------------------------------------------------| | ||
| 74 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | ||
| 75 | * |-----------------------------------------------------------| | ||
| 76 | * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | | ||
| 77 | * |-----------------------------------------------------------| | ||
| 78 | * |Shift | Z| X| C| V| B| N| M| ,| .| /| Shift | | ||
| 79 | * |-----------------------------------------------------------| | ||
| 80 | * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| | ||
| 81 | * `-----------------------------------------------------------' | ||
| 82 | */ | ||
| 83 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ | ||
| 84 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ | ||
| 85 | CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \ | ||
| 86 | LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, \ | ||
| 87 | LCTL,LGUI,LALT, SPC, RALT,GRV, FN6, RCTL), | ||
| 88 | |||
| 89 | |||
| 90 | #if 0 | ||
| 91 | /* Layer 1: HHKB mode (HHKB Fn) | ||
| 92 | * ,-----------------------------------------------------------. | ||
| 93 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 94 | * |-----------------------------------------------------------| | ||
| 95 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | | ||
| 96 | * |-----------------------------------------------------' | | ||
| 97 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 98 | * |-----------------------------------------------------------| | ||
| 99 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift |xxx| | ||
| 100 | * |-----------------------------------------------------------| | ||
| 101 | * | |Gui |Alt | |Alt |Gui| | |Ctr| | ||
| 102 | * `-----------------------------------------------------------' | ||
| 103 | */ | ||
| 104 | KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ | ||
| 105 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, INS, NLCK,\ | ||
| 106 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ | ||
| 107 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN1, \ | ||
| 108 | NO, LGUI,LALT,SPC, RALT,NO, NO, NO, RCTL), | ||
| 109 | |||
| 110 | |||
| 111 | /* Layer 2: Vi mode (Quote/Rmeta) | ||
| 112 | * ,-----------------------------------------------------------. | ||
| 113 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | | ||
| 114 | * |-----------------------------------------------------------| | ||
| 115 | * | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | | ||
| 116 | * |-----------------------------------------------------' | | ||
| 117 | * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | \ | | ||
| 118 | * |-----------------------------------------------------------| | ||
| 119 | * |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | | | ||
| 120 | * |-----------------------------------------------------------| | ||
| 121 | * | |Gui |Alt |Space |Alt |Gui|Fn6|Fn6|Ctr| | ||
| 122 | * `-----------------------------------------------------------' | ||
| 123 | */ | ||
| 124 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ | ||
| 125 | BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \ | ||
| 126 | LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, BSLS, \ | ||
| 127 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,NO, \ | ||
| 128 | NO, LGUI,LALT,SPC, RALT,RGUI,FN6, FN6, RCTL), | ||
| 129 | |||
| 130 | |||
| 131 | /* Layer 3: Mouse mode (Semicolon) | ||
| 132 | * ,-----------------------------------------------------------. | ||
| 133 | * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | | ||
| 134 | * |-----------------------------------------------------------| | ||
| 135 | * | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | | ||
| 136 | * |-----------------------------------------------------' | | ||
| 137 | * |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | \ | | ||
| 138 | * |-----------------------------------------------------------| | ||
| 139 | * |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | | | ||
| 140 | * |-----------------------------------------------------------| | ||
| 141 | * |xxx|Gui |Alt |Mb1 |Alt | | | | | | ||
| 142 | * `-----------------------------------------------------------' | ||
| 143 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 144 | */ | ||
| 145 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ | ||
| 146 | BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \ | ||
| 147 | LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, BSLS, \ | ||
| 148 | LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT,NO, \ | ||
| 149 | FN7, LGUI,LALT,BTN1,RALT,NO, FN6, FN6, NO), | ||
| 150 | |||
| 151 | |||
| 152 | /* Layer 4: Matias half keyboard style (Space) | ||
| 153 | * ,-----------------------------------------------------------. | ||
| 154 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | ||
| 155 | * |-----------------------------------------------------------| | ||
| 156 | * |Backs| P| O| I| U| Y| T| R| E| W| Q|Tab|Tab| | | ||
| 157 | * |-----------------------------------------------------' | | ||
| 158 | * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control | | ||
| 159 | * |-----------------------------------------------------------| | ||
| 160 | * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | | | ||
| 161 | * |-----------------------------------------------------------| | ||
| 162 | * | |Gui |Alt |xxxxxxxxxxxxxxxxxxxxxx|Alt |Gui| | |Ctr| | ||
| 163 | * `-----------------------------------------------------------' | ||
| 164 | */ | ||
| 165 | KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, ESC, \ | ||
| 166 | BSPC,P, O, I, U, Y, T, R, E, W, Q, TAB, TAB, TAB, \ | ||
| 167 | LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \ | ||
| 168 | LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \ | ||
| 169 | NO, LGUI,LALT,FN4, RALT,RGUI,NO, NO, RCTL), | ||
| 170 | #endif | ||
| 171 | }; | ||
| 172 | |||
| 173 | |||
| 174 | uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) | ||
| 175 | { | ||
| 176 | return KEYCODE(layer, row, col); | ||
| 177 | } | ||
| 178 | |||
| 179 | uint8_t keymap_fn_layer(uint8_t index) | ||
| 180 | { | ||
| 181 | return pgm_read_byte(&fn_layer[index]); | ||
| 182 | } | ||
| 183 | |||
| 184 | uint8_t keymap_fn_keycode(uint8_t index) | ||
| 185 | { | ||
| 186 | return pgm_read_byte(&fn_keycode[index]); | ||
| 187 | } | ||
diff --git a/keyboard/gh60/led.c b/keyboard/gh60/led.c new file mode 100644 index 000000000..62abcd79d --- /dev/null +++ b/keyboard/gh60/led.c | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | void led_set(uint8_t usb_led) | ||
| 24 | { | ||
| 25 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 26 | // output low | ||
| 27 | DDRB |= (1<<2); | ||
| 28 | PORTB &= ~(1<<2); | ||
| 29 | } else { | ||
| 30 | // Hi-Z | ||
| 31 | DDRB &= ~(1<<2); | ||
| 32 | PORTB &= ~(1<<2); | ||
| 33 | } | ||
| 34 | } | ||
diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c new file mode 100644 index 000000000..4c18a6191 --- /dev/null +++ b/keyboard/gh60/matrix.c | |||
| @@ -0,0 +1,225 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* | ||
| 19 | * scan matrix | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/io.h> | ||
| 24 | #include <util/delay.h> | ||
| 25 | #include "print.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "util.h" | ||
| 28 | #include "matrix.h" | ||
| 29 | |||
| 30 | |||
| 31 | #ifndef DEBOUNCE | ||
| 32 | # define DEBOUNCE 5 | ||
| 33 | #endif | ||
| 34 | static uint8_t debouncing = DEBOUNCE; | ||
| 35 | |||
| 36 | // matrix state buffer(1:on, 0:off) | ||
| 37 | static uint16_t *matrix; | ||
| 38 | static uint16_t *matrix_prev; | ||
| 39 | static uint16_t _matrix0[MATRIX_ROWS]; | ||
| 40 | static uint16_t _matrix1[MATRIX_ROWS]; | ||
| 41 | |||
| 42 | static uint16_t read_cols(void); | ||
| 43 | static void init_cols(void); | ||
| 44 | static void unselect_rows(void); | ||
| 45 | static void select_row(uint8_t row); | ||
| 46 | |||
| 47 | |||
| 48 | inline | ||
| 49 | uint8_t matrix_rows(void) | ||
| 50 | { | ||
| 51 | return MATRIX_ROWS; | ||
| 52 | } | ||
| 53 | |||
| 54 | inline | ||
| 55 | uint8_t matrix_cols(void) | ||
| 56 | { | ||
| 57 | return MATRIX_COLS; | ||
| 58 | } | ||
| 59 | |||
| 60 | void matrix_init(void) | ||
| 61 | { | ||
| 62 | // initialize row and col | ||
| 63 | unselect_rows(); | ||
| 64 | init_cols(); | ||
| 65 | |||
| 66 | // initialize matrix state: all keys off | ||
| 67 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0; | ||
| 68 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0; | ||
| 69 | matrix = _matrix0; | ||
| 70 | matrix_prev = _matrix1; | ||
| 71 | } | ||
| 72 | |||
| 73 | uint8_t matrix_scan(void) | ||
| 74 | { | ||
| 75 | if (!debouncing) { | ||
| 76 | uint16_t *tmp = matrix_prev; | ||
| 77 | matrix_prev = matrix; | ||
| 78 | matrix = tmp; | ||
| 79 | } | ||
| 80 | |||
| 81 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 82 | unselect_rows(); | ||
| 83 | select_row(i); | ||
| 84 | _delay_us(1); // without this wait read unstable value. | ||
| 85 | uint16_t cols = ~read_cols(); | ||
| 86 | if (matrix[i] != cols) { | ||
| 87 | matrix[i] = cols; | ||
| 88 | if (debouncing) { | ||
| 89 | debug("bounce!: "); debug_hex(debouncing); print("\n"); | ||
| 90 | } | ||
| 91 | debouncing = DEBOUNCE; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | unselect_rows(); | ||
| 95 | |||
| 96 | if (debouncing) { | ||
| 97 | debouncing--; | ||
| 98 | _delay_ms(1); // improved affect on bouncing | ||
| 99 | } | ||
| 100 | |||
| 101 | return 1; | ||
| 102 | } | ||
| 103 | |||
| 104 | bool matrix_is_modified(void) | ||
| 105 | { | ||
| 106 | if (debouncing) return false; | ||
| 107 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 108 | if (matrix[i] != matrix_prev[i]) { | ||
| 109 | return true; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | return false; | ||
| 113 | } | ||
| 114 | |||
| 115 | inline | ||
| 116 | bool matrix_has_ghost(void) | ||
| 117 | { | ||
| 118 | return false; | ||
| 119 | } | ||
| 120 | |||
| 121 | inline | ||
| 122 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 123 | { | ||
| 124 | return (matrix[row] & (1<<col)); | ||
| 125 | } | ||
| 126 | |||
| 127 | inline | ||
| 128 | uint16_t matrix_get_row(uint8_t row) | ||
| 129 | { | ||
| 130 | return matrix[row]; | ||
| 131 | } | ||
| 132 | |||
| 133 | void matrix_print(void) | ||
| 134 | { | ||
| 135 | print("\nr/c 01234567\n"); | ||
| 136 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 137 | phex(row); print(": "); | ||
| 138 | pbin_reverse16(matrix_get_row(row)); | ||
| 139 | print("\n"); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | uint8_t matrix_key_count(void) | ||
| 144 | { | ||
| 145 | uint8_t count = 0; | ||
| 146 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 147 | count += bitpop16(matrix[i]); | ||
| 148 | } | ||
| 149 | return count; | ||
| 150 | } | ||
| 151 | |||
| 152 | /* Column pin configuration | ||
| 153 | * col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | ||
| 154 | * pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 | ||
| 155 | */ | ||
| 156 | static void init_cols(void) | ||
| 157 | { | ||
| 158 | // Input with pull-up(DDR:0, PORT:1) | ||
| 159 | DDRF &= ~(1<<0 | 1<<1); | ||
| 160 | PORTF |= (1<<0 | 1<<1); | ||
| 161 | DDRE &= ~(1<<6); | ||
| 162 | PORTE |= (1<<6); | ||
| 163 | DDRD &= ~(1<<7 | 1<<6 | 1<<4); | ||
| 164 | PORTD |= (1<<7 | 1<<6 | 1<<4); | ||
| 165 | DDRC &= ~(1<<7 | 1<<6); | ||
| 166 | PORTC |= (1<<7 | 1<<6); | ||
| 167 | DDRB &= ~(1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0); | ||
| 168 | PORTB |= (1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0); | ||
| 169 | } | ||
| 170 | |||
| 171 | static uint16_t read_cols(void) | ||
| 172 | { | ||
| 173 | return (PINF&(1<<0) ? (1<<0) : 0) | | ||
| 174 | (PINF&(1<<1) ? (1<<1) : 0) | | ||
| 175 | (PINE&(1<<6) ? (1<<2) : 0) | | ||
| 176 | (PINC&(1<<7) ? (1<<3) : 0) | | ||
| 177 | (PINC&(1<<6) ? (1<<4) : 0) | | ||
| 178 | (PINB&(1<<6) ? (1<<5) : 0) | | ||
| 179 | (PIND&(1<<4) ? (1<<6) : 0) | | ||
| 180 | (PINB&(1<<1) ? (1<<7) : 0) | | ||
| 181 | (PINB&(1<<0) ? (1<<8) : 0) | | ||
| 182 | (PINB&(1<<5) ? (1<<9) : 0) | | ||
| 183 | (PINB&(1<<4) ? (1<<10) : 0) | | ||
| 184 | (PIND&(1<<7) ? (1<<11) : 0) | | ||
| 185 | (PIND&(1<<6) ? (1<<12) : 0) | | ||
| 186 | (PINB&(1<<3) ? (1<<13) : 0); | ||
| 187 | } | ||
| 188 | |||
| 189 | /* Row pin configuration | ||
| 190 | * row: 0 1 2 3 4 | ||
| 191 | * pin: D0 D1 D2 D3 D5 | ||
| 192 | */ | ||
| 193 | static void unselect_rows(void) | ||
| 194 | { | ||
| 195 | // Hi-Z(DDR:0, PORT:0) to unselect | ||
| 196 | DDRD &= ~0b00101111; | ||
| 197 | PORTD &= ~0b00101111; | ||
| 198 | } | ||
| 199 | |||
| 200 | static void select_row(uint8_t row) | ||
| 201 | { | ||
| 202 | // Output low(DDR:1, PORT:0) to select | ||
| 203 | switch (row) { | ||
| 204 | case 0: | ||
| 205 | DDRD |= (1<<0); | ||
| 206 | PORTD &= ~(1<<0); | ||
| 207 | break; | ||
| 208 | case 1: | ||
| 209 | DDRD |= (1<<1); | ||
| 210 | PORTD &= ~(1<<1); | ||
| 211 | break; | ||
| 212 | case 2: | ||
| 213 | DDRD |= (1<<2); | ||
| 214 | PORTD &= ~(1<<2); | ||
| 215 | break; | ||
| 216 | case 3: | ||
| 217 | DDRD |= (1<<3); | ||
| 218 | PORTD &= ~(1<<3); | ||
| 219 | break; | ||
| 220 | case 4: | ||
| 221 | DDRD |= (1<<5); | ||
| 222 | PORTD &= ~(1<<5); | ||
| 223 | break; | ||
| 224 | } | ||
| 225 | } | ||
