rp2/modmachine: Make lightsleep preserve SLEEP_EN0 and SLEEP_EN1.
The problem was introduced in d1423ef7a2,
calling `machine.lightsleep()` overwrites RP2xxx registers `SLEEP_EN0` and
`SLEEP_EN1` with their power on default values.
Prior to that commit the register values were saved on entry to lightsleep
and restored before returning.
These changes restores the earlier behavior.
Fixes issue #16502.
Signed-off-by: Carl Pottle <cpottle9@outlook.com>
This commit is contained in:
parent
112f657765
commit
55ae597bb6
1 changed files with 4 additions and 2 deletions
|
|
@ -196,6 +196,8 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
|||
#endif
|
||||
xosc_dormant();
|
||||
} else {
|
||||
uint32_t save_sleep_en0 = clocks_hw->sleep_en0;
|
||||
uint32_t save_sleep_en1 = clocks_hw->sleep_en1;
|
||||
bool timer3_enabled = irq_is_enabled(3);
|
||||
|
||||
const uint32_t alarm_num = 3;
|
||||
|
|
@ -251,8 +253,8 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
|||
if (!timer3_enabled) {
|
||||
irq_set_enabled(irq_num, false);
|
||||
}
|
||||
clocks_hw->sleep_en0 |= ~(0u);
|
||||
clocks_hw->sleep_en1 |= ~(0u);
|
||||
clocks_hw->sleep_en0 = save_sleep_en0;
|
||||
clocks_hw->sleep_en1 = save_sleep_en1;
|
||||
}
|
||||
|
||||
// Enable ROSC.
|
||||
|
|
|
|||
Loading…
Reference in a new issue