MTK platform timer Message Processing Mechanism

Source: Internet
Author: User

MTKPlatformTimerMessage Processing Mechanism is the content to be introduced in this article, mainly to understand and learnMTKMediumTimerFor more information, see the implementation of the specific content.

Send timer messages

(1). Steps

StartTimer-> L4StartTimer

(2). Two types of Timer

MTKThere are two types of Timer

A. NO_ALIGNMENT

Non-queue type, that is, the timer that requires immediate execution. When the time is reached, the timer is automatically reset.

B. ALIGNMENT

Queue type, that is, the timer with a certain latency tolerance can be operated through the queue. y

The basic execution process is: Execution timer --> timeout? --> Save timerid and eventid -- timerstop | noevent? ----> END;

 
 
  1. |YN|  
  2.  
  3. ||  
  4.  
  5. ---------------------------------------------------------- 

C. In addition to touch screen and handwriting, the timer in other cases is generally queue-type.

(3). Functions of L4StartTimer

Determine the ID of the timer to be sent, and pass it to different queue structures (event_sheduler1/event_sheduler2) based on the queue type );

(4). TimerExpiry

This is the callback function passed to L4StartTimer as a parameter. Because MTK is encapsulated, the internal callback trigger process is specific.

I cannot know, but according to the speculation, it should be at the scheduled time, send the message in the form of interruption (MSG_ID_TIMER_EXPIRY), and write it to the MMI loop queue.

This function may be called in L4CallBackTimer. The functions of L4CallBackTimer are as follows:

A. Reset the currentTimerInformation Structure (mmi_frm_timer_type );

B. Execute the timer-to-point execution function (TimerExpiry );

C. Write the Timer message to the MMI cyclic queue.

StopTimer corresponding to StartTimer

(1). Call the L4StopTimer operation.

(2) Purpose: Find the position of the specified timer ID in the queue, and then delete the specified timer node from the queue using evshed_cancel_event.

Processing of timer messages

(1). Steps

...-> Create MMITask-> set the MMITask entry function-> call EvshedMMITimerHandler

(2). evshed_timer_handler ()-> process specific timer events

Simple AnalysisMTK TimerMessage events are a lot of errors due to simple analysis. If you forget to forgive me, you will not be right.

MTK timer message processorSystem

I. Basic Concepts and Neclus kernel timer Initialization

Expires: specifies the time when the timer expires. This time is expressed as the number of clock tick times since the system starts ). When the expires value of a timer is smaller than or equal to the jiffies variable, we will say that the timer has timed out or expired. After a timer is initialized, The expires field is usually set to the current value of the current expires variable plus a time interval value, which is counted by the number of times the clock is ticking.

 
 
  1. typedefstructtimertable  
  2. {/*storethetimer_id.MSB(MostSignificantBit)isalign_timer_mask*/  
  3. U16timer_id[SIMULTANEOUS_TIMER_NUM];  
  4. /*storetheevent_idthatreturnsfromevshed_set_event()*/  
  5. eventidevent_id[SIMULTANEOUS_TIMER_NUM];  
  6. /*storethetimer_expiry_func*/  
  7. oslTimerFuncPtrcallback_func[SIMULTANEOUS_TIMER_NUM];  
  8. /*pointtothenextTIMERTABLEdata*/  
  9. structtimertable*next;  
  10. }TIMERTABLE;  
  11. typedeflcd_dll_node*eventid;  
  12. structlcd_dll_node{  
  13. void*data;  
  14. lcd_dll_node*prev;  
  15. lcd_dll_node*next;  
  16. }; 

1) timer_id: a maximum of 12 timer IDs.

2) two-way linked list element event_id: used to separate multipleTimerThe scheduling action is connected to a two-way cyclic queue.

3) function pointer callback_func: points to an executable function. When the timer expires, the kernel executes the function specified by the function to generate the expires message.

 
 
  1. //L4initthetimer  
  2. /*****************************************************************************  
  3. *FUNCTION  
  4. *L4InitTimer  
  5. *DESCRIPTION  
  6. *Thisfunctionistoinitthetimerwhiletaskcreate.  
  7. *  
  8. *PARAMETERS  
  9. *aINvoid  
  10. *RETURNS  
  11. *VOID.  
  12. *GLOBALSAFFECTED  
  13. *external_global  
  14. *****************************************************************************/  
  15. voidL4InitTimer(void)  
  16. {  
  17. /*----------------------------------------------------------------*/  
  18. /*LocalVariables*/  
  19. /*----------------------------------------------------------------*/  
  20. TIMERTABLE*p;  
  21. TIMERTABLE*pp;  
  22. /*----------------------------------------------------------------*/  
  23. /*CodeBody*/  
  24. /*----------------------------------------------------------------*/  
  25. /*TrytofreeTIMERTABLElistexcludeg_timer_table*/  
  26. p=g_timer_table.next;  
  27. pp=NULL;  
  28. do  
  29. {  
  30. if(p!=NULL)  
  31. {  
  32. ppp=p->next;  
  33. OslMfree(p);  
  34. }  
  35. p=pp;  
  36. }while(p!=NULL);  
  37. /*resetg_timer_talbe*/  
  38. memset(&g_timer_table,0,sizeof(TIMERTABLE));  
  39. g_timer_table_size=SIMULTANEOUS_TIMER_NUM;  
  40. g_timer_table_used=0;  
  41. /*Initiatetheclocktimecallbackfunction.*/  
  42. get_clocktime_callback_func=NULL;  
  43. set_clocktime_callback_func=NULL;  
  44. /*Initatethenoalignmentstacktimer*/  
  45. stack_init_timer(&base_timer1,"MMI_Base_Timer1",MOD_MMI);  
  46. /*Createanoalignmenttimerschedule*/  
  47. event_scheduler1_ptr=new_evshed(&base_timer1,  
  48. L4StartBaseTimer,L4StopBaseTimer,  
  49. 0,kal_evshed_get_mem,kal_evshed_free_mem,0);  
  50. /*Initatethealignmentstacktimer*/  
  51. stack_init_timer(&base_timer2,"MMI_Base_Timer2",MOD_MMI);  
  52. /*Createanalignmenttimerschedule*/  
  53. event_scheduler2_ptr=new_evshed(&base_timer2,  
  54. L4StartBaseTimer,L4StopBaseTimer,  
  55. 0,kal_evshed_get_mem,kal_evshed_free_mem,255);  
  56. }  
  57. typedefstructstack_timer_struct_t{  
  58. module_typedest_mod_id;  
  59. kal_timeridkal_timer_id;  
  60. kal_uint16timer_indx;  
  61. stack_timer_status_typetimer_status;  
  62. kal_uint8invalid_time_out_count;  
  63. }stack_timer_struct;  
  64. /*************************************************************************  
  65. *ExportedFunctionPrototypes  
  66. *************************************************************************/  
  67. /*  
  68. *Important:  
  69. *Currentimplementationmax_delay_ticks_disibledevent="text-indent:24pt;line-height:150%"align="left"> 

Summary:

MTKPlatformTimerThe content of the message processing mechanism has been introduced. I hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.