restore rp2040 sleep clocks after explicit light sleep #10018
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On RP2040,
light_sleep_until_alarms()
would turn off some clocks during the light sleep by clearing some bits inclocks_hw->sleep_en0
andclocks_hw->sleep_en1
. Those clocks are turned off when awfi()
orwfe()
happens. Butlight_sleep_until_alarms()
failed to restore the original values of those registers after a light sleep. So the next time awfi()
orwfe()
was used, even not during an explicit light sleep, those clocks would get turned off. This caused the clocks to go off duringtime.sleep()
(which useswfi()
), for instance.To fix, I saved and restored the register values.
Tested with a simplified version of the program in #8561 (I just put an LED on A1).