diff options
| author | tmk <tmk@users.noreply.github.com> | 2014-07-07 11:13:31 +0900 |
|---|---|---|
| committer | tmk <tmk@users.noreply.github.com> | 2014-07-07 11:13:31 +0900 |
| commit | 7079ba5d519d909d7543a9fd3b2b270c95c003a4 (patch) | |
| tree | 57161f2f74b9f736eaf1db98d4b146159fa69b8e | |
| parent | 9c8d0f6c0d8b145c627d073faff9c8ca6f9148fe (diff) | |
| parent | a70acecb1c1777acd719747e1b6b0829c245149c (diff) | |
| download | qmk_firmware-7079ba5d519d909d7543a9fd3b2b270c95c003a4.tar.gz qmk_firmware-7079ba5d519d909d7543a9fd3b2b270c95c003a4.zip | |
Merge pull request #126 from xauser/master
Added support for bpiphany's Kitten Paw controller
| -rw-r--r-- | keyboard/kitten_paw/Makefile.lufa | 117 | ||||
| -rw-r--r-- | keyboard/kitten_paw/README.md | 20 | ||||
| -rw-r--r-- | keyboard/kitten_paw/config.h | 43 | ||||
| -rw-r--r-- | keyboard/kitten_paw/keymap.c | 102 | ||||
| -rw-r--r-- | keyboard/kitten_paw/keymap_ansi.h | 23 | ||||
| -rw-r--r-- | keyboard/kitten_paw/led.c | 60 | ||||
| -rw-r--r-- | keyboard/kitten_paw/matrix.c | 239 |
7 files changed, 604 insertions, 0 deletions
diff --git a/keyboard/kitten_paw/Makefile.lufa b/keyboard/kitten_paw/Makefile.lufa new file mode 100644 index 000000000..4a643ea79 --- /dev/null +++ b/keyboard/kitten_paw/Makefile.lufa | |||
| @@ -0,0 +1,117 @@ | |||
| 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 = kittenpaw_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | # List C source files here. (C dependencies are automatically generated.) | ||
| 51 | SRC = keymap.c \ | ||
| 52 | matrix.c \ | ||
| 53 | led.c | ||
| 54 | |||
| 55 | CONFIG_H = config.h | ||
| 56 | |||
| 57 | # MCU name | ||
| 58 | MCU = atmega32u2 | ||
| 59 | |||
| 60 | # Processor frequency. | ||
| 61 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 62 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 63 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 64 | # automatically to create a 32-bit value in your source code. | ||
| 65 | # | ||
| 66 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 67 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 68 | # does not *change* the processor frequency - it should merely be updated to | ||
| 69 | # reflect the processor speed set externally so that the code can use accurate | ||
| 70 | # software delays. | ||
| 71 | F_CPU = 16000000 | ||
| 72 | |||
| 73 | # | ||
| 74 | # LUFA specific | ||
| 75 | # | ||
| 76 | # Target architecture (see library "Board Types" documentation). | ||
| 77 | ARCH = AVR8 | ||
| 78 | |||
| 79 | # Input clock frequency. | ||
| 80 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 81 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 82 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 83 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 84 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 85 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 86 | # source code. | ||
| 87 | # | ||
| 88 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 89 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 90 | F_USB = $(F_CPU) | ||
| 91 | |||
| 92 | |||
| 93 | # Build Options | ||
| 94 | # comment out to disable the options. | ||
| 95 | # | ||
| 96 | #BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | ||
| 97 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | ||
| 98 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
| 99 | #CONSOLE_ENABLE = yes # Console for debug(+400) | ||
| 100 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 101 | #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | ||
| 102 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | ||
| 103 | |||
| 104 | |||
| 105 | # Boot Section Size in bytes | ||
| 106 | # Teensy halfKay 512 | ||
| 107 | # Atmel DFU loader 4096 | ||
| 108 | # LUFA bootloader 4096 | ||
| 109 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 110 | |||
| 111 | # Search Path | ||
| 112 | VPATH += $(TARGET_DIR) | ||
| 113 | VPATH += $(TOP_DIR) | ||
| 114 | |||
| 115 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 116 | include $(TOP_DIR)/common.mk | ||
| 117 | include $(TOP_DIR)/rules.mk | ||
diff --git a/keyboard/kitten_paw/README.md b/keyboard/kitten_paw/README.md new file mode 100644 index 000000000..1cc8c1016 --- /dev/null +++ b/keyboard/kitten_paw/README.md | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | Kitten Paw controller firmware | ||
| 2 | ====================== | ||
| 3 | Custom controller for the Costar Majestouch keyboard designed by bpiphany. | ||
| 4 | |||
| 5 | *Note that this is not the official firmware* | ||
| 6 | |||
| 7 | Build | ||
| 8 | ----- | ||
| 9 | Move to this directory then just run `make` like: | ||
| 10 | |||
| 11 | $ make -f Makefile.lufa | ||
| 12 | |||
| 13 | At the moment only the LUFA stack is supported. | ||
| 14 | |||
| 15 | |||
| 16 | Bootloader | ||
| 17 | --------- | ||
| 18 | To enter bootloader by hardware use a magnet above the controller before connecting the usb cable. | ||
| 19 | |||
| 20 | It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though. | ||
diff --git a/keyboard/kitten_paw/config.h b/keyboard/kitten_paw/config.h new file mode 100644 index 000000000..a29ca313e --- /dev/null +++ b/keyboard/kitten_paw/config.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> | ||
| 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 | /* USB Device descriptor parameter */ | ||
| 22 | #define VENDOR_ID 0xFEED | ||
| 23 | #define PRODUCT_ID 0x6050 | ||
| 24 | #define DEVICE_VER 0x0104 | ||
| 25 | #define MANUFACTURER Costar | ||
| 26 | #define PRODUCT Majestouch | ||
| 27 | |||
| 28 | /* message strings */ | ||
| 29 | #define DESCRIPTION t.m.k. keyboard firmware for Majestouch | ||
| 30 | |||
| 31 | /* matrix size */ | ||
| 32 | #define MATRIX_ROWS 8 | ||
| 33 | #define MATRIX_COLS 18 | ||
| 34 | |||
| 35 | /* Set 0 if need no debouncing */ | ||
| 36 | #define DEBOUNCE 5 | ||
| 37 | |||
| 38 | /* key combination for command */ | ||
| 39 | #define IS_COMMAND() ( \ | ||
| 40 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
| 41 | ) | ||
| 42 | |||
| 43 | #endif | ||
diff --git a/keyboard/kitten_paw/keymap.c b/keyboard/kitten_paw/keymap.c new file mode 100644 index 000000000..23db421f9 --- /dev/null +++ b/keyboard/kitten_paw/keymap.c | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> | ||
| 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 <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #include <avr/pgmspace.h> | ||
| 21 | #include "keycode.h" | ||
| 22 | #include "action.h" | ||
| 23 | #include "action_macro.h" | ||
| 24 | #include "report.h" | ||
| 25 | #include "host.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "keymap.h" | ||
| 28 | |||
| 29 | /* | ||
| 30 | Matrix col/row mapping | ||
| 31 | |||
| 32 | ,----. ,-------------------. ,-------------------. ,-------------------. ,--------------. | ||
| 33 | |06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7| | ||
| 34 | `----' `-------------------' `-------------------' `-------------------' `--------------' | ||
| 35 | ,-------------------------------------------------------------------------. ,--------------. ,-------------------. | ||
| 36 | |06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0| | ||
| 37 | |-------------------------------------------------------------------------| |--------------| |-------------------| | ||
| 38 | |06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| | | ||
| 39 | |-------------------------------------------------------------------------| '--------------' |-------------- 02/7| | ||
| 40 | |02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| | | ||
| 41 | |-------------------------------------------------------------------------| ,----. |-------------------| | ||
| 42 | |01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| | | ||
| 43 | |-------------------------------------------------------------------------| ,--------------. |-------------- 02/3| | ||
| 44 | |15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| | | ||
| 45 | `-------------------------------------------------------------------------' `--------------' `-------------------' | ||
| 46 | */ | ||
| 47 | |||
| 48 | #define KEYMAP( \ | ||
| 49 | KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \ | ||
| 50 | KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \ | ||
| 51 | KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \ | ||
| 52 | KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \ | ||
| 53 | KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \ | ||
| 54 | KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \ | ||
| 55 | ) { \ | ||
| 56 | /* 0 1 2 3 4 5 6 7 */ \ | ||
| 57 | /* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\ | ||
| 58 | /* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\ | ||
| 59 | /* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\ | ||
| 60 | /* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\ | ||
| 61 | /* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\ | ||
| 62 | /* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\ | ||
| 63 | /* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\ | ||
| 64 | /* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\ | ||
| 65 | /* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\ | ||
| 66 | /* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\ | ||
| 67 | /* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\ | ||
| 68 | /* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\ | ||
| 69 | /* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\ | ||
| 70 | /* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\ | ||
| 71 | /* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\ | ||
| 72 | /* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\ | ||
| 73 | /* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\ | ||
| 74 | /* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \ | ||
| 75 | } | ||
| 76 | |||
| 77 | #include "keymap_ansi.h" | ||
| 78 | |||
| 79 | #define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) | ||
| 80 | #define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) | ||
| 81 | |||
| 82 | /* translates key to keycode */ | ||
| 83 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 84 | { | ||
| 85 | if (layer < KEYMAPS_SIZE) { | ||
| 86 | return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]); | ||
| 87 | } else { | ||
| 88 | return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | /* translates Fn keycode to action */ | ||
| 93 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 94 | { | ||
| 95 | action_t action; | ||
| 96 | if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { | ||
| 97 | action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); | ||
| 98 | } else { | ||
| 99 | action.code = ACTION_NO; | ||
| 100 | } | ||
| 101 | return action; | ||
| 102 | } | ||
diff --git a/keyboard/kitten_paw/keymap_ansi.h b/keyboard/kitten_paw/keymap_ansi.h new file mode 100644 index 000000000..ed1088baa --- /dev/null +++ b/keyboard/kitten_paw/keymap_ansi.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | |||
| 2 | static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = { | ||
| 3 | /* Layer 0: Standard ANSI layer */ | ||
| 4 | KEYMAP(\ | ||
| 5 | ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \ | ||
| 6 | GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ | ||
| 7 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \ | ||
| 8 | CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \ | ||
| 9 | LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \ | ||
| 10 | LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \ | ||
| 11 | /* Layer 1: Function layer */ | ||
| 12 | KEYMAP(\ | ||
| 13 | CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \ | ||
| 14 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ | ||
| 15 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ | ||
| 16 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \ | ||
| 17 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \ | ||
| 18 | TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS) | ||
| 19 | }; | ||
| 20 | |||
| 21 | static const uint16_t PROGMEM fn_actions[] = { | ||
| 22 | [0] = ACTION_LAYER_MOMENTARY(1) | ||
| 23 | }; | ||
diff --git a/keyboard/kitten_paw/led.c b/keyboard/kitten_paw/led.c new file mode 100644 index 000000000..da5dbd7ae --- /dev/null +++ b/keyboard/kitten_paw/led.c | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> | ||
| 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 | /* LED pin configuration | ||
| 23 | * | ||
| 24 | * Scroll Lock PB7 | ||
| 25 | * CAPS PC6 | ||
| 26 | * NUMLOCK PC5 | ||
| 27 | * | ||
| 28 | */ | ||
| 29 | void led_set(uint8_t usb_led) | ||
| 30 | { | ||
| 31 | DDRB |= (1<<7); | ||
| 32 | DDRC |= (1<<5) | (1<<6); | ||
| 33 | |||
| 34 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) | ||
| 35 | { | ||
| 36 | PORTC &= ~(1<<6); | ||
| 37 | } | ||
| 38 | else | ||
| 39 | { | ||
| 40 | PORTC |= (1<<6); | ||
| 41 | } | ||
| 42 | |||
| 43 | if (usb_led & (1<<USB_LED_NUM_LOCK)) | ||
| 44 | { | ||
| 45 | PORTC &= ~(1<<5); | ||
| 46 | } | ||
| 47 | else | ||
| 48 | { | ||
| 49 | PORTC |= (1<<5); | ||
| 50 | } | ||
| 51 | |||
| 52 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) | ||
| 53 | { | ||
| 54 | PORTB &= ~(1<<7); | ||
| 55 | } | ||
| 56 | else | ||
| 57 | { | ||
| 58 | PORTB |= (1<<7); | ||
| 59 | } | ||
| 60 | } | ||
diff --git a/keyboard/kitten_paw/matrix.c b/keyboard/kitten_paw/matrix.c new file mode 100644 index 000000000..08d64c5f4 --- /dev/null +++ b/keyboard/kitten_paw/matrix.c | |||
| @@ -0,0 +1,239 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> | ||
| 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 <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #include <avr/io.h> | ||
| 21 | #include <util/delay.h> | ||
| 22 | #include "print.h" | ||
| 23 | #include "debug.h" | ||
| 24 | #include "util.h" | ||
| 25 | #include "matrix.h" | ||
| 26 | |||
| 27 | #ifndef DEBOUNCE | ||
| 28 | # define DEBOUNCE 0 | ||
| 29 | #endif | ||
| 30 | static uint8_t debouncing = DEBOUNCE; | ||
| 31 | |||
| 32 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 33 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 34 | |||
| 35 | static uint8_t read_rows(void); | ||
| 36 | static void init_rows(void); | ||
| 37 | static void unselect_cols(void); | ||
| 38 | static void select_col(uint8_t col); | ||
| 39 | |||
| 40 | inline uint8_t matrix_rows(void) | ||
| 41 | { | ||
| 42 | return MATRIX_ROWS; | ||
| 43 | } | ||
| 44 | |||
| 45 | inline uint8_t matrix_cols(void) | ||
| 46 | { | ||
| 47 | return MATRIX_COLS; | ||
| 48 | } | ||
| 49 | |||
| 50 | void matrix_init(void) | ||
| 51 | { | ||
| 52 | unselect_cols(); | ||
| 53 | init_rows(); | ||
| 54 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 55 | matrix[i] = 0; | ||
| 56 | matrix_debouncing[i] = 0; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | uint8_t matrix_scan(void) | ||
| 61 | { | ||
| 62 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 63 | select_col(col); | ||
| 64 | _delay_us(3); | ||
| 65 | uint8_t rows = read_rows(); | ||
| 66 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 67 | bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col); | ||
| 68 | bool curr_bit = rows & (1<<row); | ||
| 69 | if (prev_bit != curr_bit) { | ||
| 70 | matrix_debouncing[row] ^= ((matrix_row_t)1<<col); | ||
| 71 | debouncing = DEBOUNCE; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | unselect_cols(); | ||
| 75 | } | ||
| 76 | |||
| 77 | if (debouncing) { | ||
| 78 | if (--debouncing) { | ||
| 79 | _delay_ms(1); | ||
| 80 | } else { | ||
| 81 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 82 | matrix[i] = matrix_debouncing[i]; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | return 1; | ||
| 88 | } | ||
| 89 | |||
| 90 | bool matrix_is_modified(void) | ||
| 91 | { | ||
| 92 | if (debouncing) return false; | ||
| 93 | return true; | ||
| 94 | } | ||
| 95 | |||
| 96 | inline bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 97 | { | ||
| 98 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
| 99 | } | ||
| 100 | |||
| 101 | inline matrix_row_t matrix_get_row(uint8_t row) | ||
| 102 | { | ||
| 103 | return matrix[row]; | ||
| 104 | } | ||
| 105 | |||
| 106 | void matrix_print(void) | ||
| 107 | { | ||
| 108 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 109 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 110 | xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row))); | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | uint8_t matrix_key_count(void) | ||
| 115 | { | ||
| 116 | uint8_t count = 0; | ||
| 117 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 118 | count += bitpop32(matrix[i]); | ||
| 119 | } | ||
| 120 | return count; | ||
| 121 | } | ||
| 122 | |||
| 123 | /* Row pin configuration | ||
| 124 | * | ||
| 125 | * row: 0 1 2 3 4 5 6 7 | ||
| 126 | * pin: PC2 PB1 PB2 PB3 PC7 PB4 PB5 PB6 | ||
| 127 | * | ||
| 128 | */ | ||
| 129 | static void init_rows(void) | ||
| 130 | { | ||
| 131 | DDRC &= ~0b10000100; | ||
| 132 | DDRB &= ~0b01111110; | ||
| 133 | PORTC |= 0b10000100; | ||
| 134 | PORTB |= 0b01111110; | ||
| 135 | } | ||
| 136 | |||
| 137 | static uint8_t read_rows(void) | ||
| 138 | { | ||
| 139 | return (PINC&(1<<2) ? 0 : (1<<0)) | | ||
| 140 | (PINB&(1<<1) ? 0 : (1<<1)) | | ||
| 141 | (PINB&(1<<2) ? 0 : (1<<2)) | | ||
| 142 | (PINB&(1<<3) ? 0 : (1<<3)) | | ||
| 143 | (PINC&(1<<7) ? 0 : (1<<4)) | | ||
| 144 | (PINB&(1<<4) ? 0 : (1<<5)) | | ||
| 145 | (PINB&(1<<5) ? 0 : (1<<6)) | | ||
| 146 | (PINB&(1<<6) ? 0 : (1<<7)); | ||
| 147 | } | ||
| 148 | |||
| 149 | /* These columns uses two 74HC42 4 to 10 bit demultiplexers (low active). | ||
| 150 | * | ||
| 151 | * COL PD1 PD0 PD2 PD6 PD5 PD4 | ||
| 152 | * 12 1 1 0 0 0 0 | ||
| 153 | * 11 1 1 0 0 0 1 | ||
| 154 | * 10 1 1 0 0 1 0 | ||
| 155 | * 9 1 1 0 0 1 1 | ||
| 156 | * 8 1 1 0 1 0 0 | ||
| 157 | * 7 1 1 0 1 0 1 | ||
| 158 | * 6 1 1 0 1 1 0 | ||
| 159 | * 5 1 1 0 1 1 1 | ||
| 160 | * 4 1 1 1 0 0 0 | ||
| 161 | * 3 1 1 1 0 0 1 | ||
| 162 | |||
| 163 | * COL PD2 PD6 PD1 PD0 PD5 PD4 | ||
| 164 | * 2 1 1 0 0 0 0 | ||
| 165 | * 1 1 1 0 0 0 1 | ||
| 166 | * 0 1 1 0 0 1 0 | ||
| 167 | * 17 1 1 0 0 1 1 | ||
| 168 | * 16 1 1 0 1 0 0 | ||
| 169 | * 1 1 0 1 0 1 | ||
| 170 | * 1 1 0 1 1 0 | ||
| 171 | * 15 1 1 0 1 1 1 | ||
| 172 | * 14 1 1 1 0 0 0 | ||
| 173 | * 13 1 1 1 0 0 1 | ||
| 174 | */ | ||
| 175 | static void unselect_cols(void) | ||
| 176 | { | ||
| 177 | DDRD |= 0b01110111; | ||
| 178 | PORTD &= ~0b01110111; | ||
| 179 | } | ||
| 180 | |||
| 181 | static void select_col(uint8_t col) | ||
| 182 | { | ||
| 183 | switch (col) { | ||
| 184 | case 0: | ||
| 185 | PORTD |= (1<<5) | (1<<6) | (1<<2); | ||
| 186 | break; | ||
| 187 | case 1: | ||
| 188 | PORTD |= (1<<4) | (1<<6) | (1<<2); | ||
| 189 | break; | ||
| 190 | case 2: | ||
| 191 | PORTD |= (1<<6) | (1<<2); | ||
| 192 | break; | ||
| 193 | case 3: | ||
| 194 | PORTD |= (1<<4) | (1<<2) | (1<<0) | (1<<1); | ||
| 195 | break; | ||
| 196 | case 4: | ||
| 197 | PORTD |= (1<<2) | (1<<0) | (1<<1); | ||
| 198 | break; | ||
| 199 | case 5: | ||
| 200 | PORTD |= (1<<4) | (1<<5) | (1<<6) | (1<<0) | (1<<1); | ||
| 201 | break; | ||
| 202 | case 6: | ||
| 203 | PORTD |= (1<<5) | (1<<6) | (1<<0) | (1<<1); | ||
| 204 | break; | ||
| 205 | case 7: | ||
| 206 | PORTD |= (1<<4) | (1<<6) | (1<<0) | (1<<1); | ||
| 207 | break; | ||
| 208 | case 8: | ||
| 209 | PORTD |= (1<<6) | (1<<0) | (1<<1); | ||
| 210 | break; | ||
| 211 | case 9: | ||
| 212 | PORTD |= (1<<4) | (1<<5) | (1<<0) | (1<<1); | ||
| 213 | break; | ||
| 214 | case 10: | ||
| 215 | PORTD |= (1<<5) | (1<<0) | (1<<1); | ||
| 216 | break; | ||
| 217 | case 11: | ||
| 218 | PORTD |= (1<<4) | (1<<0) | (1<<1); | ||
| 219 | break; | ||
| 220 | case 12: | ||
| 221 | PORTD |= (1<<0) | (1<<1); | ||
| 222 | break; | ||
| 223 | case 13: | ||
| 224 | PORTD |= (1<<4) | (1<<1) | (1<<6) | (1<<2); | ||
| 225 | break; | ||
| 226 | case 14: | ||
| 227 | PORTD |= (1<<1) | (1<<6) | (1<<2); | ||
| 228 | break; | ||
| 229 | case 15: | ||
| 230 | PORTD |= (1<<4) | (1<<5) | (1<<0) | (1<<6) | (1<<2); | ||
| 231 | break; | ||
| 232 | case 16: | ||
| 233 | PORTD |= (1<<0) | (1<<6) | (1<<2); | ||
| 234 | break; | ||
| 235 | case 17: | ||
| 236 | PORTD |= (1<<4) | (1<<5) | (1<<6) | (1<<2); | ||
| 237 | break; | ||
| 238 | } | ||
| 239 | } | ||
