keyboard/annepro2: Very stupid matrix scan bug fix.

This commit is contained in:
codetector
2021-08-29 13:42:06 +02:00
committed by bwisn
parent 7e4486187f
commit 00509c8ad9
2 changed files with 11 additions and 36 deletions
@@ -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
+2 -27
View File
@@ -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