We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
It seems that we have to use the second para "info" in os_tmr_create (xx, info)to distinct which usr timer callback funtion is called.
#define Timer1CallBackFn1 1 #define Timer2CallBackFn2 2 #define TimerInterval1 10 #define TimerInterval2 15 tmr1 = os_tmr_create (TimerInterval1, Timer1CallBackFn1 ); if (tmr1 == NULL) { printf ("Failed to create user timer1.\n"); } tmr2 = os_tmr_create (TimerInterval2, Timer2CallBackFn2 ); if (tmr2 == NULL) { printf ("Failed to create user timer2.\n"); }
Then, we have to modify rtx_confg.c as following:
void os_tmr_call (U16 info) { /* This function is called when the user timer has expired. Parameter */ /* 'info' holds the value, defined when the timer was created. */ /* HERE: include optional user code to be executed on timeout. */ switch(info) { case Timer1CallBackFn1 : //add code here printf("Timer1 expired!\n"); break; case Timer1CallBackFn1 : //add code here printf("Timer2 expired!\n"); break; default: break; } }
So,We can create different Usr timer and its callback funtions, is it ok?
In fact, it is best to do this:
os_tmr_create (TimerInterval, TimerCallBackFn );
Where TimerCallBackFn is a usr function address.