27
27
#include "supervisor/shared/tick.h"
28
28
29
29
#include "py/mpstate.h"
30
+ #include "py/runtime.h"
30
31
#include "supervisor/linker.h"
31
32
#include "supervisor/filesystem.h"
32
33
#include "supervisor/background_callback.h"
36
37
37
38
#if CIRCUITPY_BLEIO
38
39
#include "supervisor/shared/bluetooth.h"
39
- #include "common-hal/_bleio/bonding .h"
40
+ #include "common-hal/_bleio/__init__ .h"
40
41
#endif
41
42
42
43
#if CIRCUITPY_DISPLAYIO
@@ -68,6 +69,8 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
68
69
69
70
static background_callback_t tick_callback ;
70
71
72
+ volatile uint64_t last_finished_tick = 0 ;
73
+
71
74
void supervisor_background_tasks (void * unused ) {
72
75
port_start_background_task ();
73
76
@@ -84,7 +87,7 @@ void supervisor_background_tasks(void *unused) {
84
87
85
88
#if CIRCUITPY_BLEIO
86
89
supervisor_bluetooth_background ();
87
- bonding_background ();
90
+ bleio_background ();
88
91
#endif
89
92
90
93
port_background_task ();
@@ -95,7 +98,7 @@ void supervisor_background_tasks(void *unused) {
95
98
}
96
99
97
100
bool supervisor_background_tasks_ok (void ) {
98
- return port_get_raw_ticks (NULL ) - get_background_ticks () < 1024 ;
101
+ return port_get_raw_ticks (NULL ) - last_finished_tick < 1024 ;
99
102
}
100
103
101
104
void supervisor_tick (void ) {
@@ -145,17 +148,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
145
148
while (remaining > 0 ) {
146
149
RUN_BACKGROUND_TASKS ;
147
150
// Check to see if we've been CTRL-Ced by autoreload or the user.
148
- if (MP_STATE_VM (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )))
149
- {
150
- // clear exception and generate stacktrace
151
- MP_STATE_VM (mp_pending_exception ) = MP_OBJ_NULL ;
152
- nlr_raise (& MP_STATE_VM (mp_kbd_exception ));
153
- }
154
- if ( MP_STATE_VM (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception )) ||
155
- WATCHDOG_EXCEPTION_CHECK ()) {
156
- // stop sleeping immediately
157
- break ;
158
- }
151
+ mp_handle_pending ();
159
152
remaining = end_tick - port_get_raw_ticks (NULL );
160
153
// We break a bit early so we don't risk setting the alarm before the time when we call
161
154
// sleep.
0 commit comments