1
0

Fix matrix bugs

This commit is contained in:
Kai Ryu 2014-05-05 00:09:16 +09:00
parent 2b49a36295
commit ae0e33dd54

View File

@ -138,24 +138,22 @@ uint8_t matrix_key_count(void)
/* Column pin configuration /* Column pin configuration
* col: 0 1 2 3 4 5 * col: 0 1 2 3 4 5
* pin: D12 D13 A0 A1 A2 A3 (arduino) * pin: D14 D15 A0 A1 A2 A3 (arduino)
* PD6 PC7 PF7 PF6 PF5 PF4 * PB0 PB1 PF7 PF6 PF5 PF4
*/ */
static void init_cols(void) static void init_cols(void)
{ {
// Input with pull-up(DDR:0, PORT:1) // Input with pull-up(DDR:0, PORT:1)
DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4); PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
DDRD &= ~(1<<PD6); DDRB &= ~(1<<PB1 | 1<<PB0);
PORTD |= (1<<PD6); PORTB |= (1<<PB1 | 1<<PB0);
DDRC &= ~(1<<PC7);
PORTC |= (1<<PC7);
} }
static matrix_row_t read_cols(void) static matrix_row_t read_cols(void)
{ {
return (PIND&(1<<PD6) ? 0 : (1<<0)) | return (PINB&(1<<PB0) ? 0 : (1<<0)) |
(PINC&(1<<PC7) ? 0 : (1<<1)) | (PINB&(1<<PB1) ? 0 : (1<<1)) |
(PINF&(1<<PF7) ? 0 : (1<<2)) | (PINF&(1<<PF7) ? 0 : (1<<2)) |
(PINF&(1<<PF6) ? 0 : (1<<3)) | (PINF&(1<<PF6) ? 0 : (1<<3)) |
(PINF&(1<<PF5) ? 0 : (1<<4)) | (PINF&(1<<PF5) ? 0 : (1<<4)) |
@ -199,7 +197,7 @@ static void select_row(uint8_t row)
(row & (1<<0)) ? (PORTD |= (1<<PD3)) : (PORTD &= ~(1<<PD3)); (row & (1<<0)) ? (PORTD |= (1<<PD3)) : (PORTD &= ~(1<<PD3));
(row & (1<<1)) ? (PORTD |= (1<<PD2)) : (PORTD &= ~(1<<PD2)); (row & (1<<1)) ? (PORTD |= (1<<PD2)) : (PORTD &= ~(1<<PD2));
(row & (1<<2)) ? (PORTD |= (1<<PD0)) : (PORTD &= ~(1<<PD0)); (row & (1<<2)) ? (PORTD |= (1<<PD0)) : (PORTD &= ~(1<<PD0));
(row & (1<<3)) ? (PORTC |= (1<<PC6)) : (PORTC &= ~(1<<PC6)); (row & (1<<3)) ? (PORTC &= ~(1<<PC6)) : (PORTC |= (1<<PC6));
} }
else if (row == 16) { else if (row == 16) {
DDRD |= (1<<PD7); DDRD |= (1<<PD7);