Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Oct 1, 2024
1 parent 068b212 commit 47a1329
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 60 deletions.
57 changes: 1 addition & 56 deletions tests/validation/sleep/sleep.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@
#define THRESHOLD 0 /* Lower the value, more the sensitivity */
#endif

// External wakeup
#define BUTTON_PIN_BITMASK(GPIO) (1ULL << GPIO) // 2 ^ GPIO_NUMBER in hex

#if CONFIG_IDF_TARGET_ESP32H2
#define WAKEUP_GPIO GPIO_NUM_7 // Only RTC IO are allowed
#define TARGET_FREQ 32
#else
#define WAKEUP_GPIO GPIO_NUM_4 // Only RTC IO are allowed
#define TARGET_FREQ 40
#endif
#define TARGET_FREQ CONFIG_XTAL_FREQ

RTC_DATA_ATTR int boot_count = 0;
uint32_t orig_freq = 0;
Expand Down Expand Up @@ -60,30 +51,6 @@ void setup_touchpad() {
#endif
}

void setup_rtc_io() {
#if SOC_RTCIO_WAKE_SUPPORTED && SOC_PM_SUPPORT_EXT0_WAKEUP
esp_sleep_enable_ext0_wakeup(WAKEUP_GPIO, 1);
rtc_gpio_pullup_en(WAKEUP_GPIO);
rtc_gpio_pulldown_dis(WAKEUP_GPIO);
#endif
}

void setup_rtc_cntl() {
#if SOC_RTCIO_WAKE_SUPPORTED && SOC_PM_SUPPORT_EXT1_WAKEUP
esp_sleep_enable_ext1_wakeup_io(BUTTON_PIN_BITMASK(WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_HIGH);
rtc_gpio_pulldown_dis(WAKEUP_GPIO);
rtc_gpio_pullup_en(WAKEUP_GPIO);
#endif
}

void setup_gpio() {
esp_sleep_pd_config(ESP_PD_DOMAIN_VDDSDIO, ESP_PD_OPTION_ON);
gpio_pullup_dis(WAKEUP_GPIO);
gpio_pulldown_en(WAKEUP_GPIO);
gpio_wakeup_enable(WAKEUP_GPIO, GPIO_INTR_LOW_LEVEL);
esp_sleep_enable_gpio_wakeup();
}

void setup_uart() {
uart_set_wakeup_threshold(UART_NUM_0, 9); // wake up with "aaa" string (9 positive edges)
esp_sleep_enable_uart_wakeup(UART_NUM_0);
Expand Down Expand Up @@ -126,18 +93,6 @@ void loop() {
esp_deep_sleep_start();
Serial.println("FAIL");
while(1);
} else if (command == "rtc_io_deep") {
// Test external wakeup from deep sleep using RTC IO
setup_rtc_io();
esp_deep_sleep_start();
Serial.println("FAIL");
while(1);
} else if (command == "rtc_cntl_deep") {
// Test external wakeup from deep sleep using RTC controller
setup_rtc_cntl();
esp_deep_sleep_start();
Serial.println("FAIL");
while(1);
} else if (command == "timer_light") {
// Test timer wakeup from light sleep
setup_timer();
Expand All @@ -148,15 +103,6 @@ void loop() {
} else if (command == "touchpad_light") {
// Test touchpad wakeup from light sleep
setup_touchpad();
} else if (command == "rtc_io_light") {
// Test external wakeup from light sleep using RTC IO
setup_rtc_io();
} else if (command == "rtc_cntl_light") {
// Test external wakeup from light sleep using RTC controller
setup_rtc_cntl();
} else if (command == "gpio_light") {
// Test external wakeup from light sleep using GPIO
setup_gpio();
} else if (command == "uart_light") {
// Test external wakeup from light sleep using UART
setup_uart();
Expand All @@ -169,7 +115,6 @@ void loop() {
Serial.println("Woke up from light sleep");
print_wakeup_reason();
Serial.flush();
gpio_hold_dis(WAKEUP_GPIO);
setCpuFrequencyMhz(orig_freq);
}
}
5 changes: 1 addition & 4 deletions tests/validation/sleep/test_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
capabilities = {
"timer": ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6", "esp32h2"],
"touchpad": ["esp32", "esp32s2", "esp32s3"],
"rtc_io": ["esp32", "esp32s2", "esp32s3", "esp32c6"],
"rtc_cntl": ["esp32", "esp32s2", "esp32s3", "esp32c6"],
"gpio": ["esp32", "esp32s2", "esp32s3"],
"uart": ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6", "esp32h2"]
}

Expand All @@ -19,7 +16,7 @@ def test_sleep(dut):
dut.expect_exact("Wakeup reason: power_up")

for capability, devices in capabilities.items():
if dut.app.target in devices and capability not in ["gpio", "uart"]:
if dut.app.target in devices and capability != "uart":
LOGGER.info("Testing {} deep sleep capability".format(capability))
boot_count += 1
dut.write("{}_deep".format(capability))
Expand Down

0 comments on commit 47a1329

Please sign in to comment.