@@ -99,6 +99,25 @@ static inline void _sleep_run_from_lposc(void) {
99
99
}
100
100
#endif
101
101
102
+ #ifdef PICO_RP2040
103
+ // Light sleep turns off nonvolatile Busio and other wake-only peripherals.
104
+ // This does not save a considerable amount of current (~2mA), but
105
+ // it is only used during fake (USB-connected) LightSleep anyway.
106
+ const uint32_t RP_LIGHTSLEEP_EN0_MASK = ~(
107
+ CLOCKS_SLEEP_EN0_CLK_SYS_SPI1_BITS |
108
+ CLOCKS_SLEEP_EN0_CLK_PERI_SPI1_BITS |
109
+ CLOCKS_SLEEP_EN0_CLK_SYS_SPI0_BITS |
110
+ CLOCKS_SLEEP_EN0_CLK_PERI_SPI0_BITS |
111
+ CLOCKS_SLEEP_EN0_CLK_SYS_PWM_BITS |
112
+ CLOCKS_SLEEP_EN0_CLK_SYS_PIO1_BITS |
113
+ CLOCKS_SLEEP_EN0_CLK_SYS_PIO0_BITS |
114
+ CLOCKS_SLEEP_EN0_CLK_SYS_I2C1_BITS |
115
+ CLOCKS_SLEEP_EN0_CLK_SYS_I2C0_BITS |
116
+ CLOCKS_SLEEP_EN0_CLK_SYS_ADC_BITS |
117
+ CLOCKS_SLEEP_EN0_CLK_ADC_ADC_BITS
118
+ );
119
+ #endif
120
+
102
121
static dormant_source_t _dormant_source ;
103
122
104
123
// State of the serial connection
@@ -205,12 +224,13 @@ static void _sleep_goto_sleep_until(void) {
205
224
DEBUG_PRINT ("_sleep_goto_sleep_until" );
206
225
SLEEP (10 );
207
226
208
- clocks_hw -> sleep_en0 = CLOCKS_SLEEP_EN0_CLK_RTC_RTC_BITS ;
209
227
if (_serial_connected ) {
210
- DEBUG_PRINT ("serial connected: using sleep_en1 = CLOCKS_SLEEP_EN1_RESET " );
228
+ DEBUG_PRINT ("serial connected: using old clock-masks " );
211
229
SLEEP (10 );
230
+ clocks_hw -> sleep_en0 &= RP_LIGHTSLEEP_EN0_MASK ;
212
231
clocks_hw -> sleep_en1 = CLOCKS_SLEEP_EN1_RESET ;
213
232
} else {
233
+ clocks_hw -> sleep_en0 = CLOCKS_SLEEP_EN0_CLK_RTC_RTC_BITS ;
214
234
clocks_hw -> sleep_en1 = 0x0 ;
215
235
}
216
236
0 commit comments