32 #include "fsl_os_abstraction.h"
40 #define MPL3115_PRESS_FLOAT_CONVERSION_FACTOR 0.000000061035
41 #define MPL3115_PRESS_FLOAT_CONVERSION_OFFSET 0.0
42 #define MPL3115_PRESS_FIXED_CONVERSION_FACTOR (1000/4)
43 #define MPL3115_PRESS_FIXED_CONVERSION_OFFSET 0
44 #define MPL3115_ALT_FLOAT_CONVERSION_FACTOR (1.0F/65536.0F)
45 #define MPL3115_ALT_FLOAT_CONVERSION_OFFSET 0.0
46 #define MPL3115_ALT_FIXED_CONVERSION_FACTOR 1
47 #define MPL3115_ALT_FIXED_CONVERSION_OFFSET 0
48 #define MPL3115_TEMP_FLOAT_CONVERSION_FACTOR (1.0F/256.0F)
49 #define MPL3115_TEMP_FLOAT_CONVERSION_OFFSET 0.0
50 #define MPL3115_TEMP_FIXED_CONVERSION_FACTOR 256
51 #define MPL3115_TEMP_FIXED_CONVERSION_OFFSET 0
87 { 50000.0 , 5574.4366 },
88 { 51000.0 , 5428.1385 },
89 { 52000.0 , 5284.1450 },
90 { 53000.0 , 5142.3767 },
91 { 54000.0 , 5002.7580 },
92 { 55000.0 , 4865.2174 },
93 { 56000.0 , 4729.6871 },
94 { 57000.0 , 4596.1025 },
95 { 58000.0 , 4464.4024 },
96 { 59000.0 , 4334.5283 },
97 { 60000.0 , 4206.4245 },
98 { 61000.0 , 4080.0381 },
99 { 62000.0 , 3955.3185 },
100 { 63000.0 , 3832.2172 },
101 { 64000.0 , 3710.6880 },
102 { 65000.0 , 3590.6869 },
103 { 66000.0 , 3472.1715 },
104 { 67000.0 , 3355.1013 },
105 { 68000.0 , 3239.4376 },
106 { 69000.0 , 3125.1431 },
107 { 70000.0 , 3012.1820 },
108 { 71000.0 , 2900.5203 },
109 { 72000.0 , 2790.1248 },
110 { 73000.0 , 2680.9639 },
111 { 74000.0 , 2573.0073 },
112 { 75000.0 , 2466.2255 },
113 { 76000.0 , 2360.5905 },
114 { 77000.0 , 2256.0750 },
115 { 78000.0 , 2152.6530 },
116 { 79000.0 , 2050.2990 },
117 { 80000.0 , 1948.9888 },
118 { 81000.0 , 1848.6990 },
119 { 82000.0 , 1749.4067 },
120 { 83000.0 , 1651.0902 },
121 { 84000.0 , 1553.7282 },
122 { 85000.0 , 1457.3002 },
123 { 86000.0 , 1361.7865 },
124 { 87000.0 , 1267.1680 },
125 { 88000.0 , 1173.4260 },
126 { 89000.0 , 1080.5427 },
127 { 90000.0 , 988.5006 },
128 { 91000.0 , 897.2829 },
129 { 92000.0 , 806.8734 },
130 { 93000.0 , 717.2561 },
131 { 94000.0 , 628.4157 },
132 { 95000.0 , 540.3374 },
133 { 96000.0 , 453.0066 },
134 { 97000.0 , 366.4094 },
135 { 98000.0 , 280.5320 },
136 { 99000.0 , 195.3614 },
137 { 100000.0 , 110.8845 },
138 { 101000.0 , 27.0889 },
139 { 102000.0 , -56.0375 },
140 { 103000.0 , -138.5067 },
141 { 104000.0 , -220.3300 },
142 { 105000.0 , -301.5187 },
143 { 106000.0 , -382.0837 },
144 { 107000.0 , -462.0356 },
145 { 108000.0 , -541.3847 },
146 { 109000.0 , -620.1411 },
147 { 110000.0 , -698.3146 }
175 void mpl3115_SetMode(int32_t *status,
void* pSensorHandle, int32_t Mode);
208 if ( NULL == pSensorHandle){
227 if (NULL == pDeviceDescriptor) {
277 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->
deviceSemaphore, 1)){
304 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
333 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
345 if (NULL == pDeviceDescriptor)
356 goto unlockdescriptor;
362 goto unlockdescriptor;
424 if(NULL == pSensorHandle){
436 if (NULL == pDeviceDescriptor)
446 goto unlockdescriptor;
452 goto unlockdescriptor;
457 goto unlockdescriptor;
487 if(NULL == pSensorHandle){
500 if (NULL == pDeviceDescriptor)
509 goto unlockdescriptor;
516 goto unlockdescriptor;
523 goto unlockdescriptor;
573 if(NULL == pSensorHandle){
605 if(NULL == pSensorHandle){
617 if (NULL == pDeviceDescriptor){
644 if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->
deviceSemaphore, OSA_WAIT_FOREVER))
646 goto unlockdescriptor;
653 goto unlockdescriptor;
670 *pFifoEntry = *pCurrentSampleBuffer;
678 pCurrentSampleBuffer,
704 goto unlockdescriptor;
717 void *pConvertedSample,
726 switch (convertToType)
730 pConverter = float_press1d_converter;
732 pConverter = fixed_press1d_converter;
737 pConverter = float_alt1d_converter;
739 pConverter = fixed_alt1d_converter;
744 pConverter = float_temp1d_converter;
746 pConverter = fixed_temp1d_converter;
752 if (pConverter == NULL)
755 retStat = pConverter(
757 (mpl3115_DataBuffer_t *)pNativeSample,
820 uint8 buffer[1] = {0};
835 OSA_TimeDelay(1000/5);
845 uint8 buffer[1] = {0};
871 if (NULL == pSensorHandle) {
901 uint8 buffer[1] = {0x00};
964 uint8 buffer[1] = {0x00};
990 uint8 buffer[1] = {0x00};
1003 #define BYTES_FOR_FULL_READ 5
1030 #ifdef MPL3115_DEBUG
1031 static uint8 mpl3115_Reg[50];
1041 mpl3115_Reg[i] = buffer[0];
1060 for (
uint32 reg=0; reg < pConfigSpecific->regCount; reg++)
1062 buffer[0] = pConfigSpecific->regPairs[reg].regValue;
1082 #ifdef MPL3115_DEBUG
1084 mpl3115_ReadRegisters( pSensorHandle );
1094 float fPressure = ((float)(pressure >> 12)/(float)4.0);
1097 fLfi(&pressure_to_height,fPressure,&fHeight);
1099 return (((
int32)(fHeight*16.0))<<12);
1104 #define ABSOLUTE_VALUE(x) ( (x) < 0.0 ? (-(x)) : (x))
1105 #define ZERO_EPSILON (1.0E-10)
1106 #define IS_PRACTICALLY_ZERO(x) ( ABSOLUTE_VALUE(x) < ZERO_EPSILON )
1110 float delta_x_table;
1111 float delta_y_table;
1112 float delta_x_point;
1119 if ( x_in < lookupTable->dataPoints[i].x )
1133 for (i=1; i < lookupTable->
maxIdx; i++ )
1135 if ( x_in < lookupTable->dataPoints[i].x )
break;
1159 delta_x_point = x_in - lookupTable->
dataPoints[i].
x;
1160 *y_out = delta_y_table/delta_x_table *(delta_x_point) + lookupTable->
dataPoints[i].
y;
1177 uint8 i = 0, flag=0;
1181 if(mpl3115_osTable[i].samplePeriod == samplePeriod)
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
isf_temperature_degC_float_t temperature
void * pSensorSpecificSettings
#define MPL3115_ALT_FLOAT_CONVERSION_OFFSET
#define MPL3115_PRESS_FLOAT_CONVERSION_OFFSET
#define MPL3115_TEMP_FLOAT_CONVERSION_FACTOR
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Shutdown(isf_SensorHandle_t *pSensorHandle)
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
Standard fixed type for single axis altitude sensor.
isf_status_t dm_device_open(dm_ChannelDescriptor_t *apChannelDescriptor, void *apDevice, dm_DeviceDescriptor_t *apDeviceDescriptor)
This function creates a device handle for a device at a specified channel address.
isf_dsa_ControlData_t controlData
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
isf_fifo_status_t isf_fifo_unlock(isf_fifo_t *pFifo)
Release the exclusive access lock on a sample buffer.
Standard floating point type for single axis temperature sensor.
isf_fifo_status_t isf_fifo_el_increment(isf_fifo_t *pFifo)
Routine increments the insert pointer after direct access.
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
void mpl3115_ValidateConfig(int32_t *status, void *pSensorHandle)
This function validates the configuration for the MPL3115 sensor.
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
isf_altitude_meters_float_t altitude
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Convert(volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
This function coverts the raw sample data to the desired output type.
dm_DeviceDescriptor_t deviceHandle
#define MPL3115_ALT_FIXED_CONVERSION_OFFSET
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
long fLfi(const fLfiTable_t *lookupTable, float lFiIn, float *lfiOut)
isf_timestamp_t timestamp
#define MPL3115_PRESS_FIXED_CONVERSION_FACTOR
Define the sensor device descriptor.
#define MPL3115_TEMP_FLOAT_CONVERSION_OFFSET
void mpl3115_Reset(int32_t *status, void *pSensorHandle)
This function resets the MPL3115 sensor resulting in a default configuration for all registers...
isf_pressure_kPa_fixed_32s1i16_t pressure
#define MPL3115_TEMP_FIXED_CONVERSION_OFFSET
dm_ChannelDescriptor_t cDescriptor
void mpl3115_DataReady(int32_t *status, void *pSensorHandle)
This function sets the MPL3115 part to the requested mode.
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
isf_status_t bm_unregister_callback(bm_callback_token_t aToken)
This API unregisters one or more callbacks.
isf_SensorDataTypes_t mpl3115_SupportedDataTypes[]
#define MPL3115_WHOAMI_VALUE
#define MPL3115_TEMP_FIXED_CONVERSION_FACTOR
the structure defines the OS table for MPL3115 operation.
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
The isf_pressure_types.h file contains the ISF data type definitions for use with the ISF generic pre...
#define MPL3115_ACTIVE_MASK
void mpl3115_CheckId(int32_t *status, void *pSensorHandle)
This function validates the MPL3115 sensor is connected via the I2C bus.
const mpl3115_OS_Table_t mpl3115_osTable[]
The table that describes the configuration value based on OS (oversample ratio).
#define BYTES_FOR_FULL_READ
This function retrieves the raw data from the MPL3115 sensor.
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
isf_temperature_degC_fixed_32s1i16_t temperature
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
#define MPL3115_PRESS_FIXED_CONVERSION_OFFSET
This structure defines the dummy DSA data buffer format.
isf_alt_meters_fixed_32s1i16_t altitude
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_timestamp_t timestamp
isf_status_t dm_channel_acquire_lock(dm_ChannelDescriptor_t *apChannelDescriptor, isf_duration_t aTimeout)
This function locks the channel for exclusive access.
The isf_sensor_types.h contains the enumerated list of sensor types used by ISF.
void mpl3115_SetMode(int32_t *status, void *pSensorHandle, int32_t Mode)
This function sets the MPL3115 part to the requested mode.
The isf_util.h file contains the utility method declarations and macros.
enum isf_dsa_result_enums isf_dsa_result_types_t
Standard floating point type for single axis pressure sensor.
bm_callback_token_t bm_register_periodic_callback(isf_duration_t aPeriod, bm_callback_t *pCallback, void *pCbData)
This API schedules a callback at the specified period.
The fsl_mpl3115_i2c_1D_press.h file contains the definitions and functions supporting the MMA8652 Sen...
isf_dsa_status_t mpl3115_GetData(isf_SensorHandle_t *pSensorHandle, mpl3115_DataBuffer_t *pData)
The mpl3115.h contains the MPL3115 Pressure sensor register definitions, access macros, and device access functions.
isf_timestamp_t timestamp
#define MPL3115_ALT_FLOAT_CONVERSION_FACTOR
isf_dsa_result_types_t resultFormat
isf_timestamp_t timestamp
void fsl_mpl3115_i2c_1D_press_PeriodicCallback(void *pSensorHandle)
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
#define IS_PRACTICALLY_ZERO(x)
The isf_altitude_types.h file contains the ISF data type definitions for use with the ISF generic alt...
The isf_temperature_fixed_t.h file contains the ISF data type definitions for use with the ISF generi...
isf_dsa_status_t mpl3115_SetConfig(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pConfigSettings)
This function sets the MPL3115 sensor configuration.
isf_status_t bm_stop(bm_callback_token_t aTokens)
This API stops one or more callback(s) by setting them to the inactive state.
const isf_SensorConfig_t * pSensorStaticConfig
isf_status_t bm_start(boolean aSync, bm_callback_token_t aTokens)
This API sets one or more callback(s) to the active state.
Standard fixed type for single axis pressure sensor.
isf_pressure_kPa_float_t pressure
isf_SensorDataTypes_t resultType
#define MPL3115_ALT_FIXED_CONVERSION_FACTOR
Main ISF header file. Contains code common to all ISF components.
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
#define MPL3115_SET_FIELD(name, val)
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_StartData(isf_SensorHandle_t *pSensorHandle)
isf_dsa_AdapterStatus_t adapterStatus
sys_channelId_t channelId
Standard fixed type for single axis pressure sensor.
isf_SensorTypes_t mpl3115_SupportedSensorTypes[]
Supported sensor and data types for MPL3115.
isf_timestamp_t timestamp
isf_fifo_t * pSampleBufferInfo
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
unsigned char extrapolationBehavior
int32 isf_status_t
ISF return status type.
Standard floating point type for single axis altitude sensor.
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
isf_dsa_SensorSettings_t sensorSettings
#define MPL3115_GET_FIELD(name, val)
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
This structure defines a handle for the device.
isf_timestamp_t timestamp
void mpl3115_StartSample(int32_t *status, void *pSensorHandle)
This function sets the MPL3115 part to the requested mode.
int32 convertPressureToAltitude(uint32 pressure)
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Initialize(isf_SensorHandle_t *pSensorHandle)
semaphore_t deviceSemaphore
This structure is a declaration of a channel descriptor type.
bm_callback_token_t token
#define MPL3115_PRESS_FLOAT_CONVERSION_FACTOR
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_EndData(isf_SensorHandle_t *pSensorHandle)
uint32 timestamp
Time stamp value in micro-seconds.