ISF  1.1
Intelligent Sensing Framework
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
User/Source/isf_init.c
Go to the documentation of this file.
00001 /**
00002  * @file isf_init.c
00003  * 
00004  * @brief The \b isf_init.c file contains implementation of the ISF library 
00005  * initialization functions.
00006  *
00007  * @copyright Copyright (c) 2012, Freescale Semiconductor, Inc.  
00008  */ 
00009 
00010 #include "isf_user_config.h"
00011 #include "isf_init.h"
00012 #include <mqx.h>
00013 #include <lwevent.h>
00014 
00015 LWEVENT_STRUCT isfSysEventHandler;
00016 
00017 /*! @brief Please see isf_init.h for complete documentation. */
00018 isf_status_t isf_lib_init(void *pOptions)
00019 {
00020                 
00021 #pragma unused (pOptions)
00022                 
00023   isf_status_t status = ISF_SUCCESS;
00024   _mqx_uint   MQX_stat = _lwevent_create(&isfSysEventHandler, ISF_SYSTEM_READY_EVENT);
00025   if(MQX_stat != MQX_OK){
00026                 return ISF_ERR_LIB_INIT;
00027   }
00028  
00029 #if ISF_COMPONENT_BM  
00030   // Initialize the Bus Manager
00031   status |= bm_init();
00032 #endif
00033   
00034 #if ISF_COMPONENT_CI
00035   // Initialize the Command Interpreter
00036   status |= ci_init();
00037 #endif
00038 #if ISF_COMPONENT_SM
00039   // Initialize the Sensor Manager
00040   status |= sm_init();
00041 #endif
00042   
00043 #if ISF_COMPONENT_PM 
00044   // Initialize the Power Manager
00045   status |= pm_init();
00046 #endif
00047   
00048   if (status){
00049     status = ISF_ERR_LIB_INIT;
00050   }  
00051   else{
00052     _lwevent_set(&isfSysEventHandler, ISF_SYSTEM_READY_EVENT);
00053   }
00054   return status;
00055 }
00056 
00057 
00058 
00059 /*! @brief Please see isf_init.h for complete documentation. */
00060 void isf_init_task(uint32 initial_data)
00061 {
00062   #pragma unused(initial_data)
00063   
00064   // Initialize ISF components that are enabled in isf_user_config.h
00065   isf_lib_init(0);
00066   // Task exit.  Memory is reclaimed for other use.
00067 }
00068 
00069 
00070 
00071 /*! 
00072  * @brief This function synchronizes the user tasks and the system initialization.  */
00073  
00074 void isf_system_sync(void)
00075 {
00076                 // wait for the system ready event.
00077    _lwevent_wait_for(&isfSysEventHandler, ISF_SYSTEM_READY_EVENT, FALSE, NULL); 
00078 }
00079