|
楼主 |
发表于 2007-11-12 21:24:09
|
显示全部楼层
还是关于定时器的问题:
void L4StartTimer(
unsigned short nTimerId,
oslTimerFuncPtr TimerExpiry,
void *funcArg,
unsigned long nTimeDuration,
unsigned char alignment)
这个函数中的void *funcArg能否用来传输CallBack函数中的参数呢?
此函数原来的实现是这样的:
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
TIMERTABLE *pTable = NULL;
U16 i = 0;
U32 temp;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (TimerExpiry == NULL)
{ /* If TimerExpiry is NULL, we don't start the timer */
MMI_ASSERT(0);
return;
}
MMI_ASSERT(nTimerId < MAX_TIMERS);
if (L4TimerUsePreciseTick(nTimerId))
{
temp = (nTimeDuration * KAL_TICKS_10_MSEC) / 10;
if (temp == 0)
{
temp = KAL_TICKS_10_MSEC;
}
alignment = TIMER_IS_NO_ALIGNMENT;
}
else
{
if (nTimeDuration == 1000)
{
temp = KAL_TICKS_1_SEC - 4;
}
else
{
temp = (U32)((nTimeDuration / 5) * MMI_TICKS_5_MSEC);
}
if (temp == 0)
{
/* Cause by by rounding. If expire immediately, MoDIS boot-up failure because MMI keeps running and block NVRAM task */
temp = (U32)MMI_TICKS_5_MSEC;
}
} /* if (L4TimerUsePreciseTick(nTimerId)) */
MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_L4DRV_STARTTIMER_HDLR, nTimerId, TimerExpiry, temp, alignment));
pTable = &g_timer_table;
if (g_timer_table_used >= g_timer_table_size)
{
/*
* TIMERTABLE list doesn't have enough space, allocate the memory
*
* If we need to allocate the memeory, it means that MMI may have
* such many timers run simultaneously. We won't free the memory
* after we allocate more memory in TIMERTABLE list.
*/
do
{
if (pTable->next == NULL)
{
pTable->next = OslMalloc(sizeof(TIMERTABLE));
memset(pTable->next, 0, sizeof(TIMERTABLE));
g_timer_table_size += SIMULTANEOUS_TIMER_NUM;
pTable = pTable->next;
i = 0;
break;
}
pTable = pTable->next;
} while (pTable != NULL);
}
else
{
/* find the empty record in g_timer_table list */
i = 0;
do
{
if (pTable->event_id == NULL)
{ /* find the empty space */
break;
}
i++;
if (i >= SIMULTANEOUS_TIMER_NUM)
{
pTable = pTable->next;
i = 0;
}
} while (pTable != NULL);
if (pTable == NULL)
{
/* Can't find the empty space in TIMERTABLE list, assert!!! */
MMI_ASSERT(0);
}
} /* if (g_timer_table_used >= g_timer_table_size) */
/*
* already find the empty record, and then start timer
*
* event_sheduler1 = NO alignment scherulder
* event_sheduler2 = alignment scherulder (low power)
*/
if (alignment == TIMER_IS_NO_ALIGNMENT)
{
/* MSB(Most Significant Bit) is align_timer_mask */
pTable->timer_id = nTimerId | NO_ALIGNMENT_TIMER_MASK;
pTable->event_id = evshed_set_event(
event_scheduler1_ptr,
(kal_timer_func_ptr) L4CallBackTimer,
(void*)nTimerId,
temp);
pTable->callback_func = TimerExpiry;
g_timer_table_used++;
}
else if (alignment == TIMER_IS_ALIGNMENT)
{
/* MSB(Most Significant Bit) is align_timer_mask */
pTable->timer_id = nTimerId | ALIGNMENT_TIMER_MASK;
pTable->event_id = evshed_set_event(
event_scheduler2_ptr,
(kal_timer_func_ptr) L4CallBackTimer,
(void*)nTimerId,
temp);
pTable->callback_func = TimerExpiry;
g_timer_table_used++;
}
我想通过改写其中的内容,如改写evshed_set_event的调用来实现上述的传输CB函数的参数的功能,不知道行不? |
|