38 #define MPL3115_PRESS_FLOAT_CONVERSION_FACTOR 0.000000061035
39 #define MPL3115_PRESS_FLOAT_CONVERSION_OFFSET 0.0
40 #define MPL3115_PRESS_FIXED_CONVERSION_FACTOR (1000/4)
41 #define MPL3115_PRESS_FIXED_CONVERSION_OFFSET 0
42 #define MPL3115_ALT_FLOAT_CONVERSION_FACTOR 1.0
43 #define MPL3115_ALT_FLOAT_CONVERSION_OFFSET 0.0
44 #define MPL3115_ALT_FIXED_CONVERSION_FACTOR 1
45 #define MPL3115_ALT_FIXED_CONVERSION_OFFSET 0
46 #define MPL3115_TEMP_FLOAT_CONVERSION_FACTOR 256.0
47 #define MPL3115_TEMP_FLOAT_CONVERSION_OFFSET 0.0
48 #define MPL3115_TEMP_FIXED_CONVERSION_FACTOR 256
49 #define MPL3115_TEMP_FIXED_CONVERSION_OFFSET 0
86 { 50000.0 , 5574.4366 },
87 { 51000.0 , 5428.1385 },
88 { 52000.0 , 5284.1450 },
89 { 53000.0 , 5142.3767 },
90 { 54000.0 , 5002.7580 },
91 { 55000.0 , 4865.2174 },
92 { 56000.0 , 4729.6871 },
93 { 57000.0 , 4596.1025 },
94 { 58000.0 , 4464.4024 },
95 { 59000.0 , 4334.5283 },
96 { 60000.0 , 4206.4245 },
97 { 61000.0 , 4080.0381 },
98 { 62000.0 , 3955.3185 },
99 { 63000.0 , 3832.2172 },
100 { 64000.0 , 3710.6880 },
101 { 65000.0 , 3590.6869 },
102 { 66000.0 , 3472.1715 },
103 { 67000.0 , 3355.1013 },
104 { 68000.0 , 3239.4376 },
105 { 69000.0 , 3125.1431 },
106 { 70000.0 , 3012.1820 },
107 { 71000.0 , 2900.5203 },
108 { 72000.0 , 2790.1248 },
109 { 73000.0 , 2680.9639 },
110 { 74000.0 , 2573.0073 },
111 { 75000.0 , 2466.2255 },
112 { 76000.0 , 2360.5905 },
113 { 77000.0 , 2256.0750 },
114 { 78000.0 , 2152.6530 },
115 { 79000.0 , 2050.2990 },
116 { 80000.0 , 1948.9888 },
117 { 81000.0 , 1848.6990 },
118 { 82000.0 , 1749.4067 },
119 { 83000.0 , 1651.0902 },
120 { 84000.0 , 1553.7282 },
121 { 85000.0 , 1457.3002 },
122 { 86000.0 , 1361.7865 },
123 { 87000.0 , 1267.1680 },
124 { 88000.0 , 1173.4260 },
125 { 89000.0 , 1080.5427 },
126 { 90000.0 , 988.5006 },
127 { 91000.0 , 897.2829 },
128 { 92000.0 , 806.8734 },
129 { 93000.0 , 717.2561 },
130 { 94000.0 , 628.4157 },
131 { 95000.0 , 540.3374 },
132 { 96000.0 , 453.0066 },
133 { 97000.0 , 366.4094 },
134 { 98000.0 , 280.5320 },
135 { 99000.0 , 195.3614 },
136 { 100000.0 , 110.8845 },
137 { 101000.0 , 27.0889 },
138 { 102000.0 , -56.0375 },
139 { 103000.0 , -138.5067 },
140 { 104000.0 , -220.3300 },
141 { 105000.0 , -301.5187 },
142 { 106000.0 , -382.0837 },
143 { 107000.0 , -462.0356 },
144 { 108000.0 , -541.3847 },
145 { 109000.0 , -620.1411 },
146 { 110000.0 , -698.3146 }
154 #define MPL3115_ONE_SECOND 1000000
164 void mpl3115_SetMode(int32_t *status,
void* pSensorHandle, int32_t Mode);
193 if ( NULL == pSensorHandle){
211 if (NULL == pDeviceDescriptor) {
246 _time_delay_ticks(1);
286 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
315 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
327 if (NULL == pDeviceDescriptor)
337 goto unlockdescriptor;
343 goto unlockdescriptor;
404 if(NULL == pSensorHandle){
415 if (NULL == pDeviceDescriptor)
424 goto unlockdescriptor;
430 goto unlockdescriptor;
435 goto unlockdescriptor;
464 if(NULL == pSensorHandle){
477 if (NULL == pDeviceDescriptor)
485 goto unlockdescriptor;
492 goto unlockdescriptor;
498 goto unlockdescriptor;
547 if(NULL == pSensorHandle){
577 if(NULL == pSensorHandle){
589 if (NULL == pDeviceDescriptor){
607 if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->
deviceSemaphore, 0))
609 goto unlockdescriptor;
616 goto unlockdescriptor;
633 *pFifoEntry = *pCurrentSampleBuffer;
641 pCurrentSampleBuffer,
672 void *pConvertedSample,
681 switch (convertToType)
685 pConverter = float_press1d_converter;
687 pConverter = fixed_press1d_converter;
692 pConverter = float_alt1d_converter;
694 pConverter = fixed_alt1d_converter;
699 pConverter = float_temp1d_converter;
701 pConverter = fixed_temp1d_converter;
707 if (pConverter == NULL)
710 retStat = pConverter(
712 (mpl3115_DataBuffer_t *)pNativeSample,
775 uint8 buffer[1] = {0};
790 _time_delay_ticks(1000/5);
800 uint8 buffer[1] = {0};
845 uint8 buffer[1] = {0x00};
887 _time_delay_ticks(1);
902 #define BYTES_FOR_FULL_READ 5
928 #define MPL3115_DEBUG 0
930 static uint8 mpl3115_Reg[50];
940 mpl3115_Reg[i] = buffer[0];
959 for (
uint32 reg=0; reg < pConfigSpecific->regCount; reg++)
961 buffer[0] = pConfigSpecific->regPairs[reg].regValue;
984 float fPressure = ((float)(pressure >> 12)/(float)4.0);
987 fLfi(&pressure_to_height,fPressure,&fHeight);
989 return (((
int32)(fHeight*16.0))<<12);
994 #define ABSOLUTE_VALUE(x) ( (x) < 0.0 ? (-(x)) : (x))
995 #define ZERO_EPSILON (1.0E-10)
996 #define IS_PRACTICALLY_ZERO(x) ( ABSOLUTE_VALUE(x) < ZERO_EPSILON )
1000 float delta_x_table;
1001 float delta_y_table;
1002 float delta_x_point;
1009 if ( x_in < lookupTable->dataPoints[i].x )
1023 for (i=1; i < lookupTable->
maxIdx; i++ )
1025 if ( x_in < lookupTable->dataPoints[i].x )
break;
1049 delta_x_point = x_in - lookupTable->
dataPoints[i].
x;
1050 *y_out = delta_y_table/delta_x_table *(delta_x_point) + lookupTable->
dataPoints[i].
y;
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
unsigned char uint8
This defines uint8 as unsigned char.
#define MPL3115_PRESS_FLOAT_CONVERSION_OFFSET
fsl_i2c_master_driver.h defines structures and types for the i2c master driver.
#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 ...
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.
LWSEM_STRUCT deviceSemaphore
#define MPL3115_TEMP_FLOAT_CONVERSION_OFFSET
unsigned long uint32
This defines uint32 as unsigned long.
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
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 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.
#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.
void mpl3115_ValidateConfig(int32_t *status, void *pSensorHandle, void *pSettings)
This function validates the configuration for the MPL3115 sensor.
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
long int32
This defines int32 as long.
isf_SensorDataTypes_t resultType
#define MPL3115_ALT_FIXED_CONVERSION_FACTOR
Main ISF header file. Contains code common to all ISF components.
LWEVENT_STRUCT * pEventGroup
short int16
This defines int16 as short.
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.
#define MPL3115_ONE_SECOND
isf_SensorTypes_t mpl3115_SupportedSensorTypes[]
Supported sensor and data types for MPL3115.
void mpl3115_ReadRegisters(isf_SensorHandle_t *pSensorHandle)
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
int32 convertPressureToAltitude(uint32 pressure)
isf_dsa_status_t fsl_mpl3115_i2c_1D_press_Initialize(isf_SensorHandle_t *pSensorHandle)
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.