diff options
author | Chris Chen <twothreecc@google.com> | 2016-07-11 14:52:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-15 21:39:16 -0700 |
commit | 846741eddbb28e6770532ab09fb64dc619c2f6e6 (patch) | |
tree | 2e8e9815341d82ff83214ba5b4d94ef6869bd748 /cts/gpio/th.c | |
parent | db1b3b34c21530672118754e84ddbe879925542e (diff) | |
download | chrome-ec-846741eddbb28e6770532ab09fb64dc619c2f6e6.tar.gz |
cts: Added GPIO test suite
Contains code for all the gpio tests so far. Code in
cts_task for th and dut is for testing purposes and
test result reporting will be updated in the next
patch.
BRANCH=None
BUG=None
TEST=Manual
- Connect handshake and gpio test lines between th and dut
- Build tests
- run 'cat /dev/ttyACM0' in one terminal
- run 'cat /def/ttyACM1' in another
- Flash boards
- All test results should print either passed or unknown
Change-Id: I7142fb87a6ce0a20c571cde608fbbe60e35898ea
Reviewed-on: https://chromium-review.googlesource.com/359935
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'cts/gpio/th.c')
-rw-r--r-- | cts/gpio/th.c | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/cts/gpio/th.c b/cts/gpio/th.c index 7120a4da3e..ddc46f6602 100644 --- a/cts/gpio/th.c +++ b/cts/gpio/th.c @@ -10,12 +10,107 @@ #include "watchdog.h" #include "dut_common.h" #include "cts_common.h" +#include "gpio_common.h" + +enum cts_error_code sync_test(void) +{ + return SUCCESS; +} + +enum cts_error_code set_high_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code set_low_test(void) +{ + int level; + + gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP); + msleep(READ_WAIT_TIME_MS); + level = gpio_get_level(GPIO_INPUT_TEST); + if (!level) + return SUCCESS; + else + return FAILURE; +} + +enum cts_error_code read_high_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 1); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code read_low_test(void) +{ + gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW); + gpio_set_level(GPIO_OUTPUT_TEST, 0); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} + +enum cts_error_code od_read_high_test(void) +{ + gpio_set_flags(GPIO_INPUT_TEST, GPIO_OUTPUT | GPIO_ODR_LOW); + msleep(READ_WAIT_TIME_MS*2); + return UNKNOWN; +} void cts_task(void) { + enum cts_error_code results[GPIO_CTS_TEST_COUNT]; + int i; + + /* Don't bother checking sync's return value now because + * host will deal with hanging syncs/tests as well as + * interpreting test results later + */ + sync(); + results[0] = sync_test(); sync(); - CPRINTS("Successful Sync!"); + results[1] = set_low_test(); + sync(); + results[2] = set_high_test(); + sync(); + results[3] = read_high_test(); + sync(); + results[4] = read_low_test(); + sync(); + results[5] = od_read_high_test(); + + CPRINTS("GPIO test suite finished"); uart_flush_output(); + CPRINTS("Results:"); + for (i = 0; i < GPIO_CTS_TEST_COUNT; i++) { + switch (results[i]) { + case SUCCESS: + CPRINTS("%d) Passed", i); + break; + case FAILURE: + CPRINTS("%d) Failed", i); + break; + case BAD_SYNC: + CPRINTS("%d) Bad sync", i); + break; + case UNKNOWN: + CPRINTS("%d) Test result unknown", i); + break; + default: + CPRINTS("%d) ErrorCode not recognized", i); + break; + } + } + while (1) { watchdog_reload(); sleep(1); |