diff options
author | Simon Glass <sjg@chromium.org> | 2012-10-10 09:47:00 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-10-31 17:21:00 -0700 |
commit | f3c88fa1ab60101f32f9117dced3afdc3f4c9393 (patch) | |
tree | b751fa8ac6ff6861b33a23a520c34cde1eced1cd /chip | |
parent | eee95c9448a8accc8416b32c55a89d5796cdf35b (diff) | |
download | chrome-ec-f3c88fa1ab60101f32f9117dced3afdc3f4c9393.tar.gz |
stm32: Implement keyscan test infrastructure
Support the keyscan test functionality on stm32.
Note: This is enabled by default so that it continues to build. But it
is unlikely that we will want this in a shipping image. I suggest we add
the facility for a dev build.
Secondly, the stack has to be larger due to a printf (which admittedly I
could just remove). Should we make the stack size conditional on the
CONFIG? Seems a bit ugly, on the other hand we don't want to waste IRAM.
BUG=chrome-os-partner:12179
BRANCH=none
TEST=manual for now:
On snow:
./ectool keyscan 20000 key_sequence.txt
See that the test passes.
Change-Id: Ic441ca0bde1be9589a924374605e2f146d16f423
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35118
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/keyboard_scan.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index 34c4f7147b..5f74938312 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -16,6 +16,7 @@ #include "host_command.h" #include "keyboard.h" #include "keyboard_scan.h" +#include "keyboard_test.h" #include "registers.h" #include "system.h" #include "task.h" @@ -286,6 +287,14 @@ static void print_state(const uint8_t *state, const char *msg) CPUTS("]\n"); } +/** + * Read the raw row state for the currently selected column + * + * It is assumed that the column is already selected by the scanning + * hardware. The column number is only used by test code. + * + * @return row state, one bit for each row + */ static uint8_t read_raw_row_state(void) { uint16_t tmp; @@ -347,6 +356,11 @@ static int read_matrix(uint8_t *state) r = read_raw_row_state(); +#ifdef CONFIG_KEYBOARD_TEST + /* Use simulated keyscan sequence instead if testing active */ + r = keyscan_seq_get_scan(c, r); +#endif + #ifdef OR_WITH_CURRENT_STATE_FOR_TESTING /* KLUDGE - or current state in, so we can make sure * all the lines are hooked up */ @@ -527,8 +541,13 @@ static void scan_keyboard(void) * re-start immediatly polling instead of waiting * for the next interrupt. */ - if (!read_raw_row_state()) + if (!read_raw_row_state()) { +#ifdef CONFIG_KEYBOARD_TEST + task_wait_event(keyscan_seq_next_event_delay()); +#else task_wait_event(-1); +#endif + } enter_polling_mode(); |