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.
This commit is contained in:
Angus Gratton 2021-03-04 12:20:55 +11:00
parent 781b7f21dc
commit 964bed5c1b

View File

@ -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");
}