|
MTK定時(shí)器消息處理機(jī)制
一、基本概念及Neclus內(nèi)核定時(shí)器初始化
?expires:指定定時(shí)器到期的時(shí)間,這個(gè)時(shí)間被表示成自系統(tǒng)啟動(dòng)以來(lái)的時(shí)鐘滴答計(jì)數(shù)(也即時(shí)鐘節(jié)拍數(shù))。當(dāng)一個(gè)定時(shí)器的expires值小于或等于jiffies變量時(shí),我們就說(shuō)這個(gè)定時(shí)器已經(jīng)超時(shí)或到期了。在初始化一個(gè)定時(shí)器后,通常把它的expires域設(shè)置成當(dāng)前expires變量的當(dāng)前值加上某個(gè)時(shí)間間隔值(以時(shí)鐘滴答次數(shù)計(jì)。
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:定時(shí)器id多同時(shí)12個(gè)。
(2)雙向鏈表元素event_id:用來(lái)將多個(gè)定時(shí)器調(diào)度動(dòng)作連接成一條雙向循環(huán)隊(duì)列。
(3)函數(shù)指針callback_func:指向一個(gè)可執(zhí)行函數(shù)。當(dāng)定時(shí)器到期時(shí),內(nèi)核就執(zhí)行function所指定的函數(shù),產(chǎn)生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">
|
|