File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
ports/raspberrypi/supervisor Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -716,9 +716,15 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
716
716
717
717
// time_to_next_change is in ms and ticks are slightly shorter so
718
718
// we'll undersleep just a little. It shouldn't matter.
719
- port_interrupt_after_ticks (time_to_next_change );
720
- #endif
719
+ if (time_to_next_change > 0 ) {
720
+ port_interrupt_after_ticks (time_to_next_change );
721
+ port_idle_until_interrupt ();
722
+ }
723
+ #else
724
+ // No status LED can we sleep until we are interrupted by some
725
+ // interaction.
721
726
port_idle_until_interrupt ();
727
+ #endif
722
728
}
723
729
}
724
730
Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ uint32_t port_get_saved_word(void) {
257
257
}
258
258
259
259
static volatile bool ticks_enabled ;
260
+ static volatile bool _woken_up ;
260
261
261
262
uint64_t port_get_raw_ticks (uint8_t * subticks ) {
262
263
uint64_t microseconds = time_us_64 ();
@@ -268,6 +269,7 @@ STATIC void _tick_callback(uint alarm_num) {
268
269
supervisor_tick ();
269
270
hardware_alarm_set_target (0 , delayed_by_us (get_absolute_time (), 977 ));
270
271
}
272
+ _woken_up = true;
271
273
}
272
274
273
275
// Enable 1/1024 second tick.
@@ -291,11 +293,12 @@ void port_interrupt_after_ticks(uint32_t ticks) {
291
293
if (!ticks_enabled ) {
292
294
hardware_alarm_set_target (0 , delayed_by_us (get_absolute_time (), ticks * 977 ));
293
295
}
296
+ _woken_up = false;
294
297
}
295
298
296
299
void port_idle_until_interrupt (void ) {
297
300
common_hal_mcu_disable_interrupts ();
298
- if (!background_callback_pending () && !tud_task_event_ready ()) {
301
+ if (!background_callback_pending () && !tud_task_event_ready () && ! _woken_up ) {
299
302
__DSB ();
300
303
__WFI ();
301
304
}
You can’t perform that action at this time.
0 commit comments