|
MTK定时器消息处理机制
一、基本概念及Neclus内核定时器初始化
?expires:指定定时器到期的时间,这个时间被表示成自系统启动以来的时钟滴答计数(也即时钟节拍数)。当一个定时器的expires值小于或等于jiffies变量时,我们就说这个定时器已经超时或到期了。在初始化一个定时器后,通常把它的expires域设置成当前expires变量的当前值加上某个时间间隔值(以时钟滴答次数计。
typedef struct timertable
{???? /* store the timer_id. MSB(Most Significant Bit) is align_timer_mask */
?????? U16 timer_id[SIMULTANEOUS_TIMER_NUM];
?????? /* store the event_id that returns from evshed_set_event() */
?????? eventid event_id[SIMULTANEOUS_TIMER_NUM];
?????? /* store the timer_expiry_func */
?????? oslTimerFuncPtr callback_func[SIMULTANEOUS_TIMER_NUM];
?????? /* point to the next TIMERTABLE data */
?????? struct timertable *next;
} TIMERTABLE;
typedef lcd_dll_node *eventid;
?struct lcd_dll_node {
?? void??????????? *data;
?? lcd_dll_node??? *prev;
?? lcd_dll_node??? *next;
};
(1)timer_id:定时器id多同时12个。
(2)双向链表元素event_id:用来将多个定时器调度动作连接成一条双向循环队列。
(3)函数指针callback_func:指向一个可执行函数。当定时器到期时,内核就执行function所指定的函数,产生expires 消息。
//L4 init the timer
/*****************************************************************************
* FUNCTION
* L4InitTimer
* DESCRIPTION
*?? This function is to init the timer while task create.
*
* PARAMETERS
* a IN???? void
* RETURNS
* VOID.
* GLOBALS AFFECTED
*?? external_global
*****************************************************************************/
void L4InitTimer(void)
{
?? /*----------------------------------------------------------------*/
?? /* Local Variables??????????????????????????????????????????????? */
?? /*----------------------------------------------------------------*/
? ?????TIMERTABLE?????? *p;
?????? TIMERTABLE?????? *pp;
??
?? /*----------------------------------------------------------------*/
?? /* Code Body????????????????????????????????????????????????????? */
?? /*----------------------------------------------------------------*/
?????? /* Try to free TIMERTABLE list exclude g_timer_table */
?????? p = g_timer_table.next;
?????? pp = NULL;
?????? do
?????? {????
????????????? if (p != NULL)
????????????? {
???????????????????? pp = p->next;
???????????????????? OslMfree(p);
????????????? }
????????????? p = pp;
?????? } while (p != NULL);
?????? /* reset g_timer_talbe */
?????? memset(&g_timer_table, 0, sizeof(TIMERTABLE));
?????? g_timer_table_size = SIMULTANEOUS_TIMER_NUM;
?????? g_timer_table_used = 0;
??? /* Initiate the clock time callback function. */
?? get_clocktime_callback_func = NULL;
?? set_clocktime_callback_func = NULL;
??? /* Initate the no alignment stack timer */
?????? stack_init_timer (&base_timer1, "MMI_Base_Timer1", MOD_MMI);
??? /* Create a no alignment timer schedule */
? event_scheduler1_ptr = new_evshed(&base_timer1,
?????????????????????????????????????????????????????????? L4StartBaseTimer, L4StopBaseTimer,
?????????????????????????????????????????????????????????? 0 , kal_evshed_get_mem, kal_evshed_free_mem, 0);
??? /* Initate the alignment stack timer */
?? stack_init_timer (&base_timer2, "MMI_Base_Timer2", MOD_MMI);
??? /* Create an alignment timer schedule */
?? event_scheduler2_ptr = new_evshed(&base_timer2,
???????????????????????? ??????????????????????????????????L4StartBaseTimer, L4StopBaseTimer,
????????????????????????????????????????????????????????? 0, kal_evshed_get_mem, kal_evshed_free_mem, 255);
}
typedef struct stack_timer_struct_t {
?????? module_type???????????? dest_mod_id;
?????? kal_timerid???????????? kal_timer_id;
?????? kal_uint16????????????? timer_indx;
?????? stack_timer_status_type timer_status;
?????? kal_uint8????????????? invalid_time_out_count;
} stack_timer_struct;
?/*************************************************************************
?* Exported Function Prototypes
?*************************************************************************/
/*
?* Important:
?* Current implementation max_delay_ticks _disibledevent="text-indent: 24pt; line-height: 150%" align="left">
|
|