aboutsummaryrefslogtreecommitdiff
path: root/keyboard/hhkb/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/hhkb/matrix.c')
-rw-r--r--keyboard/hhkb/matrix.c36
1 files changed, 34 insertions, 2 deletions
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)
130void matrix_init(void) 156void 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 {