diff options
author | tmk <nobody@nowhere> | 2013-07-08 14:38:03 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-07-08 14:38:03 +0900 |
commit | 0e37dd2ec56114221d8c3eaf98e02b95fa15fa74 (patch) | |
tree | c96e5c0804ee16fb56a39078950b90ab5a9d2743 /keyboard/hhkb/matrix.c | |
parent | d965822857e4933b1fcb0e940f4251468b32de9a (diff) | |
download | qmk_firmware-0e37dd2ec56114221d8c3eaf98e02b95fa15fa74.tar.gz qmk_firmware-0e37dd2ec56114221d8c3eaf98e02b95fa15fa74.zip |
Add power control of keyswitch board and tweak scan wait
Diffstat (limited to 'keyboard/hhkb/matrix.c')
-rw-r--r-- | keyboard/hhkb/matrix.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index cf4bf9a7de..d0731ef1f8 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -63,7 +63,7 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; PORTE |= (1<<6); \ } while (0) #define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ - (((COL) & 0x07)<<3) | \ + (((COL) & 0x07)<<3) | \ ((ROW) & 0x07)) #define KEY_ENABLE() (PORTB &= ~(1<<6)) #define KEY_UNABLE() (PORTB |= (1<<6)) @@ -79,16 +79,20 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; // col: PB3-5,6 // key: PD7(pull-uped) // prev: PB7 +// power: PD4(L:off/H:on) #define KEY_INIT() do { \ DDRB = 0xFF; \ PORTB = 0x00; \ DDRD &= ~0x80; \ PORTD |= 0x80; \ + /* keyswitch board power on */ \ + DDRD |= (1<<4); \ + PORTD |= (1<<4); \ KEY_UNABLE(); \ KEY_PREV_OFF(); \ } while (0) #define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ - (((COL) & 0x07)<<3) | \ + (((COL) & 0x07)<<3) | \ ((ROW) & 0x07)) #define KEY_ENABLE() (PORTB &= ~(1<<6)) #define KEY_UNABLE() (PORTB |= (1<<6)) @@ -97,6 +101,20 @@ static matrix_row_t _matrix1[MATRIX_ROWS]; #define KEY_PREV_OFF() (PORTB &= ~(1<<7)) #define KEY_POWER_ON() #define KEY_POWER_OFF() +/* +#define KEY_POWER_ON() do { \ + KEY_INIT(); \ + PORTD |= (1<<4); \ + _delay_ms(1); \ +} while (0) +#define KEY_POWER_OFF() do { \ + PORTD &= ~(1<<4); \ + DDRB &= ~0xFF; \ + PORTB &= ~0xFF; \ + DDRB &= ~0x80; \ + PORTB &= ~0x80; \ +} while (0) +*/ #elif defined(__AVR_ATmega328P__) @@ -195,16 +213,21 @@ uint8_t matrix_scan(void) uint8_t last = TIMER_RAW; KEY_ENABLE(); + // Wait for KEY_STATE outputs its value. // 1us was ok on one HHKB, but not worked on another. // 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 + // 1us wait doesn't work on tmk(16MHz) + // 5us wait does work on tmk(16MHz) + // 5us wait does work on tmk(16MHz/2) + // 5us wait does work on tmk(8MHz) // 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); + _delay_us(5); + if (KEY_STATE()) { matrix[row] &= ~(1<<col); } else { |