diff options
Diffstat (limited to 'keyboard/planck')
| -rwxr-xr-x | keyboard/planck/Config/LUFAConfig.h | 93 | ||||
| -rw-r--r-- | keyboard/planck/Makefile | 6 | ||||
| -rw-r--r-- | keyboard/planck/config.h | 7 | ||||
| -rw-r--r-- | keyboard/planck/config_definitions.h | 50 | ||||
| -rw-r--r-- | keyboard/planck/extended_keymap_common.h | 1 | ||||
| -rw-r--r-- | keyboard/planck/extended_keymaps/extended_keymap_default.c | 4 | ||||
| -rw-r--r-- | keyboard/planck/matrix.c | 235 | ||||
| -rw-r--r-- | keyboard/planck/matrix_pcb.c | 1 |
8 files changed, 392 insertions, 5 deletions
diff --git a/keyboard/planck/Config/LUFAConfig.h b/keyboard/planck/Config/LUFAConfig.h new file mode 100755 index 000000000..fa9404498 --- /dev/null +++ b/keyboard/planck/Config/LUFAConfig.h | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2012. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaim all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * \brief LUFA Library Configuration Header File | ||
| 33 | * | ||
| 34 | * This header file is used to configure LUFA's compile time options, | ||
| 35 | * as an alternative to the compile time constants supplied through | ||
| 36 | * a makefile. | ||
| 37 | * | ||
| 38 | * For information on what each token does, refer to the LUFA | ||
| 39 | * manual section "Summary of Compile Tokens". | ||
| 40 | */ | ||
| 41 | |||
| 42 | #ifndef _LUFA_CONFIG_H_ | ||
| 43 | #define _LUFA_CONFIG_H_ | ||
| 44 | |||
| 45 | #if (ARCH == ARCH_AVR8) | ||
| 46 | |||
| 47 | /* Non-USB Related Configuration Tokens: */ | ||
| 48 | // #define DISABLE_TERMINAL_CODES | ||
| 49 | |||
| 50 | /* USB Class Driver Related Tokens: */ | ||
| 51 | // #define HID_HOST_BOOT_PROTOCOL_ONLY | ||
| 52 | // #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} | ||
| 53 | // #define HID_USAGE_STACK_DEPTH {Insert Value Here} | ||
| 54 | // #define HID_MAX_COLLECTIONS {Insert Value Here} | ||
| 55 | // #define HID_MAX_REPORTITEMS {Insert Value Here} | ||
| 56 | // #define HID_MAX_REPORT_IDS {Insert Value Here} | ||
| 57 | // #define NO_CLASS_DRIVER_AUTOFLUSH | ||
| 58 | |||
| 59 | /* General USB Driver Related Tokens: */ | ||
| 60 | // #define ORDERED_EP_CONFIG | ||
| 61 | #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) | ||
| 62 | #define USB_DEVICE_ONLY | ||
| 63 | // #define USB_HOST_ONLY | ||
| 64 | // #define USB_STREAM_TIMEOUT_MS {Insert Value Here} | ||
| 65 | // #define NO_LIMITED_CONTROLLER_CONNECT | ||
| 66 | // #define NO_SOF_EVENTS | ||
| 67 | |||
| 68 | /* USB Device Mode Driver Related Tokens: */ | ||
| 69 | // #define USE_RAM_DESCRIPTORS | ||
| 70 | #define USE_FLASH_DESCRIPTORS | ||
| 71 | // #define USE_EEPROM_DESCRIPTORS | ||
| 72 | // #define NO_INTERNAL_SERIAL | ||
| 73 | #define FIXED_CONTROL_ENDPOINT_SIZE 8 | ||
| 74 | // #define DEVICE_STATE_AS_GPIOR {Insert Value Here} | ||
| 75 | #define FIXED_NUM_CONFIGURATIONS 1 | ||
| 76 | // #define CONTROL_ONLY_DEVICE | ||
| 77 | // #define INTERRUPT_CONTROL_ENDPOINT | ||
| 78 | // #define NO_DEVICE_REMOTE_WAKEUP | ||
| 79 | // #define NO_DEVICE_SELF_POWER | ||
| 80 | |||
| 81 | /* USB Host Mode Driver Related Tokens: */ | ||
| 82 | // #define HOST_STATE_AS_GPIOR {Insert Value Here} | ||
| 83 | // #define USB_HOST_TIMEOUT_MS {Insert Value Here} | ||
| 84 | // #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} | ||
| 85 | // #define NO_AUTO_VBUS_MANAGEMENT | ||
| 86 | // #define INVERTED_VBUS_ENABLE_LINE | ||
| 87 | |||
| 88 | #else | ||
| 89 | |||
| 90 | #error Unsupported architecture for this LUFA configuration file. | ||
| 91 | |||
| 92 | #endif | ||
| 93 | #endif | ||
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index cd67c711b..ad25854e6 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile | |||
| @@ -60,8 +60,7 @@ ifdef COMMON | |||
| 60 | SRC = keymap_common.c \ | 60 | SRC = keymap_common.c \ |
| 61 | $(MATRIX) \ | 61 | $(MATRIX) \ |
| 62 | led.c \ | 62 | led.c \ |
| 63 | backlight.c \ | 63 | backlight.c |
| 64 | beeps.c | ||
| 65 | 64 | ||
| 66 | ifdef KEYMAP | 65 | ifdef KEYMAP |
| 67 | SRC := common_keymaps/keymap_$(KEYMAP).c $(SRC) | 66 | SRC := common_keymaps/keymap_$(KEYMAP).c $(SRC) |
| @@ -74,8 +73,7 @@ else | |||
| 74 | SRC = extended_keymap_common.c \ | 73 | SRC = extended_keymap_common.c \ |
| 75 | $(MATRIX) \ | 74 | $(MATRIX) \ |
| 76 | led.c \ | 75 | led.c \ |
| 77 | backlight.c \ | 76 | backlight.c |
| 78 | beeps.c | ||
| 79 | 77 | ||
| 80 | ifdef KEYMAP | 78 | ifdef KEYMAP |
| 81 | SRC := extended_keymaps/extended_keymap_$(KEYMAP).c $(SRC) | 79 | SRC := extended_keymaps/extended_keymap_$(KEYMAP).c $(SRC) |
diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h index 7e95afdde..47cf39a90 100644 --- a/keyboard/planck/config.h +++ b/keyboard/planck/config.h | |||
| @@ -18,19 +18,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 18 | #ifndef CONFIG_H | 18 | #ifndef CONFIG_H |
| 19 | #define CONFIG_H | 19 | #define CONFIG_H |
| 20 | 20 | ||
| 21 | #include "config_definitions.h" | ||
| 21 | 22 | ||
| 22 | /* USB Device descriptor parameter */ | 23 | /* USB Device descriptor parameter */ |
| 23 | #define VENDOR_ID 0xFEED | 24 | #define VENDOR_ID 0xFEED |
| 24 | #define PRODUCT_ID 0x6060 | 25 | #define PRODUCT_ID 0x6060 |
| 25 | #define DEVICE_VER 0x0001 | 26 | #define DEVICE_VER 0x0001 |
| 26 | #define MANUFACTURER Ortholinear Keyboards | 27 | #define MANUFACTURER Ortholinear Keyboards |
| 27 | #define PRODUCT Planck | 28 | #define PRODUCT The Planck Keyboard |
| 28 | #define DESCRIPTION A compact ortholinear keyboard | 29 | #define DESCRIPTION A compact ortholinear keyboard |
| 29 | 30 | ||
| 30 | /* key matrix size */ | 31 | /* key matrix size */ |
| 31 | #define MATRIX_ROWS 4 | 32 | #define MATRIX_ROWS 4 |
| 32 | #define MATRIX_COLS 12 | 33 | #define MATRIX_COLS 12 |
| 33 | 34 | ||
| 35 | /* Planck PCB default pin-out */ | ||
| 36 | #define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } | ||
| 37 | #define ROWS (int []){ D0, D5, B5, B6 } | ||
| 38 | |||
| 34 | /* define if matrix has ghost */ | 39 | /* define if matrix has ghost */ |
| 35 | //#define MATRIX_HAS_GHOST | 40 | //#define MATRIX_HAS_GHOST |
| 36 | 41 | ||
diff --git a/keyboard/planck/config_definitions.h b/keyboard/planck/config_definitions.h new file mode 100644 index 000000000..fd138b884 --- /dev/null +++ b/keyboard/planck/config_definitions.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | #ifndef CONFIG_DEFINITIONS_H | ||
| 2 | #define CONFIG_DEFINITIONS_H | ||
| 3 | |||
| 4 | #define B0 0x20 | ||
| 5 | #define B1 0x21 | ||
| 6 | #define B2 0x22 | ||
| 7 | #define B3 0x23 | ||
| 8 | #define B4 0x24 | ||
| 9 | #define B5 0x25 | ||
| 10 | #define B6 0x26 | ||
| 11 | #define B7 0x27 | ||
| 12 | #define C0 0x30 | ||
| 13 | #define C1 0x31 | ||
| 14 | #define C2 0x32 | ||
| 15 | #define C3 0x33 | ||
| 16 | #define C4 0x34 | ||
| 17 | #define C5 0x35 | ||
| 18 | #define C6 0x36 | ||
| 19 | #define C7 0x37 | ||
| 20 | #define D0 0x40 | ||
| 21 | #define D1 0x41 | ||
| 22 | #define D2 0x42 | ||
| 23 | #define D3 0x43 | ||
| 24 | #define D4 0x44 | ||
| 25 | #define D5 0x45 | ||
| 26 | #define D6 0x46 | ||
| 27 | #define D7 0x47 | ||
| 28 | #define E0 0x50 | ||
| 29 | #define E1 0x51 | ||
| 30 | #define E2 0x52 | ||
| 31 | #define E3 0x53 | ||
| 32 | #define E4 0x54 | ||
| 33 | #define E5 0x55 | ||
| 34 | #define E6 0x56 | ||
| 35 | #define E7 0x57 | ||
| 36 | #define F0 0x60 | ||
| 37 | #define F1 0x61 | ||
| 38 | #define F2 0x62 | ||
| 39 | #define F3 0x63 | ||
| 40 | #define F4 0x64 | ||
| 41 | #define F5 0x65 | ||
| 42 | #define F6 0x66 | ||
| 43 | #define F7 0x67 | ||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | #endif | ||
| 50 | |||
diff --git a/keyboard/planck/extended_keymap_common.h b/keyboard/planck/extended_keymap_common.h index 2dce4a2fa..e6a7dac5b 100644 --- a/keyboard/planck/extended_keymap_common.h +++ b/keyboard/planck/extended_keymap_common.h | |||
| @@ -48,6 +48,7 @@ typedef union { | |||
| 48 | keymap_config_t keymap_config; | 48 | keymap_config_t keymap_config; |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | |||
| 51 | /* translates key to keycode */ | 52 | /* translates key to keycode */ |
| 52 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); | 53 | uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key); |
| 53 | 54 | ||
diff --git a/keyboard/planck/extended_keymaps/extended_keymap_default.c b/keyboard/planck/extended_keymaps/extended_keymap_default.c index 1d5ac4321..c75144bf4 100644 --- a/keyboard/planck/extended_keymaps/extended_keymap_default.c +++ b/keyboard/planck/extended_keymaps/extended_keymap_default.c | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #include "extended_keymap_common.h" | 1 | #include "extended_keymap_common.h" |
| 2 | #include "backlight.h" | 2 | #include "backlight.h" |
| 3 | #include "lufa.h" | ||
| 4 | #include "debug.h" | ||
| 3 | 5 | ||
| 4 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 6 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 5 | [0] = { /* Qwerty */ | 7 | [0] = { /* Qwerty */ |
| @@ -51,9 +53,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 51 | case 0: | 53 | case 0: |
| 52 | if (record->event.pressed) { | 54 | if (record->event.pressed) { |
| 53 | register_code(KC_RSFT); | 55 | register_code(KC_RSFT); |
| 56 | midi_send_noteon(&midi_device, 1, 64, 127); | ||
| 54 | backlight_step(); | 57 | backlight_step(); |
| 55 | } else { | 58 | } else { |
| 56 | unregister_code(KC_RSFT); | 59 | unregister_code(KC_RSFT); |
| 60 | midi_send_noteoff(&midi_device, 1, 64, 127); | ||
| 57 | } | 61 | } |
| 58 | break; | 62 | break; |
| 59 | } | 63 | } |
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c new file mode 100644 index 000000000..58bd61f75 --- /dev/null +++ b/keyboard/planck/matrix.c | |||
| @@ -0,0 +1,235 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012 Jun Wako | ||
| 3 | Generated by planckkeyboard.com (2014 Jack Humbert) | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation, either version 2 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * scan matrix | ||
| 21 | */ | ||
| 22 | #include <stdint.h> | ||
| 23 | #include <stdbool.h> | ||
| 24 | #include <avr/io.h> | ||
| 25 | #include <util/delay.h> | ||
| 26 | #include "print.h" | ||
| 27 | #include "debug.h" | ||
| 28 | #include "util.h" | ||
| 29 | #include "matrix.h" | ||
| 30 | #include "backlight.h" // TODO fix this dependency | ||
| 31 | |||
| 32 | #ifndef DEBOUNCE | ||
| 33 | # define DEBOUNCE 10 | ||
| 34 | #endif | ||
| 35 | static uint8_t debouncing = DEBOUNCE; | ||
| 36 | |||
| 37 | /* matrix state(1:on, 0:off) */ | ||
| 38 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 39 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 40 | |||
| 41 | static matrix_row_t read_cols(void); | ||
| 42 | static void init_cols(void); | ||
| 43 | static void unselect_rows(void); | ||
| 44 | static void select_row(uint8_t row); | ||
| 45 | |||
| 46 | inline | ||
| 47 | uint8_t matrix_rows(void) | ||
| 48 | { | ||
| 49 | return MATRIX_ROWS; | ||
| 50 | } | ||
| 51 | |||
| 52 | inline | ||
| 53 | uint8_t matrix_cols(void) | ||
| 54 | { | ||
| 55 | return MATRIX_COLS; | ||
| 56 | } | ||
| 57 | |||
| 58 | void matrix_init(void) | ||
| 59 | { | ||
| 60 | // To use PORTF disable JTAG with writing JTD bit twice within four cycles. | ||
| 61 | MCUCR |= (1<<JTD); | ||
| 62 | MCUCR |= (1<<JTD); | ||
| 63 | |||
| 64 | backlight_init_ports(); | ||
| 65 | |||
| 66 | // Turn status LED on | ||
| 67 | DDRE |= (1<<6); | ||
| 68 | PORTE |= (1<<6); | ||
| 69 | |||
| 70 | // initialize row and col | ||
| 71 | unselect_rows(); | ||
| 72 | init_cols(); | ||
| 73 | |||
| 74 | // initialize matrix state: all keys off | ||
| 75 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 76 | matrix[i] = 0; | ||
| 77 | matrix_debouncing[i] = 0; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | uint8_t matrix_scan(void) | ||
| 83 | { | ||
| 84 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 85 | select_row(i); | ||
| 86 | _delay_us(30); // without this wait read unstable value. | ||
| 87 | matrix_row_t cols = read_cols(); | ||
| 88 | if (matrix_debouncing[i] != cols) { | ||
| 89 | matrix_debouncing[i] = cols; | ||
| 90 | if (debouncing) { | ||
| 91 | debug("bounce!: "); debug_hex(debouncing); debug("\n"); | ||
| 92 | } | ||
| 93 | debouncing = DEBOUNCE; | ||
| 94 | } | ||
| 95 | unselect_rows(); | ||
| 96 | } | ||
| 97 | |||
| 98 | if (debouncing) { | ||
| 99 | if (--debouncing) { | ||
| 100 | _delay_ms(1); | ||
| 101 | } else { | ||
| 102 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 103 | matrix[i] = matrix_debouncing[i]; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | return 1; | ||
| 109 | } | ||
| 110 | |||
| 111 | bool matrix_is_modified(void) | ||
| 112 | { | ||
| 113 | if (debouncing) return false; | ||
| 114 | return true; | ||
| 115 | } | ||
| 116 | |||
| 117 | inline | ||
| 118 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 119 | { | ||
| 120 | return (matrix[row] & ((matrix_row_t)1<col)); | ||
| 121 | } | ||
| 122 | |||
| 123 | inline | ||
| 124 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 125 | { | ||
| 126 | return matrix[row]; | ||
| 127 | } | ||
| 128 | |||
| 129 | void matrix_print(void) | ||
| 130 | { | ||
| 131 | print("\nr/c 0123456789ABCDEF\n"); | ||
| 132 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 133 | phex(row); print(": "); | ||
| 134 | pbin_reverse16(matrix_get_row(row)); | ||
| 135 | print("\n"); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | uint8_t matrix_key_count(void) | ||
| 140 | { | ||
| 141 | uint8_t count = 0; | ||
| 142 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 143 | count += bitpop16(matrix[i]); | ||
| 144 | } | ||
| 145 | return count; | ||
| 146 | } | ||
| 147 | |||
| 148 | static void init_cols(void) | ||
| 149 | { | ||
| 150 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 151 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 152 | int col = COLS[x]; | ||
| 153 | if ((col & 0xF0) == 0x20) { | ||
| 154 | B |= (1<<(col & 0x0F)); | ||
| 155 | } else if ((col & 0xF0) == 0x30) { | ||
| 156 | C |= (1<<(col & 0x0F)); | ||
| 157 | } else if ((col & 0xF0) == 0x40) { | ||
| 158 | D |= (1<<(col & 0x0F)); | ||
| 159 | } else if ((col & 0xF0) == 0x50) { | ||
| 160 | E |= (1<<(col & 0x0F)); | ||
| 161 | } else if ((col & 0xF0) == 0x60) { | ||
| 162 | F |= (1<<(col & 0x0F)); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | DDRB &= ~(B); PORTB |= (B); | ||
| 166 | DDRC &= ~(C); PORTC |= (C); | ||
| 167 | DDRD &= ~(D); PORTD |= (D); | ||
| 168 | DDRE &= ~(E); PORTE |= (E); | ||
| 169 | DDRF &= ~(F); PORTF |= (F); | ||
| 170 | } | ||
| 171 | |||
| 172 | static matrix_row_t read_cols(void) | ||
| 173 | { | ||
| 174 | matrix_row_t result = 0; | ||
| 175 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
| 176 | int col = COLS[x]; | ||
| 177 | if ((col & 0xF0) == 0x20) { | ||
| 178 | result |= (PINB&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 179 | } else if ((col & 0xF0) == 0x30) { | ||
| 180 | result |= (PINC&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 181 | } else if ((col & 0xF0) == 0x40) { | ||
| 182 | result |= (PIND&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 183 | } else if ((col & 0xF0) == 0x50) { | ||
| 184 | result |= (PINE&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 185 | } else if ((col & 0xF0) == 0x60) { | ||
| 186 | result |= (PINF&(1<<(col & 0x0F)) ? 0 : (1<<x)); | ||
| 187 | } | ||
| 188 | } | ||
| 189 | return result; | ||
| 190 | } | ||
| 191 | |||
| 192 | static void unselect_rows(void) | ||
| 193 | { | ||
| 194 | int B = 0, C = 0, D = 0, E = 0, F = 0; | ||
| 195 | for(int x = 0; x < MATRIX_ROWS; x++) { | ||
| 196 | int row = ROWS[x]; | ||
| 197 | if ((row & 0xF0) == 0x20) { | ||
| 198 | B |= (1<<(row & 0x0F)); | ||
| 199 | } else if ((row & 0xF0) == 0x30) { | ||
| 200 | C |= (1<<(row & 0x0F)); | ||
| 201 | } else if ((row & 0xF0) == 0x40) { | ||
| 202 | D |= (1<<(row & 0x0F)); | ||
| 203 | } else if ((row & 0xF0) == 0x50) { | ||
| 204 | E |= (1<<(row & 0x0F)); | ||
| 205 | } else if ((row & 0xF0) == 0x60) { | ||
| 206 | F |= (1<<(row & 0x0F)); | ||
| 207 | } | ||
| 208 | } | ||
| 209 | DDRB &= ~(B); PORTB |= (B); | ||
| 210 | DDRC &= ~(C); PORTC |= (C); | ||
| 211 | DDRD &= ~(D); PORTD |= (D); | ||
| 212 | DDRE &= ~(E); PORTE |= (E); | ||
| 213 | DDRF &= ~(F); PORTF |= (F); | ||
| 214 | } | ||
| 215 | |||
| 216 | static void select_row(uint8_t row) | ||
| 217 | { | ||
| 218 | int row_pin = ROWS[row]; | ||
| 219 | if ((row_pin & 0xF0) == 0x20) { | ||
| 220 | DDRB |= (1<<(row_pin & 0x0F)); | ||
| 221 | PORTB &= ~(1<<(row_pin & 0x0F)); | ||
| 222 | } else if ((row_pin & 0xF0) == 0x30) { | ||
| 223 | DDRC |= (1<<(row_pin & 0x0F)); | ||
| 224 | PORTC &= ~(1<<(row_pin & 0x0F)); | ||
| 225 | } else if ((row_pin & 0xF0) == 0x40) { | ||
| 226 | DDRD |= (1<<(row_pin & 0x0F)); | ||
| 227 | PORTD &= ~(1<<(row_pin & 0x0F)); | ||
| 228 | } else if ((row_pin & 0xF0) == 0x50) { | ||
| 229 | DDRE |= (1<<(row_pin & 0x0F)); | ||
| 230 | PORTE &= ~(1<<(row_pin & 0x0F)); | ||
| 231 | } else if ((row_pin & 0xF0) == 0x60) { | ||
| 232 | DDRF |= (1<<(row_pin & 0x0F)); | ||
| 233 | PORTF &= ~(1<<(row_pin & 0x0F)); | ||
| 234 | } | ||
| 235 | } \ No newline at end of file | ||
diff --git a/keyboard/planck/matrix_pcb.c b/keyboard/planck/matrix_pcb.c index 6f6ccd5c1..2a9ec8fcd 100644 --- a/keyboard/planck/matrix_pcb.c +++ b/keyboard/planck/matrix_pcb.c | |||
| @@ -78,6 +78,7 @@ void matrix_init(void) | |||
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | |||
| 81 | uint8_t matrix_scan(void) | 82 | uint8_t matrix_scan(void) |
| 82 | { | 83 | { |
| 83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 84 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
