ISF  1.1
Intelligent Sensing Framework
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Include/isf_hostproxy.h
Go to the documentation of this file.
00001 /*
00002  * 
00003  * Copyright (c) 2013, Freescale Semiconductor, Inc.
00004  * 
00005 */
00006 /**
00007  * @file isf_hostproxy.h
00008  * @brief Definitions and types for the Host Proxy component. * 
00009  *
00010  */
00011 #ifndef HOSTPROXY_H_
00012 #define HOSTPROXY_H_
00013 
00014 #include "isf.h"
00015 #include "isf_types.h"
00016 #include "isf_init.h"
00017 #include <lwevent.h>
00018 /*! @brief This enumeration defines the common Host Proxy errors */
00019 enum hp_Error {
00020                 HP_ERROR_MAXIUM_NO = 1,          /*!< Error for exceeding the maximum number of user applications configured to the Host Proxy. The maximum number is 8. */  
00021                 HP_ERROR_INVALID_PROXY,  /*!< Error for using an invalid proxy. */
00022                 HP_ERROR_INVALID_EVENT   /*!< Error for passing an invalid event to a method. */
00023 };
00024 /*! @brief The generic control register structure for user applications. */
00025 typedef union {
00026   uint8 reg;                                                                       /*!< The control byte. */
00027   struct {
00028                 uint8 startStop         :1;    /*!< The data streaming bit. When this bit is set, data streaming is enabled. Data streaming is disabled by clearing this bit. */ 
00029                 uint8 subState          :1;    /*!< The subscription state bit. Setting this bit enables the subscription. Clearing this bit disables the subscription.*/
00030     uint8 hostIntEn         :1;    /*!< The host interrupt bit. Setting this bit enables the host interrupt. Clearing this bit disables the host interrupt.*/
00031     uint8 quickReadEn           :1;    /*!< The quick read bit for the application. Setting this bit enables the quick read. Clearing this bit disables the quick read.*/
00032     uint8 reserved          :4;    /*!< These bits are for future use. */
00033   } Bits;
00034 }ctrl_reg_t;
00035 
00036 /*! @brief This is the structure defined for the user application to update the host.  */
00037 typedef struct hp_hostUpdate_struct{
00038                 uint8 isQuickReadUpdate;  /*!< Status indicating whether or not Quick Read is enabled. */
00039                 uint8 isHostInt;                                  /*!< Status indicating whether or not host interrupt is enabled.*/
00040                 uint8 size;                                                       /*!< The size of the buffer holding user application data. */ 
00041                 uint8 AppId;                                      /*!< The current application ID for the user application. */  
00042                 uint8 *pDataBuffer;       /*!< The buffer containing user application data. */
00043 }hp_hostUpdate_t;
00044 
00045 /*! @brief This is the structure for the host interface. Each user application needs to implement this interface, when utilizing the features of the Host Proxy.  */
00046 typedef struct hp_Interface_struct{
00047                 isf_status_t (*init)(void);  /*!< The callback for user application specific initialization. */
00048                 isf_status_t (*config)(void); /*!< The callback for user application specific configuration. */
00049                 isf_status_t (*getData)(hp_hostUpdate_t *pHostData); /*!< The callback for data preparation by the user application. */
00050 }hp_Interface_t;
00051 
00052 /*! @brief This structure configures a user application. */
00053 typedef struct hp_ApplicationConfig_struct{
00054                 uint8 appId; /*!< The Application Id of the user application. */
00055                 uint8 sensorId; /*!< The sensor identification number for the user application. */
00056                 hp_Interface_t interface; /*!< The handle for the host interface. */
00057 }hp_ApplicationConfig_t;
00058 
00059 /*! @brief This structure defines the host configuration which has multiple configured user applications. */
00060 typedef struct hp_Config_struct{
00061                 uint8 proxyNo; /*!< The events mapped to the specific user application. */
00062                 hp_ApplicationConfig_t *appConfig; /*!< The handle for the configured user applications. */
00063 }hp_Config_t;
00064 
00065 /*! @brief The common events handled by the Host Proxy. */
00066 #define EVENT_DATA_READY                                          0x1 /*!< The data ready event. */
00067 #define EVENT_HOST_CONFIG             0x2 /*!< The application configuration event. */
00068 #define EVENT_BITMASK                 0x3 /*!< The event bit masking for the Host Proxy.*/ 
00069 #define MAX_APPS_ON_PROXY             0x8 /*!< The maximum number of instances of user applications supported by the Host Proxy. */              
00070 #define MAX_EVENTS_PER_APPS           0x2 /*!< The number of events for each user application.*/
00071 
00072 
00073 extern LWEVENT_STRUCT   gProxyEvent;            /*!< The handle for the Host Proxy events. */
00074 
00075 /*!
00076  * @brief The following macros and functions define the individual attributes for the ISF Host Proxy. 
00077  */
00078 extern void task_proxy(uint_32 param);                          
00079 #define ISF_TASK_HP_INDEX                (ISF_TASK_INDEX_START + 4)
00080 #define ISF_TASK_HP_STACK_SIZE           (512)
00081 #define ISF_TASK_HP_PRIORITY             ISF_TASK_PRIORITY
00082 #define ISF_TASK_HP_NAME                 ("HostProxy")
00083 #define ISF_TASK_HP_PARAM                (0)
00084 #define ISF_TASK_HP_TIMESLICE            (0)
00085 
00086 /*!
00087  * @brief The definition of the ISF Host Proxy task-startup attributes macro.
00088  * The developer inserts the task initialization macro into the structure :TASK_TEMPLATE_STRUCT  MQX_template_list[] to launch a Host Proxy task. 
00089  */
00090 #define ISF_TASK_ATTRIBUTE_HOST_PROXY    { ISF_TASK_HP_INDEX, \
00091                                                                                                                                                                   task_proxy, \
00092                                                                                                                                                                   ISF_TASK_HP_STACK_SIZE, \
00093                                                                                                                                                                   ISF_TASK_HP_PRIORITY, \
00094                                                                                                                                                                   ISF_TASK_HP_NAME, \
00095                                           MQX_AUTO_START_TASK, \
00096                                           ISF_TASK_HP_PARAM, \
00097                                           ISF_TASK_HP_TIMESLICE   },
00098 
00099 /*! @brief               This function sets an event for a proxy. 
00100  *
00101  *  @details             An user application registered to the Host Proxy is called a proxy. When this function is called, an event is created internally based on the proxy number and the event number. The created event is set to the Host Proxy for notification. 
00102  *  
00103  *  @param [in]          proxyNo   The proxy number
00104  *  @param [in]          eventNo   The event number
00105  *  
00106  *  @return              ::isf_hp_set_proxy_event() returns a value of type ::isf_status_t indicating whether the operation was successful or unsuccessful.
00107  *  
00108  *  @retval              ::ISF_SUCCESS           is returned when a proxy event is successfully set.                         
00109  *  @retval              ::HP_ERROR_INVALID_PROXY is returned when an invalid event proxy number is passed into the function.
00110  *  @retval                                      ::HP_ERROR_INVALID_EVENT is returned when an invalid event number is passed into the function.
00111  *                                          
00112  *  @Constraints         None
00113  *                   
00114  *  @Reentrant           Yes
00115  *                       
00116  *  @Libs                isf_core.lib
00117  *
00118  */
00119 isf_status_t isf_hp_set_proxy_event(uint8 proxyNo, uint8 eventNo);
00120 
00121 /*! @brief               This function gets the event for a proxy.
00122  *
00123  *  @details             An user application registered to the Host Proxy is called a proxy. This function obtains a proxy event for a proxy. 
00124  *  
00125  *  @param[in]           proxyNo    The proxy number.
00126  *  @param[in]           eventNo    The event number.
00127  *  @param[out]          proxyEvent The proxy event for a specific proxy.
00128  *    
00129  *  @return              ::isf_hp_get_proxy_event() returns a value of type ::isf_status_t indicating whether the operation was successful or unsuccessful.
00130  *  
00131  *  @retval                                                      ::ISF_SUCCESS           is returned when the an event is successfully retrieved.                  
00132  *  @retval              ::HP_ERROR_INVALID_PROXY is returned when an invalid event proxy number is passed into the function.
00133  *  @retval              ::HP_ERROR_INVALID_EVENT is returned when an invalid event number is passed into the function.                                        
00134  *
00135  *  @Constraints         None
00136                      
00137  *  @Reentrant           Yes
00138  *                       
00139  *  @Libs                isf_core.lib
00140  *
00141  */
00142 isf_status_t isf_hp_get_proxy_event(uint8 proxyNo, uint8 eventNo, uint32* proxyEvent );
00143 #endif /* HOSTPROXY_H_ */