From 964bed5c1ba1231d35880d1bb37b0878bc64e415 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 4 Mar 2021 12:20:55 +1100 Subject: [PATCH] test_gpio: Fix GPIO_MODE_INPUT_OUTPUT test case The case sets one pin as output and the other as INPUT_OUTPUT (so output buffer is enabled in both), then only changes level of one pin - causing a conflict. Probably this test should be deleted, as it's not good practice for two output pins to drive each other, but this fix also seems to work. --- components/driver/test/test_gpio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/driver/test/test_gpio.c b/components/driver/test/test_gpio.c index c40815683c..3232df3ba2 100644 --- a/components/driver/test/test_gpio.c +++ b/components/driver/test/test_gpio.c @@ -341,7 +341,7 @@ TEST_CASE("GPIO enable and disable interrupt test", "[gpio][test_env=UT_T1_GPIO] TEST_ASSERT(gpio_isr_handler_remove(GPIO_INPUT_IO) == ESP_ERR_INVALID_STATE); } -// Connect GPIO18 with GPIO19 +// Connect GPIO_OUTPUT_IO with GPIO_INPUT_IO // use multimeter to test the voltage, so it is ignored in CI TEST_CASE("GPIO set gpio output level test", "[gpio][ignore]") { @@ -417,7 +417,7 @@ TEST_CASE("GPIO io pull up/down function", "[gpio]") TEST_CASE("GPIO output and input mode test", "[gpio][test_env=UT_T1_GPIO]") { - //connect io18 and io5 + //connect GPIO_OUTPUT_IO with GPIO_INPUT_IO gpio_config_t output_io = init_io(GPIO_OUTPUT_IO); gpio_config_t input_io = init_io(GPIO_INPUT_IO); gpio_config(&output_io); @@ -464,9 +464,10 @@ TEST_CASE("GPIO output and input mode test", "[gpio][test_env=UT_T1_GPIO]") TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_INPUT_IO), !level, "direction set error, it can't output"); // input test gpio_set_direction(GPIO_OUTPUT_IO, GPIO_MODE_OUTPUT); - gpio_set_direction(GPIO_INPUT_IO, GPIO_MODE_INPUT_OUTPUT); + gpio_set_direction(GPIO_INPUT_IO, GPIO_MODE_INPUT_OUTPUT); // sets output buffer for this pin also level = gpio_get_level(GPIO_INPUT_IO); gpio_set_level(GPIO_OUTPUT_IO, !level); + gpio_set_level(GPIO_INPUT_IO, !level); // in GPIO_MODE_INPUT_OUTPUT this pin also has an enabled output buffer TEST_ASSERT_EQUAL_INT_MESSAGE(gpio_get_level(GPIO_INPUT_IO), !level, "direction set error, it can't output"); }