summaryrefslogtreecommitdiff
path: root/ports/stm32/softtimer.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-04-27 16:30:58 +1000
committerDamien George <damien@micropython.org>2021-04-29 16:54:35 +1000
commit89b64478c73d2228419e77a4450c004157ec725a (patch)
treeab96181b33c920814e318fc4d3646b1ea3ee77cc /ports/stm32/softtimer.c
parent326dd7f0dbbadc4a536636d486600ce93dade8c5 (diff)
stm32/softtimer: Add support for having a C-based callback.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/stm32/softtimer.c')
-rw-r--r--ports/stm32/softtimer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/stm32/softtimer.c b/ports/stm32/softtimer.c
index d0a186c7d..7e439d4e7 100644
--- a/ports/stm32/softtimer.c
+++ b/ports/stm32/softtimer.c
@@ -64,7 +64,11 @@ void soft_timer_handler(void) {
while (heap != NULL && TICKS_DIFF(heap->expiry_ms, ticks_ms) <= 0) {
soft_timer_entry_t *entry = heap;
heap = (soft_timer_entry_t *)mp_pairheap_pop(soft_timer_lt, &heap->pairheap);
- mp_sched_schedule(entry->callback, MP_OBJ_FROM_PTR(entry));
+ if (entry->flags & SOFT_TIMER_FLAG_PY_CALLBACK) {
+ mp_sched_schedule(entry->py_callback, MP_OBJ_FROM_PTR(entry));
+ } else {
+ entry->c_callback(entry);
+ }
if (entry->mode == SOFT_TIMER_MODE_PERIODIC) {
entry->expiry_ms += entry->delta_ms;
heap = (soft_timer_entry_t *)mp_pairheap_push(soft_timer_lt, &heap->pairheap, &entry->pairheap);