@@ -884,7 +884,7 @@ TEST_CASE("GPIO_light_sleep_wake_up_test", "[gpio][ignore]")
884884}
885885#endif
886886
887- #if SOC_DEEP_SLEEP_SUPPORTED && SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP
887+ #if SOC_DEEP_SLEEP_SUPPORTED
888888// Pick one digital IO for each target to test is enough
889889static void gpio_deep_sleep_hold_test_first_stage (void )
890890{
@@ -902,7 +902,9 @@ static void gpio_deep_sleep_hold_test_first_stage(void)
902902 .pull_up_en = GPIO_PULLUP_DISABLE ,
903903 };
904904 TEST_ESP_OK (gpio_config (& io_conf ));
905- TEST_ESP_OK (gpio_set_level (io_num , 0 ));
905+
906+ const bool initial_level = gpio_get_level (io_num );
907+ TEST_ESP_OK (gpio_set_level (io_num , !initial_level ));
906908
907909 // Enable global persistence
908910 TEST_ESP_OK (gpio_hold_en (io_num ));
@@ -911,6 +913,10 @@ static void gpio_deep_sleep_hold_test_first_stage(void)
911913 // Extra step is required, so that all digital IOs can automatically get held when entering Deep-sleep
912914 gpio_deep_sleep_hold_en ();
913915#endif
916+ vTaskDelay (pdMS_TO_TICKS (200 ));
917+ TEST_ESP_OK (gpio_set_level (io_num , initial_level ));
918+ TEST_ASSERT_EQUAL_INT (!initial_level , gpio_get_level (io_num ));
919+ vTaskDelay (pdMS_TO_TICKS (200 ));
914920
915921 esp_deep_sleep_start ();
916922}
@@ -921,16 +927,31 @@ static void gpio_deep_sleep_hold_test_second_stage(void)
921927 // Check reset reason is waking up from deepsleep
922928 TEST_ASSERT_EQUAL (ESP_RST_DEEPSLEEP , esp_reset_reason ());
923929
924- // Pin should stay at low level after the deep sleep
925- TEST_ASSERT_EQUAL_INT ( 0 , gpio_get_level (io_num ) );
930+ #if ! CONFIG_ESP32P4_SELECTS_REV_LESS_V3 // DIG-399
931+ bool level = gpio_get_level (io_num );
926932 // Set level should not take effect since hold is still active (and the INPUT_OUTPUT mode should still be held)
927- TEST_ESP_OK (gpio_set_level (io_num , 1 ));
928- TEST_ASSERT_EQUAL_INT (0 , gpio_get_level (io_num ));
933+ TEST_ESP_OK (gpio_set_level (io_num , !level ));
934+ TEST_ASSERT_EQUAL_INT (level , gpio_get_level (io_num ));
935+ #endif
929936
930937#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
931938 gpio_deep_sleep_hold_dis ();
932939#endif
933940 TEST_ESP_OK (gpio_hold_dis (io_num ));
941+
942+ gpio_config_t io_conf = {
943+ .intr_type = GPIO_INTR_DISABLE ,
944+ .mode = GPIO_MODE_INPUT_OUTPUT ,
945+ .pin_bit_mask = (1ULL << io_num ),
946+ .pull_down_en = GPIO_PULLDOWN_DISABLE ,
947+ .pull_up_en = GPIO_PULLUP_DISABLE ,
948+ };
949+ TEST_ESP_OK (gpio_config (& io_conf ));
950+
951+ #if !CONFIG_ESP32P4_SELECTS_REV_LESS_V3 // DIG-399
952+ // Check that the hold level after wakeup is the level before entering deep sleep
953+ TEST_ASSERT_EQUAL_INT (!level , gpio_get_level (io_num ));
954+ #endif
934955}
935956
936957/*
@@ -942,4 +963,4 @@ static void gpio_deep_sleep_hold_test_second_stage(void)
942963TEST_CASE_MULTIPLE_STAGES ("GPIO_deep_sleep_output_hold_test" , "[gpio]" ,
943964 gpio_deep_sleep_hold_test_first_stage ,
944965 gpio_deep_sleep_hold_test_second_stage )
945- #endif // SOC_DEEP_SLEEP_SUPPORTED && SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP
966+ #endif // SOC_DEEP_SLEEP_SUPPORTED
0 commit comments