diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 7dc5a52d32..0be3230823 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -24,14 +24,12 @@ * THE SOFTWARE. */ -#include - #include "supervisor/shared/tick.h" #include "supervisor/filesystem.h" #include "supervisor/shared/autoreload.h" -static atomic_bool tick_up; static volatile uint64_t ticks_ms; +static volatile uint32_t background_ticks_ms32; #if CIRCUITPY_GAMEPAD #include "shared-module/gamepad/__init__.h" @@ -47,8 +45,6 @@ void supervisor_tick(void) { ticks_ms ++; - atomic_store(&tick_up, true); - #if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 filesystem_tick(); #endif @@ -82,7 +78,14 @@ uint32_t supervisor_ticks_ms32() { extern void run_background_tasks(void); void supervisor_run_background_tasks_if_tick() { - if (atomic_exchange(&tick_up, false)) { - run_background_tasks(); + uint32_t now32 = ticks_ms; + + if (now32 == background_ticks_ms32) { + return; } + background_ticks_ms32 = now32; + + run_background_tasks(); +} + } diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h index b662734492..eb2af29ca4 100644 --- a/supervisor/shared/tick.h +++ b/supervisor/shared/tick.h @@ -28,7 +28,6 @@ #define __INCLUDED_SUPERVISOR_TICK_H #include -#include extern void supervisor_tick(void); extern uint32_t supervisor_ticks_ms32(void);