From 00509c8ad92164ad7c06ad764e1fc2b03bbbdedd Mon Sep 17 00:00:00 2001 From: codetector Date: Wed, 1 Jul 2020 17:29:43 -0400 Subject: [PATCH] keyboard/annepro2: Very stupid matrix scan bug fix. --- .../annepro2/boards/ANNEPRO2_C18/board.h | 18 ++++++------ keyboards/annepro2/matrix.c | 29 ++----------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 6b33268a9bc..f413595d11f 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -39,23 +39,23 @@ #define LINE_ROW2 PAL_LINE(IOPORTB, 4) #define LINE_ROW3 PAL_LINE(IOPORTB, 3) #define LINE_ROW4 PAL_LINE(IOPORTB, 2) -#define LINE_ROW5 PAL_LINE(IOPORTC, 14) +#define LINE_ROW5 PAL_LINE(IOPORTD, 1) // inputs (columns are sampled) #define LINE_COL1 PAL_LINE(IOPORTC, 4) #define LINE_COL2 PAL_LINE(IOPORTC, 5) -#define LINE_COL3 PAL_LINE(IOPORTB, 15) -#define LINE_COL4 PAL_LINE(IOPORTC, 0) +#define LINE_COL3 PAL_LINE(IOPORTD, 0) +#define LINE_COL4 PAL_LINE(IOPORTB, 15) #define LINE_COL5 PAL_LINE(IOPORTC, 11) -#define LINE_COL6 PAL_LINE(IOPORTC, 10) +#define LINE_COL6 PAL_LINE(IOPORTA, 15) #define LINE_COL7 PAL_LINE(IOPORTC, 12) #define LINE_COL8 PAL_LINE(IOPORTC, 13) #define LINE_COL9 PAL_LINE(IOPORTA, 8) -#define LINE_COL10 PAL_LINE(IOPORTA, 9) -#define LINE_COL11 PAL_LINE(IOPORTA, 10) -#define LINE_COL12 PAL_LINE(IOPORTA, 11) -#define LINE_COL13 PAL_LINE(IOPORTD, 2) -#define LINE_COL14 PAL_LINE(IOPORTD, 3) +#define LINE_COL10 PAL_LINE(IOPORTA, 10) +#define LINE_COL11 PAL_LINE(IOPORTA, 11) +#define LINE_COL12 PAL_LINE(IOPORTA, 14) +#define LINE_COL13 PAL_LINE(IOPORTD, 3) +#define LINE_COL14 PAL_LINE(IOPORTD, 2) #if !defined(_FROM_ASM_) #ifdef __cplusplus diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 5dbbae17992..472b20ec729 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -39,35 +39,9 @@ void matrix_init(void) { matrix_init_quantum(); } -uint8_t matrix_scan_key(uint32_t row_line, uint32_t col_line) { - uint8_t debouncing = 0; - uint8_t count = 0; - while (1) { - // pull row low - palClearLine(row_line); - wait_us(1); - // read column - uint8_t val = palReadLine(col_line); - // drive row high - palSetLine(row_line); - - // debounce - if (val != debouncing) { - // restart debouncing - debouncing = val; - count = 0; - } else if (count >= DEBOUNCE) { - // finished debouncing - return (~debouncing) & 1; - } - wait_ms(1); - count++; - } -} - uint8_t matrix_scan(void) { // cache of input ports for columns - static uint16_t port_cache[3]; + static uint16_t port_cache[4]; // scan each row for (int row = 0; row < MATRIX_ROWS; row++) { palClearLine(row_list[row]); @@ -76,6 +50,7 @@ uint8_t matrix_scan(void) { port_cache[0] = palReadPort(IOPORTA); port_cache[1] = palReadPort(IOPORTB); port_cache[2] = palReadPort(IOPORTC); + port_cache[2] = palReadPort(IOPORTD); palSetLine(row_list[row]); // get columns from ports