Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Sep 17, 2024
1 parent e5b17db commit 4ddcd08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion tests/validation/sleep/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"platforms": {
"qemu": false
"qemu": false,
"wokwi": false
}
}
18 changes: 13 additions & 5 deletions tests/validation/sleep/sleep.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@

#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

RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR int boot_count = 0;
uint32_t orig_freq = 0;

void print_wakeup_reason() {
esp_sleep_wakeup_cause_t wakeup_reason;
Expand Down Expand Up @@ -86,17 +89,17 @@ void setup_uart() {
esp_sleep_enable_uart_wakeup(UART_NUM_0);
}



void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}

orig_freq = getCpuFrequencyMhz();

//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
boot_count++;
Serial.println("Boot number: " + String(boot_count));

//Print the wakeup reason for ESP32
print_wakeup_reason();
Expand Down Expand Up @@ -138,6 +141,10 @@ void loop() {
} else if (command == "timer_light") {
// Test timer wakeup from light sleep
setup_timer();
} else if (command == "timer_freq_light") {
// Test timer wakeup from light sleep while changing CPU frequency
setCpuFrequencyMhz(TARGET_FREQ);
setup_timer();
} else if (command == "touchpad_light") {
// Test touchpad wakeup from light sleep
setup_touchpad();
Expand All @@ -163,5 +170,6 @@ void loop() {
print_wakeup_reason();
Serial.flush();
gpio_hold_dis(WAKEUP_GPIO);
setCpuFrequencyMhz(orig_freq);
}
}
8 changes: 4 additions & 4 deletions tests/validation/sleep/test_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_sleep(dut):
dut.write("aaa") # Send 9 positive edges
dut.expect_exact("Woke up from light sleep")
dut.expect_exact("Wakeup reason: {}".format(capability))




if capability == "timer":
dut.write("timer_freq_light")
dut.expect_exact("Woke up from light sleep")
dut.expect_exact("Wakeup reason: timer")

0 comments on commit 4ddcd08

Please sign in to comment.