From a15d1bb0021c837dff548d024e6f1904dbd559a9 Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Thu, 22 Sep 2016 16:56:06 +1000 Subject: [PATCH] timers: esp library timer callbacks expect their argument not a xTimerHandle (#221) --- open_esplibs/libmain/timers.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/open_esplibs/libmain/timers.c b/open_esplibs/libmain/timers.c index 4c1edb9..b30f6e3 100644 --- a/open_esplibs/libmain/timers.c +++ b/open_esplibs/libmain/timers.c @@ -60,11 +60,17 @@ void sdk_os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg) { *tailptr = new_entry; } +static void timer_tramp(xTimerHandle xTimer) +{ + ETSTimer *ptimer = pvTimerGetTimerID(xTimer); + ptimer->timer_func(ptimer->timer_arg); +} + void sdk_os_timer_arm(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag) { if (!ptimer->timer_handle) { ptimer->timer_repeat = repeat_flag; ptimer->timer_ms = milliseconds; - ptimer->timer_handle = xTimerCreate(0, milliseconds/10, repeat_flag, ptimer->timer_arg, ptimer->timer_func); + ptimer->timer_handle = xTimerCreate(0, milliseconds/10, repeat_flag, ptimer, timer_tramp); armed_timer_count++; if (!ptimer->timer_handle) { //FIXME: should print an error? (original code doesn't)