![]() |
ISF
1.1
Intelligent Sensing Framework
|
00001 /** 00002 * @file isf_sm_dsa_adapter.h 00003 * @brief The \b isf_sm_dsa_adapter.h contains the data types and enumerations used by 00004 * the Sensor Manager and the Digital Sensor Abstraction (DSA) implementation. 00005 * 00006 * @copyright Copyright (c) 2012, Freescale Semiconductor, Inc. 00007 */ 00008 00009 #ifndef ISF_SM_DSA_ADAPTER_H_ 00010 #define ISF_SM_DSA_ADAPTER_H_ 00011 00012 #include "isf_types.h" 00013 #include <mqx.h> 00014 #include "lwevent.h" 00015 #include "isf_sysconf_types.h" 00016 00017 /*! 00018 * @brief This is the Sensor Manager API return type definition. 00019 */ 00020 typedef int32 sm_status_t; 00021 00022 00023 /*! 00024 * @brief This enumerates the error types returned by the DSA sensor functions. 00025 */ 00026 typedef enum sm_dsa_error_types 00027 { 00028 SM_DSA_ERR_INITIALIZE = 1, 00029 /*!< Adapter initialize error. */ 00030 SM_DSA_ERR_VALIDATE_SETTINGS, 00031 /*!< Adapter settings validation error. */ 00032 SM_DSA_ERR_CONFIGURE, 00033 /*!< Adapter configuration error. */ 00034 SM_DSA_ERR_START_DATA, 00035 /*!< Adapter data start error. */ 00036 SM_DSA_ERR_END_DATA, 00037 /*!< Adapter data end error. */ 00038 SM_DSA_ERR_CALIBRATE, 00039 /*!< Adapter calibration error. */ 00040 SM_DSA_ERR_PARAM 00041 /*!< Adapter parameter error. */ 00042 } sm_dsa_err_t; 00043 00044 /*! 00045 * @brief This defines the DSA adapter control interface abstract function list. 00046 */ 00047 typedef struct sm_dsa_ControlInterface_st 00048 { 00049 sm_status_t (*Initialize)( void *pSensorHandle); /*!< Pointer to the adapter Initialize() function. */ 00050 sm_status_t (*ValidateSettings)(void *pSensorHandle, void *pSettings); 00051 /*!< Pointer to the adapter ValidateSettings() function. */ 00052 sm_status_t (*Configure)(void *pSensorHandle, void *pConfigSettings); 00053 /*!< Pointer to the adapter Configure() function. */ 00054 sm_status_t (*StartData)(void *pSensorHandle ); /*!< Pointer to the adapter StartData() function. */ 00055 sm_status_t (*EndData)(void *pSensorHandle ); /*!< Pointer to the adapter EndData() function. */ 00056 sm_status_t (*Calibrate)(void *pSensorHandle ); /*!< Pointer to the adapter Calibrate() function. */ 00057 } sm_dsa_ControlInterface_t; 00058 00059 /*! 00060 * @brief This defines the DSA adapter device information block. 00061 */ 00062 typedef struct sm_dsa_DeviceInfoBlock_st 00063 { 00064 uint8 nDataSetSize; 00065 /*!< The size of a data sample for this sensor. */ 00066 uint8 nDevConfigSize; 00067 /*!< The total size of the memory block for the device configuration parameters */ 00068 } sm_dsa_DeviceInfoBlock_t; 00069 00070 /*! 00071 * @brief This defines the DSA adapter functional interface. 00072 */ 00073 typedef struct sm_dsa_FunctionalInterface_st 00074 { 00075 void *pDataBuff; 00076 /*!< The data buffer where sensor data is deposited by the sensor device adapter ISR. */ 00077 LWEVENT_STRUCT *pEventGroup; 00078 /*!< The event group to signal after depositing sensor sample in pDataBuff. */ 00079 uint32 nEventFieldIndex; 00080 /*!< The event flag of the event group to signal after depositing sensor sample in pDataBuff. */ 00081 } sm_dsa_FunctionalInterface_t; 00082 00083 /*! 00084 * @brief This defines the DSA adapter sensor status bit-field structure. 00085 */ 00086 typedef struct sm_Dsa_SensorStatus_st 00087 { 00088 uint8 bAvailable : 1; 00089 /*!< The current sensor is available for use. */ 00090 uint8 bInitialized : 1; 00091 /*!< The current sensor is initialized. */ 00092 uint8 bSensorOn : 1; 00093 /*!< The current sensor is on. */ 00094 uint8 bDummy : 5; 00095 /*!< Unused bits. */ 00096 }sm_DsaAdapterStatus_t; 00097 00098 /*! 00099 * @brief This defines the DSA adapter structure required for static initialization of 00100 * the concrete instance of a given sensor adapter. 00101 */ 00102 typedef struct sm_DsaAdapter_st 00103 { 00104 sm_dsa_DeviceInfoBlock_t devInfoBlock; 00105 /*!< Adapter device information block field. */ 00106 sm_dsa_ControlInterface_t ctrlIntf; 00107 /*!< Adapter control interface field. */ 00108 } sm_DsaAdapter_t; 00109 00110 /*! 00111 * @brief This defines the DSA sensor configuration parameter structure configuring the sensor settings 00112 * by a subscriber task. 00113 */ 00114 typedef struct sm_SensorConfigSettings_st 00115 { 00116 uint32 nSampleRate; 00117 /*!< Sample period in microseconds. */ 00118 uint8 nResolution; 00119 /*!< Sample resolution. */ 00120 uint8 nRange; 00121 /*!< Sensor dynamic range. */ 00122 uint8 nMode; 00123 /*!< Sensor specific mode. */ 00124 } SM_SensorConfigSettings_t; 00125 00126 /*! 00127 * @brief This defines the DSA sensor device configuration header structure 00128 * used for adapter initial configuration. 00129 */ 00130 typedef struct sm_DevConfigHdr_St 00131 { 00132 sm_DsaAdapterStatus_t devStatus; 00133 /*!< Adapter status bit-field. */ 00134 sm_dsa_FunctionalInterface_t funcIntf; 00135 /*!< Adapter functional interface field. */ 00136 sys_channelId_t channelId; 00137 /*!< Adapter physical channel identification field. */ 00138 uint32 devAddress; 00139 /*!< Adapter physical device address field. */ 00140 SM_SensorConfigSettings_t sensorSettings; 00141 /*!< Adapter sensor settings field. */ 00142 LWSEM_STRUCT sensorDataSemaphore; 00143 /*!< Adapter sensor data semaphore field. */ 00144 uint8 semTimeout; 00145 /*!< Adapter sensor data semaphore timeout value field. */ 00146 } sm_DevConfigHdr_t; 00147 00148 00149 /*! 00150 * @brief This is defines the DSA sensor device handle structure 00151 * to invoke the adapter access functions. 00152 */ 00153 typedef struct sm_SensorHandle_St 00154 { 00155 sm_DevConfigHdr_t hdr; 00156 /*!< Adapter device configuration header field. */ 00157 void *pDescriptor; 00158 /*!< Pointer to the adapter generic device descriptor field. */ 00159 void *pSensorSpecificSettings; 00160 /*!< Pointer to the adapter sensor specific settings field. */ 00161 } sm_SensorHandle_t; 00162 00163 /*! 00164 * @brief This defines the DSA sensor configuration structure 00165 * defining each individual sensor adapter in the DSA Sensor List. 00166 */ 00167 typedef struct SensorConfig_st 00168 { 00169 sm_DsaAdapter_t *pAdapter; 00170 /*!< Pointer to the statically initialized adapter structure. */ 00171 void *pSensorHandle; 00172 /*!< Pointer to the sensor device handle. */ 00173 void *pSensorSpecificSettings; 00174 /*!< Pointer to the adapter sensor specific settings. */ 00175 sys_channelId_t channelId; 00176 /*!< Sensor device physical channel identification value. */ 00177 uint32 devAddress; 00178 /*!< Sensor device physical address. */ 00179 } SensorConfig_t; 00180 00181 #endif /* ISF_SM_DSA_ADAPTER_H_*/