diff options
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 0000000000..32dd5796f5 --- /dev/null +++ b/keyboard/hhkb/Makefile.tmk @@ -0,0 +1,129 @@ +#---------------------------------------------------------------------------- +# 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 = hhkb_tmk + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + + +# List C source files here. (C dependencies are automatically generated.) +SRC += keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + + +# MCU name +#MCU = at90usb1286 +MCU = atmega32u4 + +# 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 = 8000000 + + +# +# 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 +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 +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +#NKRO_ENABLE = yes # USB Nkey Rollover + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk + +debug-on: EXTRAFLAGS += -DDEBUG +debug-on: all diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index 3d4b1f6c74..cf4bf9a7de 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -73,6 +73,32 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; #define KEY_POWER_ON() #define KEY_POWER_OFF() +#elif defined(__AVR_ATmega32U4__) +// Ports for my designed Alt Controller PCB +// row: PB0-2 +// col: PB3-5,6 +// key: PD7(pull-uped) +// prev: PB7 +#define KEY_INIT() do { \ + DDRB = 0xFF; \ + PORTB = 0x00; \ + DDRD &= ~0x80; \ + PORTD |= 0x80; \ + KEY_UNABLE(); \ + KEY_PREV_OFF(); \ +} while (0) +#define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ + (((COL) & 0x07)<<3) | \ + ((ROW) & 0x07)) +#define KEY_ENABLE() (PORTB &= ~(1<<6)) +#define KEY_UNABLE() (PORTB |= (1<<6)) +#define KEY_STATE() (PIND & (1<<7)) +#define KEY_PREV_ON() (PORTB |= (1<<7)) +#define KEY_PREV_OFF() (PORTB &= ~(1<<7)) +#define KEY_POWER_ON() +#define KEY_POWER_OFF() + + #elif defined(__AVR_ATmega328P__) // Ports for V-USB // key: PB0(pull-uped) @@ -130,7 +156,6 @@ uint8_t matrix_cols(void) void matrix_init(void) { #ifdef DEBUG - print_enable = true; debug_enable = true; debug_keyboard = true; #endif @@ -172,7 +197,14 @@ uint8_t matrix_scan(void) KEY_ENABLE(); // Wait for KEY_STATE outputs its value. // 1us was ok on one HHKB, but not worked on another. - _delay_us(10); + // no wait doesn't work on Teensy++ with pro(1us works) + // no wait does work on tmk PCB(8MHz) with pro2 + // 1us wait does work on both of above + // 10us wait does work on Teensy++ with pro + // 10us wait does work on 328p+iwrap with pro + // 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan) + _delay_us(1); +// _delay_us(10); if (KEY_STATE()) { matrix[row] &= ~(1<<col); } else { |