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) {
716716
717717 // time_to_next_change is in ms and ticks are slightly shorter so
718718 // 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.
721726 port_idle_until_interrupt ();
727+ #endif
722728 }
723729 }
724730
Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ uint32_t port_get_saved_word(void) {
257257}
258258
259259static volatile bool ticks_enabled ;
260+ static volatile bool _woken_up ;
260261
261262uint64_t port_get_raw_ticks (uint8_t * subticks ) {
262263 uint64_t microseconds = time_us_64 ();
@@ -268,6 +269,7 @@ STATIC void _tick_callback(uint alarm_num) {
268269 supervisor_tick ();
269270 hardware_alarm_set_target (0 , delayed_by_us (get_absolute_time (), 977 ));
270271 }
272+ _woken_up = true;
271273}
272274
273275// Enable 1/1024 second tick.
@@ -291,11 +293,12 @@ void port_interrupt_after_ticks(uint32_t ticks) {
291293 if (!ticks_enabled ) {
292294 hardware_alarm_set_target (0 , delayed_by_us (get_absolute_time (), ticks * 977 ));
293295 }
296+ _woken_up = false;
294297}
295298
296299void port_idle_until_interrupt (void ) {
297300 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 ) {
299302 __DSB ();
300303 __WFI ();
301304 }
You can’t perform that action at this time.
0 commit comments