From 1da2708a7c48c144605d84da94d0184209713683 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 9 Oct 2019 17:22:48 -0500 Subject: Fix timer Agptek Rocker (other hosted players) on timer_unregister callbacks are not removed It seems (at least on the Rocker) timers continue to fire (for a bit??) Now we store the registered callback in the sigev structure and check that the callback matches the one registered when the timer is created. This should stop the possible case of a new timer getting spurious callbacks We also now NULL the callbacks on un-register which should stop the segfaults Added some notes to timer.c and timer.h Change-Id: Ia155c3a4e4af89f474d55ed845560ccc1fab85aa --- firmware/export/timer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'firmware/export/timer.h') diff --git a/firmware/export/timer.h b/firmware/export/timer.h index b12ec55881..92b26db216 100644 --- a/firmware/export/timer.h +++ b/firmware/export/timer.h @@ -30,6 +30,7 @@ #define TIMER_FREQ 1000000 #endif +/* NOTE: if unreg cb is defined you are in charge of calling timer_unregister() */ bool timer_register(int reg_prio, void (*unregister_callback)(void), long cycles, void (*timer_callback)(void) IF_COP(,int core)); @@ -37,6 +38,10 @@ bool timer_set_period(long cycles); #ifdef CPU_COLDFIRE void timers_adjust_prescale(int multiplier, bool enable_irq); #endif + +/* NOTE: unregister callbacks are not called by timer_unregister() +* the unregister_callback only gets called when your timer gets +* overwritten by a lower priority timer using timer_register() */ void timer_unregister(void); /* target-specific interface */ -- cgit v1.2.3