diff options
author | Vic Yang <victoryang@chromium.org> | 2014-11-20 13:20:37 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-12 07:26:49 +0000 |
commit | 33142ba9ac61833ad10ffe5b7b6a2ca0e7be9912 (patch) | |
tree | 054f23a09fbbf10cf300ff2b88ae426e123055fa /test | |
parent | 99ec74d7d414b4acd6e210798469f7699fedea01 (diff) | |
download | chrome-ec-33142ba9ac61833ad10ffe5b7b6a2ca0e7be9912.tar.gz |
ryu: Try to clear CHARGE_DONE when the lid is just closed
For the transmitter to clear CHARGE_DONE, charging must be enabled.
Therefore, we should always enable charging when the lid is just closed.
BRANCH=ryu
BUG=None
TEST=Test on Ryu p1.
Signed-off-by: Vic Yang <victoryang@chromium.org>
Change-Id: I44f3d7c9e413a63be66ccf9695fea5411b2067b6
Reviewed-on: https://chromium-review.googlesource.com/231121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/inductive_charging.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test/inductive_charging.c b/test/inductive_charging.c index 8a4a94df5f..9e9d1f8486 100644 --- a/test/inductive_charging.c +++ b/test/inductive_charging.c @@ -15,6 +15,9 @@ #include "timer.h" #include "util.h" +#define START_CHARGE_DELAY 5000 /* ms */ +#define TEST_CHECK_CHARGE_DELAY (START_CHARGE_DELAY + 500) /* ms */ + static void wait_for_lid_debounce(void) { while (lid_is_open() != gpio_get_level(GPIO_LID_OPEN)) @@ -34,13 +37,21 @@ static int test_lid(void) gpio_set_level(GPIO_CHARGE_DONE, 0); TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - /* Close the lid. Transmitter should be enabled. */ + /* + * Close the lid. The EC should wait for a second before + * enabling transmitter. + */ set_lid_open(0); + TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); + msleep(TEST_CHECK_CHARGE_DELAY); + + /* Transmitter should now be enabled. */ TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); /* Open the lid. Charging should stop. */ set_lid_open(1); + msleep(TEST_CHECK_CHARGE_DELAY); TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); @@ -51,6 +62,7 @@ static int test_charge_done(void) { /* Close the lid to start charging */ set_lid_open(0); + msleep(TEST_CHECK_CHARGE_DELAY); TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); @@ -71,12 +83,14 @@ static int test_lid_open_during_charging(void) { /* Close the lid. Start charging. */ set_lid_open(0); + msleep(TEST_CHECK_CHARGE_DELAY); gpio_set_level(GPIO_CHARGE_DONE, 0); TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); /* Open the lid. Transmitter should be turned off. */ set_lid_open(1); + msleep(TEST_CHECK_CHARGE_DELAY); TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); @@ -91,6 +105,30 @@ static int test_lid_open_during_charging(void) return EC_SUCCESS; } +static int test_clear_charge_done(void) +{ + /* Lid is open initially. CHARGE_DONE is set. */ + set_lid_open(1); + msleep(TEST_CHECK_CHARGE_DELAY); + gpio_set_level(GPIO_CHARGE_DONE, 1); + TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); + TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); + + /* Close the lid. Charging should start. */ + set_lid_open(0); + msleep(TEST_CHECK_CHARGE_DELAY); + TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); + TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); + gpio_set_level(GPIO_CHARGE_DONE, 0); + + /* Charge is done. */ + gpio_set_level(GPIO_CHARGE_DONE, 1); + TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); + TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); + + return EC_SUCCESS; +} + void run_test(void) { test_reset(); @@ -98,6 +136,7 @@ void run_test(void) RUN_TEST(test_lid); RUN_TEST(test_charge_done); RUN_TEST(test_lid_open_during_charging); + RUN_TEST(test_clear_charge_done); test_print_result(); } |