gpio test: add GPIO multi-level interrupt test
add case to test the bug of v3.0. If we trigger the level interrupt more than once, will cause the interrupt be triggered many times
@@ -287,6 +287,31 @@ TEST_CASE("GPIO low level interrupt test", "[gpio][test_env=UT_T1_GPIO]")
gpio_uninstall_isr_service();
}
+TEST_CASE("GPIO multi-level interrupt test, to cut the interrupt source exit interrupt ", "[gpio][test_env=UT_T1_GPIO]")
+{
+ level_intr_times=0;
+ gpio_config_t output_io = init_io(GPIO_OUTPUT_IO);
+ gpio_config_t input_io = init_io(GPIO_INPUT_IO);
+ input_io.intr_type = GPIO_INTR_POSEDGE;
+ input_io.mode = GPIO_MODE_INPUT;
+ input_io.pull_up_en = 1;
+ TEST_ESP_OK(gpio_config(&output_io));
+ TEST_ESP_OK(gpio_config(&input_io));
+ TEST_ESP_OK(gpio_set_level(GPIO_OUTPUT_IO, 0));
+
+ gpio_set_intr_type(GPIO_INPUT_IO, GPIO_INTR_HIGH_LEVEL);
+ gpio_install_isr_service(0);
+ gpio_isr_handler_add(GPIO_INPUT_IO, gpio_isr_level_handler2, (void*) GPIO_INPUT_IO);
+ gpio_set_level(GPIO_OUTPUT_IO, 1);
+ vTaskDelay(100 / portTICK_RATE_MS);
+ TEST_ASSERT_EQUAL_INT_MESSAGE(level_intr_times, 1, "go into high-level interrupt more than once with cur interrupt source way");
+ gpio_set_level(GPIO_OUTPUT_IO, 1);
+ vTaskDelay(200 / portTICK_RATE_MS);
+ TEST_ASSERT_EQUAL_INT_MESSAGE(level_intr_times, 2, "go into high-level interrupt more than once with cur interrupt source way");
+ gpio_isr_handler_remove(GPIO_INPUT_IO);
+ gpio_uninstall_isr_service();
+}
+
TEST_CASE("GPIO enable and disable interrupt test", "[gpio][test_env=UT_T1_GPIO]")
{
gpio_config_t output_io = init_io(GPIO_OUTPUT_IO);
