diff options
| author | Damien George <damien.p.george@gmail.com> | 2017-02-15 23:04:53 +1100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2017-03-20 15:20:26 +1100 |
| commit | a5159edc2090a5670c33a829d7e54ab2ba8635c4 (patch) | |
| tree | 036b854990ce272ec39f6d7605452ad13b34a3fd /stmhal/timer.c | |
| parent | c138b21cebfa1a32e9911c1424aa1016c679463b (diff) | |
stmhal: Enable micropython.schedule().
ExtInt, Timer and CAN IRQ callbacks are made to work with the scheduler.
They are still hard IRQs by default, but one can now call
micropython.schedule within the hard IRQ to schedule a soft callback.
Diffstat (limited to 'stmhal/timer.c')
| -rw-r--r-- | stmhal/timer.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c index 494045c28..7f0a70c5e 100644 --- a/stmhal/timer.c +++ b/stmhal/timer.c @@ -1363,6 +1363,7 @@ STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_o // execute callback if it's set if (callback != mp_const_none) { + mp_sched_lock(); // When executing code within a handler we must lock the GC to prevent // any memory allocations. We must also catch any exceptions. gc_lock(); @@ -1382,6 +1383,7 @@ STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_o mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); } gc_unlock(); + mp_sched_unlock(); } } } |
