-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[beken-72xx] Fix GPIO deep sleep wakeup edge #159
[beken-72xx] Fix GPIO deep sleep wakeup edge #159
Conversation
Users' comments from the esphome PR confirms it worked for them when the logic was reverted. Also the |
How do I actually test it? Something doesn't work for me. #include <Arduino.h>
void setup() {
pinMode(14, INPUT);
// pinMode(14, OUTPUT);
// while (true) {
// digitalWrite(14, HIGH);
// delay(1000);
// digitalWrite(14, LOW);
// delay(1000);
// yield();
// }
}
void loop() {
Serial.println("Waking up on HIGH...");
lt_deep_sleep_config_gpio(1 << 14, true);
lt_deep_sleep_enter();
Serial.println("Wake up successful!");
delay(2000);
Serial.println("Waking up on LOW...");
lt_deep_sleep_config_gpio(1 << 14, false);
lt_deep_sleep_enter();
Serial.println("Wake up successful!");
delay(2000);
}
I uploaded this test program, and it gets stuck on |
Are you sure it's not coming out? |
Oh. You're right, obviously - I haven't been too familiar with deep sleep at all. Still, I was getting no messages at all after the deep sleep. Turns out, that deep sleep deactivates UART1 and UART2 - which are not activated back after waking up. Since LibreTiny doesn't initialize these peripherals upon reboot (and since I didn't add I added |
Yeah that works... GPIO wakeup is inverted, as per this PR. Thanks! One odd thing is that HIGH wakeup doesn't set the reset reason correctly... I [ 0.000] LibreTiny v1.2.1+sha.f387138.dirty on generic-bk7231n-qfn32-tuya, compiled at Aug 23 2023 15:33:27, GCC 10.3.1 (-O1)
I [ 0.000] Reset reason: Power-On
// lt_deep_sleep_config_gpio(1 << 14, false);
Waking up on LOW...
I [ 0.000] LibreTiny v1.2.1+sha.f387138.dirty on generic-bk7231n-qfn32-tuya, compiled at Aug 23 2023 15:33:27, GCC 10.3.1 (-O1)
I [ 0.000] Reset reason: Sleep Wakeup
// lt_deep_sleep_config_gpio(1 << 14, true);
Waking up on HIGH...
I [ 0.000] LibreTiny v1.2.1+sha.f387138.dirty on generic-bk7231n-qfn32-tuya, compiled at Aug 23 2023 15:33:27, GCC 10.3.1 (-O1)
I [ 0.000] Reset reason: Power-On
// lt_deep_sleep_config_timer(1000);
Waking up in 1000 ms...
I [ 0.000] LibreTiny v1.2.1+sha.f387138.dirty on generic-bk7231n-qfn32-tuya, compiled at Aug 23 2023 15:33:27, GCC 10.3.1 (-O1)
I [ 0.000] Reset reason: Sleep Wakeup |
Manufacturer docs: https://docs-bekencorp-com.translate.goog/sdk_3.0.x/bk7238/html/developer-guide/power_save/sleep_test.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=hu&_x_tr_pto=wapp
Discussion: libretiny-eu/libretiny-esphome#11