![]() |
ISF
1.1
Intelligent Sensing Framework
|
00001 /** 00002 * @file isf_init.h 00003 * @brief The \b isf_init.h file contains the task initialization attributes required for initialization of the following 00004 * ISF tasks: \n 00005 * @li ISF Initialization task 00006 * @li ISF Sensor Manager task 00007 * @li ISF Command Interpreter task 00008 * @li ISF Bus Manager task. 00009 * 00010 * 00011 * @copyright Copyright (c) 2012, Freescale Semiconductor, Inc. 00012 */ 00013 00014 #ifndef ISF_INIT_H_ 00015 #define ISF_INIT_H_ 00016 00017 #include "isf_user_config.h" 00018 #include "isf.h" 00019 #include <mqx.h> 00020 #include <lwevent.h> 00021 /*! 00022 * @brief Definition of the system ready event. 00023 */ 00024 #define ISF_SYSTEM_READY_EVENT (1<<1) 00025 /*! 00026 * @brief Definition of the event handle to the system ready event. 00027 */ 00028 extern LWEVENT_STRUCT isfSysEventHandler; 00029 /*! 00030 * @brief Definition of the base task priority for ISF tasks.<br> 00031 * \b Note: Task priority of all ISF tasks must be 00032 * set higher than user task priorities. <br> 00033 * \b Note: Lower numbers represent higher task priorities and 00034 * higher numbers represent lower priorities. 00035 */ 00036 #define ISF_TASK_PRIORITY (9) 00037 00038 /*! 00039 * @brief Definition of the task priority used by the lowest priority ISF task. <br> 00040 * \b Note: User tasks must be set to a higher priority level than the task priority 00041 * used by the lowest priority ISF task. <br> 00042 * \b Note: Lower numbers represent higher task priorities and 00043 * higher numbers represent lower priorities. 00044 * 00045 */ 00046 #define ISF_TASK_LOWEST_PRIORITY (20) 00047 00048 /*! 00049 * @brief Definition of the starting task index for ISF tasks. <br> 00050 * \b Note: User task indexes must have a LOWER value than the value defined here. 00051 */ 00052 #define ISF_TASK_INDEX_START (50) 00053 00054 00055 00056 // ========================================================================== 00057 00058 /*! 00059 * @brief This function initializes the ISF library. 00060 * 00061 * @Purpose The isf_lib_init() function is called by an application to 00062 * initialize the ISF library. <br> 00063 * \b Note: This initialization must be done in the user application before it calls any 00064 * ISF function. 00065 * 00066 * @param[in] pOptions This must be a NULL pointer. 00067 * 00068 * @return ::isf_lib_init() returns a value of type ::isf_status_t indicating 00069 * the result of the operation. 00070 * 00071 * @retval ::ISF_SUCCESS is returned when the library initializes successfully. 00072 * @retval ::ISF_ERR_LIB_INIT is returned when the library does not initialize successfully. 00073 * 00074 * @reentrant No 00075 * 00076 * @libs None. 00077 * 00078 */ 00079 isf_status_t isf_lib_init(void *pOptions); 00080 00081 00082 /*! 00083 * @brief This function initializes the ISF components for operation. 00084 * 00085 * @Purpose The ISF initialization task calls each ISF component to 00086 * perform a one-time initialization. Each ISF component executes its initialization 00087 * routine, if enabled in isf_user_config.h and if there are any initialization 00088 * activities to perform. 00089 * 00090 * @param[in] initial_data This is required by MQX and any UINT32 value can be used. 00091 * 00092 * @return This function does not return any values. 00093 * 00094 * @Constraints (1) The isf_init_task() must be the highest priority task in the system. <br> 00095 * (2) This API call must be invoked only once and must run before any other task in the system runs. 00096 * This can be ensured by using the default setting 00097 * in isf_init.h, which sets this task as the highest priority task in the system. \n 00098 * Once initialization is complete, the task exits and its task memory is 00099 * reclaimed by the system and is made available for application use. 00100 * 00101 * @Reentrant No 00102 * 00103 * @Libs isf_core.lib 00104 * 00105 */ 00106 void isf_init_task(uint32 initial_data); 00107 00108 /*! 00109 * @brief This function synchronizes the user tasks and the system initialization. 00110 * 00111 * @Purpose This function blocks the user tasks from executing until ISF initialization is completed. 00112 * 00113 * @return This function does not return any values. 00114 * 00115 * @Constraints 00116 * 00117 * @Reentrant No 00118 * 00119 * @Libs isf_core.lib 00120 * 00121 */ 00122 void isf_system_sync(void); 00123 00124 /*! 00125 * @brief The following macros define the individual attributes for ISF Initialization Task startup. <br> 00126 * \b Note: These macro definitions must not be changed by the user. 00127 */ 00128 #define ISF_TASK_INIT_INDEX (ISF_TASK_INDEX_START + 0) 00129 #define ISF_TASK_INIT_STACK_SIZE (384) 00130 #define ISF_TASK_INIT_PRIORITY (ISF_TASK_PRIORITY-1) 00131 #define ISF_TASK_INIT_NAME ("ii") 00132 #define ISF_TASK_INIT_PARAM (0) 00133 #define ISF_TASK_INIT_TIMESLICE (0) 00134 00135 /*! 00136 * @brief Definition of the task-startup attributes macro for the ISF Initialization Task. 00137 * This task initialization macro is used to initialize and launch the ISF initialization task. 00138 */ 00139 #define ISF_TASK_ATTRIBUTE_INIT { ISF_TASK_INIT_INDEX, \ 00140 isf_init_task, \ 00141 ISF_TASK_INIT_STACK_SIZE, \ 00142 ISF_TASK_INIT_PRIORITY, \ 00143 ISF_TASK_INIT_NAME, \ 00144 MQX_AUTO_START_TASK, \ 00145 ISF_TASK_INIT_PARAM, \ 00146 ISF_TASK_INIT_TIMESLICE }, 00147 00148 00149 // ========================================================================== 00150 00151 #if ISF_COMPONENT_SM 00152 /*! 00153 * @brief This is the external declaration of the ISF Sensor Manager Task task-startup function. 00154 * This task performs all necessary startup operations for the Sensor Manager as well as initialization 00155 * of all supported sensor device adapters. <br> 00156 * \b Note: ISF library initialization calls this function. \n 00157 * The user application must not call this function. 00158 */ 00159 extern void sensor_mgr_task(uint32); 00160 00161 /*! 00162 * @brief This is the external declaration of the ISF Sensor Manager task pre-initialization 00163 * function. <br> 00164 * \b Note: The ISF library initialization calls this function. \n 00165 * The user application must not call this function. 00166 */ 00167 extern isf_status_t sm_init(void); 00168 00169 /*! 00170 * @brief The following macros define the individual attributes for the ISF Sensor Manager Task 00171 * task-startup. <br> 00172 * \b Note: These macro definitions must not be changed by the user. 00173 */ 00174 #define ISF_TASK_SM_INDEX (ISF_TASK_INDEX_START + 1) 00175 #define ISF_TASK_SM_STACK_SIZE (640) 00176 #define ISF_TASK_SM_PRIORITY (ISF_TASK_PRIORITY + 0) 00177 #define ISF_TASK_SM_NAME ("sm") 00178 #define ISF_TASK_SM_PARAM (0) 00179 #define ISF_TASK_SM_TIMESLICE (0) 00180 00181 /*! 00182 * @brief Definition of the ISF Sensor Manager Task task-startup attributes macro. 00183 * This task initialization macro is used during the initial task startup process to initialize and 00184 * launch the Sensor Manager task. 00185 */ 00186 #define ISF_TASK_ATTRIBUTE_SM { ISF_TASK_SM_INDEX, \ 00187 sensor_mgr_task, \ 00188 ISF_TASK_SM_STACK_SIZE, \ 00189 ISF_TASK_SM_PRIORITY, \ 00190 ISF_TASK_SM_NAME, \ 00191 MQX_AUTO_START_TASK, \ 00192 ISF_TASK_SM_PARAM, \ 00193 ISF_TASK_SM_TIMESLICE }, 00194 #else 00195 00196 #define ISF_TASK_ATTRIBUTE_SM 00197 00198 #endif // ISF_COMPONENT_SM 00199 00200 00201 00202 00203 00204 // ========================================================================== 00205 00206 #if ISF_COMPONENT_CI 00207 00208 extern void task_ci(uint32); 00209 extern isf_status_t ci_init(void); 00210 #include "isf_ci.h" 00211 00212 #define ISF_APP_CALLBACK_DEV_INFO (isf_app_callback_dev_info) 00213 #define ISF_APP_CALLBACK_MBOX (isf_app_callback_mbox), 00214 00215 /*! 00216 * @brief The following macros define the individual attributes for ISF Command Interpreter 00217 * task task-startup. <br> 00218 * \b Note: These macro definitions must not be changed by the user. 00219 */ 00220 #define ISF_TASK_CI_INDEX (ISF_TASK_INDEX_START + 2) 00221 #define ISF_TASK_CI_STACK_SIZE (1024) 00222 #define ISF_TASK_CI_PRIORITY (ISF_TASK_PRIORITY + 2) 00223 #define ISF_TASK_CI_NAME ("ci") 00224 #define ISF_TASK_CI_PARAM (0) 00225 #define ISF_TASK_CI_TIMESLICE (0) 00226 00227 /*! 00228 * @brief Definition of the ISF Command Interpreter task task-startup attributes macro. 00229 * This task initialization macro is used to initialize and launch the Command Interpreter task. 00230 */ 00231 #define ISF_TASK_ATTRIBUTE_CI { ISF_TASK_CI_INDEX, \ 00232 task_ci, \ 00233 ISF_TASK_CI_STACK_SIZE, \ 00234 ISF_TASK_CI_PRIORITY, \ 00235 ISF_TASK_CI_NAME, \ 00236 MQX_AUTO_START_TASK, \ 00237 ISF_TASK_CI_PARAM, \ 00238 ISF_TASK_CI_TIMESLICE }, 00239 00240 #else 00241 00242 #define ISF_TASK_ATTRIBUTE_CI 00243 #define ISF_APP_CALLBACK_DEV_INFO 00244 #define ISF_APP_CALLBACK_MBOX 00245 00246 #endif // ISF_COMPONENT_CI 00247 00248 00249 00250 00251 // ========================================================================== 00252 00253 #if ISF_COMPONENT_BM 00254 00255 extern void task_bm(uint32); 00256 extern isf_status_t bm_init(void); 00257 00258 /*! 00259 * @brief The following macros define the individual attributes for the ISF Bus Manager 00260 * task task-startup. <br> 00261 * \b Note: These macro definitions must not be changed by the user. 00262 */ 00263 #define ISF_TASK_BM_INDEX (ISF_TASK_INDEX_START + 3) 00264 #define ISF_TASK_BM_STACK_SIZE (512) 00265 #define ISF_TASK_BM_PRIORITY (ISF_TASK_PRIORITY + 1) 00266 #define ISF_TASK_BM_NAME ("bm") 00267 #define ISF_TASK_BM_PARAM (0) 00268 #define ISF_TASK_BM_TIMESLICE (0) 00269 00270 /*! 00271 * @brief Definition of the ISF Bus Manager task task-startup attributes macro. 00272 * This task initialization macro is used during the initial task-startup process to initialize 00273 * and launch the Bus Manager task. 00274 */ 00275 #define ISF_TASK_ATTRIBUTE_BM { ISF_TASK_BM_INDEX, \ 00276 task_bm, \ 00277 ISF_TASK_BM_STACK_SIZE, \ 00278 ISF_TASK_BM_PRIORITY, \ 00279 ISF_TASK_BM_NAME, \ 00280 MQX_AUTO_START_TASK, \ 00281 ISF_TASK_BM_PARAM, \ 00282 ISF_TASK_BM_TIMESLICE }, 00283 00284 #else 00285 00286 #define ISF_TASK_ATTRIBUTE_BM 00287 00288 #endif // ISF_COMPONENT_BM 00289 00290 00291 00292 00293 // ========================================================================== 00294 00295 #if ISF_COMPONENT_PM 00296 00297 void task_idle(uint32 initial_data); 00298 extern isf_status_t pm_init(void); 00299 00300 /*! 00301 * 00302 * @define ISF Power Manager task information 00303 * 00304 * @brief Power Manager component task and attributes.\n 00305 * Care should be taken in changing these attributes. 00306 */ 00307 #define ISF_TASK_PM_INDEX (ISF_TASK_INDEX_START + 4) 00308 #define ISF_TASK_PM_STACK_SIZE (128) 00309 #define ISF_TASK_PM_PRIORITY (ISF_TASK_LOWEST_PRIORITY) 00310 #define ISF_TASK_PM_NAME ("pm") 00311 #define ISF_TASK_PM_PARAM (0) 00312 #define ISF_TASK_PM_TIMESLICE (0) 00313 00314 #define ISF_TASK_ATTRIBUTE_PM { ISF_TASK_PM_INDEX, \ 00315 task_idle, \ 00316 ISF_TASK_PM_STACK_SIZE, \ 00317 ISF_TASK_PM_PRIORITY, \ 00318 ISF_TASK_PM_NAME, \ 00319 MQX_AUTO_START_TASK, \ 00320 ISF_TASK_PM_PARAM, \ 00321 ISF_TASK_PM_TIMESLICE }, 00322 #else 00323 00324 #define ISF_TASK_ATTRIBUTE_PM 00325 00326 #endif // ISF_COMPONENT_PM 00327 00328 00329 00330 00331 /*! 00332 * @brief ISF tasks attributes. The user puts these tasks\n 00333 * in the MQX_template_list[] array. 00334 */ 00335 #define ISF_TASKS_ATTRIBUTES ISF_TASK_ATTRIBUTE_INIT \ 00336 ISF_TASK_ATTRIBUTE_SM \ 00337 ISF_TASK_ATTRIBUTE_CI \ 00338 ISF_TASK_ATTRIBUTE_BM \ 00339 ISF_TASK_ATTRIBUTE_PM 00340 00341 00342 /*! 00343 * @brief This macro defines the ISF application Command Interpreter callback(s).\n 00344 * \b Note: The user must put these callbacks at the beginning of the ci_callback[] array. 00345 */ 00346 #define ISF_APP_CALLBACKS \ 00347 ISF_APP_CALLBACK_DEV_INFO, \ 00348 ISF_APP_CALLBACK_MBOX 00349 00350 #endif // ISF_INIT_H_