File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ static void draw_object(mp_obj_t obj) {
93
93
async_stop ();
94
94
}
95
95
} else {
96
- MP_STATE_VM ( mp_pending_exception ) = mp_obj_new_exception_msg (& mp_type_TypeError , "not an image" );
96
+ mp_sched_schedule_exception ( mp_obj_new_exception_msg (& mp_type_TypeError , "not an image" ) );
97
97
async_stop ();
98
98
}
99
99
}
@@ -126,7 +126,7 @@ void microbit_display_update(void) {
126
126
if (mp_obj_get_type (nlr .ret_val ) == & mp_type_MemoryError ) {
127
127
mp_printf (& mp_plat_print , "Allocation in interrupt handler" );
128
128
}
129
- MP_STATE_VM ( mp_pending_exception ) = MP_OBJ_FROM_PTR (nlr .ret_val );
129
+ mp_sched_schedule_exception ( MP_OBJ_FROM_PTR (nlr .ret_val ) );
130
130
}
131
131
obj = MP_OBJ_STOP_ITERATION ;
132
132
}
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ STATIC void audio_data_fetcher(void) {
77
77
} else {
78
78
if (!mp_obj_is_subclass_fast (MP_OBJ_FROM_PTR (((mp_obj_base_t * )nlr .ret_val )-> type ),
79
79
MP_OBJ_FROM_PTR (& mp_type_StopIteration ))) {
80
- MP_STATE_VM ( mp_pending_exception ) = MP_OBJ_FROM_PTR (nlr .ret_val );
80
+ mp_sched_schedule_exception ( MP_OBJ_FROM_PTR (nlr .ret_val ) );
81
81
}
82
82
buffer_obj = MP_OBJ_STOP_ITERATION ;
83
83
}
@@ -89,7 +89,7 @@ STATIC void audio_data_fetcher(void) {
89
89
// Audio iterator did not return an AudioFrame
90
90
audio_source_iter = NULL ;
91
91
microbit_audio_stop ();
92
- MP_STATE_VM ( mp_pending_exception ) = mp_obj_new_exception_msg (& mp_type_TypeError , "not an AudioFrame" );
92
+ mp_sched_schedule_exception ( mp_obj_new_exception_msg (& mp_type_TypeError , "not an AudioFrame" ) );
93
93
} else {
94
94
microbit_audio_frame_obj_t * buffer = (microbit_audio_frame_obj_t * )buffer_obj ;
95
95
uint8_t * dest = & audio_output_buffer [0 ];
Original file line number Diff line number Diff line change 27
27
#include "py/runtime.h"
28
28
#include "py/mphal.h"
29
29
30
+ void mp_sched_schedule_exception (mp_obj_t exc ) {
31
+ MP_STATE_VM (mp_pending_exception ) = exc ;
32
+ if (MP_STATE_VM (sched_state ) == MP_SCHED_IDLE ) {
33
+ MP_STATE_VM (sched_state ) = MP_SCHED_PENDING ;
34
+ }
35
+ }
36
+
30
37
void mp_hal_delay_us (mp_uint_t us ) {
31
38
if (us <= 0 ) {
32
39
return ;
Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
27
+ #include "py/obj.h"
27
28
#include "microbithal.h"
28
29
29
30
// Not implemented and not exposed in utime module.
30
31
#define mp_hal_ticks_cpu () (0)
31
32
33
+ void mp_sched_schedule_exception (mp_obj_t exc );
32
34
void mp_hal_set_interrupt_char (int c );
33
35
34
36
// MicroPython low-level C API for pins
You can’t perform that action at this time.
0 commit comments