diff options
| author | tmk <nobody@nowhere> | 2013-07-03 11:02:33 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-07-03 11:02:33 +0900 |
| commit | e9796ff462efe7e6d06ecf56494632a780fe992b (patch) | |
| tree | fbd67275bdba8ba5d69eaff11a41bc29bc69ad71 /keyboard/hhkb | |
| parent | 681e0194501aba4e6234f478d2c96d428b1223b5 (diff) | |
| download | qmk_firmware-e9796ff462efe7e6d06ecf56494632a780fe992b.tar.gz qmk_firmware-e9796ff462efe7e6d06ecf56494632a780fe992b.zip | |
Add Makefile for tmk board and tweak scan wait
Diffstat (limited to 'keyboard/hhkb')
| -rw-r--r-- | keyboard/hhkb/Makefile.tmk | 129 | ||||
| -rw-r--r-- | keyboard/hhkb/matrix.c | 36 |
2 files changed, 163 insertions, 2 deletions
diff --git a/keyboard/hhkb/Makefile.tmk b/keyboard/hhkb/Makefile.tmk new file mode 100644 index 000000000..32dd5796f --- /dev/null +++ b/keyboard/hhkb/Makefile.tmk | |||
| @@ -0,0 +1,129 @@ | |||
| 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 = hhkb_tmk | ||
| 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 = at90usb1286 | ||
| 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 = 8000000 | ||
| 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 | # Interrupt driven control endpoint task | ||
| 97 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 98 | |||
| 99 | |||
| 100 | # Boot Section Size in *bytes* | ||
| 101 | # Teensy halfKay 512 | ||
| 102 | # Teensy++ halfKay 1024 | ||
| 103 | # Atmel DFU loader 4096 | ||
| 104 | # LUFA bootloader 4096 | ||
| 105 | # USBaspLoader 2048 | ||
| 106 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 107 | |||
| 108 | |||
| 109 | # Build Options | ||
| 110 | # comment out to disable the options. | ||
| 111 | # | ||
| 112 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | ||
| 113 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 114 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 115 | CONSOLE_ENABLE = yes # Console for debug | ||
| 116 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 117 | #NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 118 | |||
| 119 | |||
| 120 | # Search Path | ||
| 121 | VPATH += $(TARGET_DIR) | ||
| 122 | VPATH += $(TOP_DIR) | ||
| 123 | |||
| 124 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 125 | include $(TOP_DIR)/common.mk | ||
| 126 | include $(TOP_DIR)/rules.mk | ||
| 127 | |||
| 128 | debug-on: EXTRAFLAGS += -DDEBUG | ||
| 129 | debug-on: all | ||
diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index 3d4b1f6c7..cf4bf9a7d 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c | |||
| @@ -73,6 +73,32 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; | |||
| 73 | #define KEY_POWER_ON() | 73 | #define KEY_POWER_ON() |
| 74 | #define KEY_POWER_OFF() | 74 | #define KEY_POWER_OFF() |
| 75 | 75 | ||
| 76 | #elif defined(__AVR_ATmega32U4__) | ||
| 77 | // Ports for my designed Alt Controller PCB | ||
| 78 | // row: PB0-2 | ||
| 79 | // col: PB3-5,6 | ||
| 80 | // key: PD7(pull-uped) | ||
| 81 | // prev: PB7 | ||
| 82 | #define KEY_INIT() do { \ | ||
| 83 | DDRB = 0xFF; \ | ||
| 84 | PORTB = 0x00; \ | ||
| 85 | DDRD &= ~0x80; \ | ||
| 86 | PORTD |= 0x80; \ | ||
| 87 | KEY_UNABLE(); \ | ||
| 88 | KEY_PREV_OFF(); \ | ||
| 89 | } while (0) | ||
| 90 | #define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ | ||
| 91 | (((COL) & 0x07)<<3) | \ | ||
| 92 | ((ROW) & 0x07)) | ||
| 93 | #define KEY_ENABLE() (PORTB &= ~(1<<6)) | ||
| 94 | #define KEY_UNABLE() (PORTB |= (1<<6)) | ||
| 95 | #define KEY_STATE() (PIND & (1<<7)) | ||
| 96 | #define KEY_PREV_ON() (PORTB |= (1<<7)) | ||
| 97 | #define KEY_PREV_OFF() (PORTB &= ~(1<<7)) | ||
| 98 | #define KEY_POWER_ON() | ||
| 99 | #define KEY_POWER_OFF() | ||
| 100 | |||
| 101 | |||
| 76 | #elif defined(__AVR_ATmega328P__) | 102 | #elif defined(__AVR_ATmega328P__) |
| 77 | // Ports for V-USB | 103 | // Ports for V-USB |
| 78 | // key: PB0(pull-uped) | 104 | // key: PB0(pull-uped) |
| @@ -130,7 +156,6 @@ uint8_t matrix_cols(void) | |||
| 130 | void matrix_init(void) | 156 | void matrix_init(void) |
| 131 | { | 157 | { |
| 132 | #ifdef DEBUG | 158 | #ifdef DEBUG |
| 133 | print_enable = true; | ||
| 134 | debug_enable = true; | 159 | debug_enable = true; |
| 135 | debug_keyboard = true; | 160 | debug_keyboard = true; |
| 136 | #endif | 161 | #endif |
| @@ -172,7 +197,14 @@ uint8_t matrix_scan(void) | |||
| 172 | KEY_ENABLE(); | 197 | KEY_ENABLE(); |
| 173 | // Wait for KEY_STATE outputs its value. | 198 | // Wait for KEY_STATE outputs its value. |
| 174 | // 1us was ok on one HHKB, but not worked on another. | 199 | // 1us was ok on one HHKB, but not worked on another. |
| 175 | _delay_us(10); | 200 | // no wait doesn't work on Teensy++ with pro(1us works) |
| 201 | // no wait does work on tmk PCB(8MHz) with pro2 | ||
| 202 | // 1us wait does work on both of above | ||
| 203 | // 10us wait does work on Teensy++ with pro | ||
| 204 | // 10us wait does work on 328p+iwrap with pro | ||
| 205 | // 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan) | ||
| 206 | _delay_us(1); | ||
| 207 | // _delay_us(10); | ||
| 176 | if (KEY_STATE()) { | 208 | if (KEY_STATE()) { |
| 177 | matrix[row] &= ~(1<<col); | 209 | matrix[row] &= ~(1<<col); |
| 178 | } else { | 210 | } else { |
