任何一个任务必须包含初始化和处理函数(即ProcessEvent),其具体信息如下:
Any OSAL Task must implement two methods:one to perform task initialization and the other to handle task
events.
1.2.5.1 Task Initialization
The callback function to perform task initialization is named like this in the sample applications: “Application
Name”_Init (e.g. GenericApp_Init). The task initialization function should accomplish the following:
- Initialization of variables local to or specific for the corresponding Application Object(s). Any long-lived heap memory allocation should be made in order to facilitate more efficient heap memory
management by the OSAL.
- Instantiation of the corresponding Application Object(s) by registering with the AF layer (e.g.
afRegister()).
- Registration with the applicable OSAL or HAL system services (e.g.RegisterForKeys()).
1.2.5.2 Task Event Handler
The callback function to handle task events is named like this in the sample applications: “Application
Name”_ProcessEvent (e.g. GenericApp_ProcessEvent()). Any OSAL Task can define up to 15 events in
addition to the mandatory event.