Skip to content

Commit 5a5bcc5

Browse files
committed
Firmware's pinout fits to the documentation
1 parent 93259b0 commit 5a5bcc5

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

keyboard/ergomod/matrix.c

+28-33
Original file line numberDiff line numberDiff line change
@@ -135,52 +135,47 @@ uint8_t matrix_key_count(void)
135135
}
136136

137137
/* Column pin configuration
138-
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
139-
* pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A)
140-
* pin: B7 (Rev.B)
138+
* col: 0 1 2 3 4 5 6 7 8 9 A B C D E F
139+
* pin: F0 F1 F2 F3 F4 F5 F6 F7 C0 C1 C2 C3 C4 C5 C6 C7
141140
*/
142141
static void init_cols(void)
143142
{
144143
// Input with pull-up(DDR:0, PORT:1)
145-
DDRF &= ~(1<<0 | 1<<1);
146-
PORTF |= (1<<0 | 1<<1);
147-
DDRE &= ~(1<<6);
148-
PORTE |= (1<<6);
149-
DDRD &= ~(1<<7 | 1<<6 | 1<<4);
150-
PORTD |= (1<<7 | 1<<6 | 1<<4);
151-
DDRC &= ~(1<<7 | 1<<6);
152-
PORTC |= (1<<7 | 1<<6);
153-
DDRB &= ~(1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
154-
PORTB |= (1<<7 | 1<<6 | 1<< 5 | 1<<4 | 1<<3 | 1<<1 | 1<<0);
144+
DDRF &= 0b00000000;
145+
PORTF |= 0b11111111;
146+
DDRC &= 0b00000000;
147+
PORTC |= 0b11111111;
155148
}
156149

157150
static matrix_row_t read_cols(void)
158151
{
159-
return (PINF&(1<<0) ? 0 : (1<<0)) |
160-
(PINF&(1<<1) ? 0 : (1<<1)) |
161-
(PINE&(1<<6) ? 0 : (1<<2)) |
162-
(PINC&(1<<7) ? 0 : (1<<3)) |
163-
(PINC&(1<<6) ? 0 : (1<<4)) |
164-
(PINB&(1<<6) ? 0 : (1<<5)) |
165-
(PIND&(1<<4) ? 0 : (1<<6)) |
166-
(PINB&(1<<1) ? 0 : (1<<7)) |
167-
((PINB&(1<<0) && PINB&(1<<7)) ? 0 : (1<<8)) | // Rev.A and B
168-
(PINB&(1<<5) ? 0 : (1<<9)) |
169-
(PINB&(1<<4) ? 0 : (1<<10)) |
170-
(PIND&(1<<7) ? 0 : (1<<11)) |
171-
(PIND&(1<<6) ? 0 : (1<<12)) |
172-
(PINB&(1<<3) ? 0 : (1<<13));
152+
return (PINF&(1<<0) ? 0 : (1<<0)) |
153+
(PINF&(1<<1) ? 0 : (1<<1)) |
154+
(PINF&(1<<2) ? 0 : (1<<2)) |
155+
(PINF&(1<<3) ? 0 : (1<<3)) |
156+
(PINF&(1<<4) ? 0 : (1<<4)) |
157+
(PINF&(1<<5) ? 0 : (1<<5)) |
158+
(PINF&(1<<6) ? 0 : (1<<6)) |
159+
(PINF&(1<<7) ? 0 : (1<<7)) |
160+
(PINC&(1<<0) ? 0 : (1<<8)) |
161+
(PINC&(1<<1) ? 0 : (1<<9)) |
162+
(PINC&(1<<2) ? 0 : (1<<10)) |
163+
(PINC&(1<<3) ? 0 : (1<<11)) |
164+
(PINC&(1<<4) ? 0 : (1<<12)) |
165+
(PINC&(1<<5) ? 0 : (1<<13)) |
166+
(PINC&(1<<6) ? 0 : (1<<14)) |
167+
(PINC&(1<<7) ? 0 : (1<<15));
173168
}
174169

175170
/* Row pin configuration
176-
* row: 0 1 2 3 4
177-
* pin: D0 D1 D2 D3 D5
171+
* row: 0 1 2 3 4
172+
* pin: D0 D1 D2 D3 D4
178173
*/
179174
static void unselect_rows(void)
180175
{
181176
// Hi-Z(DDR:0, PORT:0) to unselect
182-
DDRD &= ~0b00101111;
183-
PORTD &= ~0b00101111;
177+
DDRD &= ~0b00011111;
178+
PORTD &= ~0b00011111;
184179
}
185180

186181
static void select_row(uint8_t row)
@@ -204,8 +199,8 @@ static void select_row(uint8_t row)
204199
PORTD &= ~(1<<3);
205200
break;
206201
case 4:
207-
DDRD |= (1<<5);
208-
PORTD &= ~(1<<5);
202+
DDRD |= (1<<4);
203+
PORTD &= ~(1<<4);
209204
break;
210205
}
211206
}

0 commit comments

Comments
 (0)