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
[photon2] fix GPIOs sleep configuration. #2666
Conversation
@@ -249,8 +249,31 @@ void configureDeepSleepWakeupSource(const hal_sleep_config_t* config) { | |||
|
|||
// Copy and paste from SOCPS_DeepSleep_RAM() | |||
void enterDeepSleep() { | |||
#if PLATFORM_ID == PLATFORM_P2 | |||
// dirty-hack for Photon2 D7: PA27 (SWD-DIO) | |||
uint32_t bitMask = 1 << 27; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other pins at risk of this behavior or is this just because of how the SWD pin is configured in the SDK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested other normal GPIOs and they behave as expected. But when configuring D6 as GPIO, which is originally SWD-CLK, the D7 is also affected, because SWD is disabled and its pin state is not defined, which results in power leakage as well. I'll make some changes to fix it.
@scott-brust I re-tested the PR against the app you posted above and it worked fine. Below is when the D7 is configured as output and output low (5s delay + 10s sleep): Below is when D7 is configured as SWD (5s delay + 10s sleep): |
I re-tested today, and everything seems to work 🤷♂️ , here is D7 remaining low while Hibernating. I added a 1s pulse just to make sure the IO was actually working: When configured as SWD, it remained low through Hibernate as well. I also confirmed I was able to attach SWD when the device waked, so the pin re-configuration to SWD works as well. I also checked with the OTII and before in Hibernate I was measuring 115 uA. With these changes its down to 108 uA. Does this match with what you would expect? |
Instresting finding, when GPIO is configured as OUTPUT, the pull up/down resistor is not set as expected and it remains the previous setting:
|
@@ -103,3 +103,7 @@ | |||
|
|||
// Read-only charge indicator pin for Photon2 | |||
#define CHG S5 | |||
|
|||
// Set it to PIN_INVALID if not present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scott-brust need to define these pins for msom.
Will do the same tests on MSoM and see if problems are producable without the patch. |
Unfortunately when GPIOs are configured as output, the internal pad is actually shutdown during hibernate mode. Configuring pull-up/down resitor just maintain the level on the pin without any load. If there is load on the pin, then it won't work as expected. I have confirmed with Realtek FAE and requested them to provide a patch if possible. |
Problem
All GPIOs cannot remainAll GPIOs are actually shutdown in hibernate mode.HIGH
in hibernate mode if they are configured as outputHIGH
.LOW
in hibernate mode if it is configured as outputLOW
.Solution
Enable pull-up when a pin is configured as outputHIGH
and restore default when outputLOW
.Example
References
N/A
Completeness