diff --git a/board/daisy/board.h b/board/daisy/board.h index 4849259ecc..f06a4cf86a 100644 --- a/board/daisy/board.h +++ b/board/daisy/board.h @@ -22,6 +22,9 @@ #define USB_CHARGE_PORT_COUNT 0 +/* EC drives 13 outputs to keyboard matrix */ +#define KB_OUTPUTS 13 + /* GPIO signal list */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/board/snow/board.h b/board/snow/board.h index 93d219a635..6192fc1ce6 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -16,6 +16,9 @@ #define USB_CHARGE_PORT_COUNT 0 +/* EC drives 13 outputs to keyboard matrix */ +#define KB_OUTPUTS 13 + /* GPIO signal list */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index f6b1576360..453dc10af9 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -33,16 +33,14 @@ enum COL_INDEX { #define POLLING_MODE_TIMEOUT 100000 /* 100 ms */ #define SCAN_LOOP_DELAY 10000 /* 10 ms */ -#define KB_COLS 13 - /* 15:14, 12:8, 2 */ #define IRQ_MASK 0xdf04 /* The keyboard state from the last read */ -static uint8_t raw_state[KB_COLS]; +static uint8_t raw_state[KB_OUTPUTS]; /* The keyboard state we will return when requested */ -static uint8_t saved_state[KB_COLS]; +static uint8_t saved_state[KB_OUTPUTS]; /* Mask with 1 bits only for keys that actually exist */ static const uint8_t *actual_key_mask; @@ -50,7 +48,7 @@ static const uint8_t *actual_key_mask; /* All actual key masks (todo: move to keyboard matrix definition) */ /* TODO: (crosbug.com/p/7485) fill in real key mask with 0-bits for coords that aren't keys */ -static const uint8_t actual_key_masks[4][KB_COLS] = { +static const uint8_t actual_key_masks[4][KB_OUTPUTS] = { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, {0}, @@ -169,7 +167,7 @@ static int check_keys_changed(void) int change = 0; int num_press = 0; - for (c = 0; c < KB_COLS; c++) { + for (c = 0; c < KB_OUTPUTS; c++) { uint16_t tmp; /* Select column, then wait a bit for it to settle */ @@ -221,7 +219,7 @@ static int check_keys_changed(void) select_column(COL_TRI_STATE_ALL); /* Count number of key pressed */ - for (c = 0; c < KB_COLS; c++) { + for (c = 0; c < KB_OUTPUTS; c++) { if (raw_state[c]) ++num_press; } @@ -231,7 +229,7 @@ static int check_keys_changed(void) board_keyboard_scan_ready(); CPRINTF("[%d keys pressed: ", num_press); - for (c = 0; c < KB_COLS; c++) { + for (c = 0; c < KB_OUTPUTS; c++) { if (raw_state[c]) CPRINTF(" %02x", raw_state[c]); else