]> granicus.if.org Git - esp-idf/commitdiff
gpio test: add GPIO multi-level interrupt test
authorhouchenyao <houchenyao@espressif.com>
Thu, 6 Sep 2018 03:47:17 +0000 (11:47 +0800)
committerhouchenyao <houchenyao@espressif.com>
Thu, 6 Sep 2018 09:43:23 +0000 (17:43 +0800)
 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

components/driver/test/test_gpio.c

index 20962e36f872aeba348c9bec2581010ce16b4f8b..e2550c7ee4c089122c2f2f52165d60ee506dd3cb 100644 (file)
@@ -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);