38 #define MHEG_TIMER_MAGIC 0xc10c0000 43 #define MHEG_TIMER_MAX_WAIT 60000 51 #define MHEG_TIMER_ACCURACY 5 53 #define SIZEOF_TIMER_EVENT_MSG 1 54 #define MAX_NUM_TIMER_EVENT_MSG 100 89 static void *mhegTimerListMutex = 0;
90 static void *mhegTimerCountMutex = 0;
96 static void *mhegTimerUpdateEvent = 0;
99 static void *mhegTimerTaskHandle = 0;
110 static U16BIT mhegTimerIdentityCount = 0;
128 static void TimersMain(
void *pArg)
130 S32BIT eventWaitTimeout = 0;
136 mhegTimerTaskRunning =
TRUE;
138 while (!mhegTimerQuit)
150 while ((timerListHead != 0) && (timerListHead->
triggerTime <= sysTime))
155 pOldTimerInfo = timerListHead;
161 timerListHead = timerListHead->
next;
172 if (timerListHead == 0)
185 eventWaitTimeout = timerListHead->
triggerTime - sysTime;
206 mhegTimerTaskRunning =
FALSE;
238 if (!mhegTimerCountMutex || !mhegTimerListMutex)
245 if (pNewTimerInfo == 0)
267 ++mhegTimerIdentityCount;
275 if ((timerListHead == 0) ||
282 pNewTimerInfo->
next = timerListHead;
283 timerListHead = pNewTimerInfo;
298 pTimerInfo = timerListHead;
299 while ((pTimerInfo->
next != 0) &&
302 pTimerInfo = pTimerInfo->
next;
306 pNewTimerInfo->
next = pTimerInfo->
next;
307 pTimerInfo->
next = pNewTimerInfo;
330 timerHdl.
ptr = timerHandle;
333 if (mhegTimerListMutex == 0)
343 if (timerListHead == NULL)
351 pOldTimerInfo = timerListHead;
352 timerListHead = timerListHead->
next;
358 prevTimerInfo = timerListHead;
359 pTimerInfo = timerListHead->
next;
360 while (pTimerInfo != 0)
364 pOldTimerInfo = pTimerInfo;
365 prevTimerInfo->
next = pTimerInfo->
next;
368 prevTimerInfo = pTimerInfo;
369 pTimerInfo = pTimerInfo->
next;
409 if (mhegTimerTaskHandle != 0 && mhegTimerListMutex != 0)
418 TRACE(TKEYS, (
"mhegTimerListMutex=%d", mhegTimerListMutex))
419 if (mhegTimerListMutex == NULL)
424 TRACE(TKEYS, (
"mhegTimerCountMutex=%d", mhegTimerCountMutex))
425 if (mhegTimerCountMutex == NULL)
428 mhegTimerListMutex = 0;
436 if (mhegTimerUpdateEvent == NULL)
439 mhegTimerCountMutex = 0;
441 mhegTimerListMutex = 0;
449 mhegTimerQuit =
FALSE;
453 if (mhegTimerTaskHandle == NULL)
456 mhegTimerUpdateEvent = 0;
458 mhegTimerCountMutex = 0;
460 mhegTimerListMutex = 0;
479 if (!mhegTimerTaskHandle)
485 mhegTimerQuit =
TRUE;
488 if (mhegTimerTaskRunning)
493 while (mhegTimerTaskRunning)
499 mhegTimerTaskHandle = 0;
501 mhegTimerUpdateEvent = NULL;
505 if (mhegTimerListMutex != 0)
509 while (timerListHead != NULL)
513 pTimerInfo = timerListHead;
514 timerListHead = timerListHead->
next;
521 mhegTimerCountMutex = 0;
523 mhegTimerListMutex = 0;
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
E_MhegErr VT_TimerDestroy(H_Timer timerHandle)
Destroy the specified timer. A callback will not be invoked for this timer after this function return...
void STB_OSTaskDelay(U16BIT timeout)
Delay Task for Specifed Time Period.
#define MAX_NUM_TIMER_EVENT_MSG
E_MhegErr VT_TimerCreate(U32BIT millisecs, F_TimerCallback callback, void *callerRef, H_Timer *pTimerHandle)
Set a timer for a certain number of millseconds. When the timer expires a specified callback will be ...
void STB_OSDeleteMutex(void *mutex)
Delete a mutex.
struct s_timer_info S_TIMER_INFO
void(* F_TimerCallback)(BOOLEAN triggered, void *callerRef, H_Timer timerHandle)
BOOLEAN STB_OSDestroyQueue(void *queue)
Destroy Queue.
BOOLEAN STB_OSWriteQueue(void *queue, void *msg, U16BIT msg_size, U16BIT timeout)
Write a message to the queue.
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
#define SIZEOF_TIMER_EVENT_MSG
void * STB_OSCreateQueue(U16BIT msg_size, U16BIT msg_max)
Create Queue of given number of messages and size of message.
void * STB_OSCreateMutex(void)
Create a mutex.
BOOLEAN STB_OSReadQueue(void *queue, void *msg, U16BIT msg_size, U16BIT timeout)
Read a message from a queue.
E_MhegErr VT_TimersExit(void)
Uninitialise the timer component - all resources are freed. Other timer functions must not be called ...
struct s_timer_info * next
#define MHEG_TIMER_ACCURACY
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
The timer module allows the use of timers within the MHEG5 component. These timers can be set by othe...
E_MhegErr VT_TimersInit(U32BIT task_priority)
Initialise the timer component. This function must be called before any other timer functions are inv...
void * STB_OSCreateTask(void(*function)(void *), void *param, U32BIT stack, U8BIT priority, U8BIT *name)
Create a New Task to the calling process. Upon success, the created task runs on its own stack...
#define MHEG_TIMER_MAX_WAIT
void STB_OSDestroyTask(void *task)
Delete Task must be called upon termination of each task as it frees all OS specific resources alloca...
Header file - Function prototypes for operating system.