ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_mpl3115_i2c_1D_press.c
Go to the documentation of this file.
1 /**
2  ** @file fsl_mpl3115_i2c_1D_press.c
3  ** @version 01.00
4  ** @brief
5  **
6  */
7 /**
8  ** @addtogroup fsl_mpl3115_i2c_1D_press_module fsl_mpl3115_i2c_1D_press module documentation
9  ** @{
10  */
11 
12 /* MODULE fsl_mpl3115_i2c_1D_press. */
13 
14 #include <isf.h>
15 #include <isf_types.h>
16 #include <lwmem.h>
17 #include <lwsem.h>
18 #include <lwevent.h>
19 #include <isf_sm_api.h>
20 #include <isf_dsa_adapter.h>
21 #include <isf_bm.h>
22 #include <isf_sensor_types.h>
23 #include <isf_fifo.h>
24 #include <isf_pressure_types.h>
25 #include <isf_altitude_types.h>
26 #include <isf_temperature_types.h>
27 #include <isf_comm.h>
28 #include <isf_util.h>
29 #include <isf_sensors.h>
30 #include "mpl3115.h"
31 #include "fsl_i2c_master_driver.h"
33 
34 
35 /*
36  * @brief This table contains the MPL3115 conversion factors based on the full-scale range selected.
37  */
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
50 
51 enum {
55 };
56 
57 enum {
62 };
63 
64 typedef struct {
65  float x;
66  float y;
67 } dataPair_t;
68 
69 typedef struct {
70  unsigned char maxIdx;
71  unsigned char extrapolationBehavior;
72  dataPair_t dataPoints[];
73 } fLfiTable_t;
74 
75 long fLfi( const fLfiTable_t *lookupTable, float lFiIn, float *lfiOut);
76 // ! @brief Implements pressure to height equation in MPL3115A2 data sheet section 5.3.
77 // See MPL3115_Pressure_to_Height.xlsx file in the /Doc directory for calculation
78 // and formatting of the .dataPoints.
79 //Note: The values in the table below produce an altitude value approximately accurate to 0.25 meter.
80 static const fLfiTable_t pressure_to_height = {
81  .maxIdx = 61,
82  .extrapolationBehavior = LFI_TABLE_LIMITS,
83  .dataPoints =
84  {
85  // Paste directly from MPL3115_Pressure_to_Height.xlsx columns R through V here.
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 }
147  // End paste.
148  }
149 };
150 
151 /*
152  * @brief This is the only realistic support rate (1Hz) for a timer-callback based sensor adapter.
153  */
154 #define MPL3115_ONE_SECOND 1000000
155 
158 
159 /*
160  * Local function prototypes.
161  */
162 void mpl3115_Reset(int32_t *status, void* pSensorHandle);
163 void mpl3115_CheckId(int32_t *status, void* pSensorHandle);
164 void mpl3115_SetMode(int32_t *status, void* pSensorHandle, int32_t Mode);
165 void mpl3115_ValidateConfig(int32_t *status, void* pSensorHandle, void* pSettings);
169 
170 // Converter routines for the supported data types
171 static isf_dsa_status_t float_press1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
172 static isf_dsa_status_t fixed_press1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
173 static isf_dsa_status_t float_alt1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
174 static isf_dsa_status_t fixed_alt1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
175 static isf_dsa_status_t float_temp1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
176 static isf_dsa_status_t fixed_temp1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample );
177 
178 /*
179  ** ===================================================================
180  ** Method : fsl_mpl3115_i2c_1D_press_Initialize (component ISFDSA)
181  ** @brief
182  **
183  ** Parameters :
184  ** NAME - DESCRIPTION
185  ** @param
186  ** isf_SensorHandle_t *pSensorHandle
187  ** @return
188  ** isf_dsa_status_t -
189  ** ===================================================================
190  */
192 {
193  if ( NULL == pSensorHandle){
194  return DSA_ERR_PARAM;
195  }
196 
197  int32_t status;
198 
199 
200  // Check if the sensor is available, and that it has already been initialized.
201  if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
202  return DSA_ERR_INITIALIZE;
203  }
204 
205  // Allocate the adapter specific memory for the descriptor
206  pSensorHandle->pDeviceDescriptor = (DeviceDescriptor_t *)_lwmem_alloc_system_zero(sizeof(DeviceDescriptor_t));
207 
208  // Create and validate helper reference pointers.
209  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
210 
211  if (NULL == pDeviceDescriptor) {
212  return DSA_ERR_INITIALIZE;
213  }
214 
215  // Allocate the current sample data buffer and initialize it.
216  pDeviceDescriptor->pCurrentSample = _lwmem_alloc_system_zero(sizeof(mpl3115_DataBuffer_t));
217  mpl3115_DataBuffer_t *pCurrentSampleBuffer = (mpl3115_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
218  pCurrentSampleBuffer->timestamp = 0;
219  pCurrentSampleBuffer->pressure = 0;
220  pCurrentSampleBuffer->altitude = 0;
221  pCurrentSampleBuffer->temperature = 0;
222 
223  dm_ChannelDescriptor_t *pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
224 
225  // Initialize the channel
226  if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
227  return DSA_ERR_INITIALIZE;
228  }
229 
230  // Start the Bus
231  if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
232  return DSA_ERR_INITIALIZE;
233  }
234 
235  // Get the Channel state to check if it is ready to use
236  if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
237  return DSA_ERR_INITIALIZE;
238  }
239 
240  // Open the device and get the device handler
241  if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
242  return DSA_ERR_INITIALIZE;
243  }
244 
245  // A very short delay is needed for device startup.
246  _time_delay_ticks(1);
247 
248  // Query the sensor to validate Device Messaging initialization and the sensor identity.
249  mpl3115_CheckId(&status,pSensorHandle);
250  if (ISF_SUCCESS != status)
251  {
252  return DSA_ERR_INITIALIZE;
253  }
254 
255  // Set the adapter state to be initialized.
256  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
257 
258  // Create a semaphore to synchronize the device descriptor across tasks
259  if (MQX_OK != _lwsem_create(&pDeviceDescriptor->deviceSemaphore, 1)){
260  return DSA_ERR_INITIALIZE;
261  }
262 
263  pDeviceDescriptor->skipFramecnt = 0;
264 
265  return ISF_SUCCESS;
266 }
267 
268 /*
269  ** ===================================================================
270  ** Method : fsl_mpl3115_i2c_1D_press_ValidateSettings (component ISFDSA)
271  ** @brief
272  **
273  ** Parameters :
274  ** NAME - DESCRIPTION
275  ** @param
276  ** isf_SensorHandle_t *pSensorHandle
277  ** @param
278  ** isf_SubscriptionSettings_t *pSettings
279  ** @return
280  ** isf_dsa_status_t -
281  ** ===================================================================
282  */
284 {
285  // Check the input arguments.
286  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
287  return DSA_ERR_PARAM;
288  }
289 
290  int32_t status;
291 
292  mpl3115_ValidateConfig(&status,pSensorHandle,pSensorSettings);
293 
294  return status;
295 }
296 
297 /*
298  ** ===================================================================
299  ** Method : fsl_mpl3115_i2c_1D_press_Configure (component ISFDSA)
300  ** @brief
301  **
302  ** Parameters :
303  ** NAME - DESCRIPTION
304  ** @param
305  ** isf_SensorHandle_t *pSensorHandle
306  ** @param
307  ** isf_SubscriptionSettings_t *pConfigSettings
308  ** @return
309  ** isf_dsa_status_t -
310  ** ===================================================================
311  */
313 {
314  // Check pointers.
315  if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
316  return DSA_ERR_PARAM;
317  }
318 
319  int32_t status;
320 
321  int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
322 
323  // Create helper reference pointers.
324  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) pSensorHandle->pDeviceDescriptor;
325 
326  // Check the device descriptor pointer.
327  if (NULL == pDeviceDescriptor)
328  {
329  return retStat;
330  }
331 
332  // Lock the device descriptor.
333  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
334 
335  // Check the driver state.
336  if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
337  goto unlockdescriptor;
338  }
339 
340  // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
341  // or any number of undesirable things may occur.
342  if (ISF_SUCCESS != dm_channel_acquire_lock(&pDeviceDescriptor->cDescriptor, 0)) {
343  goto unlockdescriptor;
344  }
345 
346  // Set the sensor into STANDBY mode for configuration.
347  mpl3115_SetMode(&status, pSensorHandle, SENSOR_STANDBY);
348  if (ISF_SUCCESS != status) {
349  goto unlockchannel;
350  }
351 
352  // Configure the sensor.
353  retStat = mpl3115_SetConfig(pSensorHandle, pSensorSettings);
354  if (ISF_SUCCESS != retStat) {
355  goto unlockchannel;
356  }
357 
358  // Register the periodic callback function with the Bus Manager.
359  pDeviceDescriptor->token = bm_register_periodic_callback( pSensorSettings->nSamplePeriod, fsl_mpl3115_i2c_1D_press_PeriodicCallback , pSensorHandle);
360  if(BM_ERROR & pDeviceDescriptor->token){
361  goto unlockchannel;
362  }
363 
364  //Store the configured settings
365  pSensorHandle->controlData.sensorSettings = *pSensorSettings;
366 
368  retStat = ISF_SUCCESS;
369 
370  unlockchannel:
371  // Unlock the channel.
372  // The explicit lock must be released when the configuration is done allowing the bus to be used by others.
373  // User Notice: This is a required function call.
374  status = dm_channel_release_lock(&pDeviceDescriptor->cDescriptor);
375  if (ISF_SUCCESS != status)
376  {
377  retStat = status;
378  }
379 
380  unlockdescriptor:
381 
382  // Unlock the device descriptor.
383  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
384 
385  return retStat;
386 }
387 
388 /*
389  ** ===================================================================
390  ** Method : fsl_mpl3115_i2c_1D_press_StartData (component ISFDSA)
391  ** @brief
392  **
393  ** Parameters :
394  ** NAME - DESCRIPTION
395  ** @param
396  ** isf_SensorHandle_t *pSensorHandle
397  ** @return
398  ** isf_dsa_status_t -
399  ** ===================================================================
400  */
402 {
403  // Check pointers.
404  if(NULL == pSensorHandle){
405  return DSA_ERR_PARAM;
406  }
407 
408  int32_t status;
409  int32_t retStat = DSA_ERR_START_DATA;
410 
411  // Create helper reference pointers.
412  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
413 
414  // Check the device descriptor.
415  if (NULL == pDeviceDescriptor)
416  return DSA_ERR_PARAM;
417 
418  // Lock the device descriptor.
419  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
420 
421  // Check the driver state.
422  if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
423  {
424  goto unlockdescriptor;
425  }
426 
427  // Set the sensor into ACTIVE mode for operation.
428  mpl3115_SetMode(&status, pSensorHandle, SENSOR_ACTIVE);
429  if (ISF_SUCCESS != status) {
430  goto unlockdescriptor;
431  }
432 
433  // Start the Bus Manager sampling timer.
434  if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) // Check for Bus Manager error and return on failure.
435  goto unlockdescriptor;
436 
437  // Set device to active state.
439  retStat = ISF_SUCCESS;
440 
441  unlockdescriptor:
442  // Unlock the device descriptor.
443  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
444 
445  return retStat;
446 }
447 
448 /*
449  ** ===================================================================
450  ** Method : fsl_mpl3115_i2c_1D_press_EndData (component ISFDSA)
451  ** @brief
452  **
453  ** Parameters :
454  ** NAME - DESCRIPTION
455  ** @param
456  ** isf_SensorHandle_t *pSensorHandle
457  ** @return
458  ** isf_dsa_status_t -
459  ** ===================================================================
460  */
462 {
463  // Check pointers.
464  if(NULL == pSensorHandle){
465  return DSA_ERR_PARAM;
466  }
467 
468  int32_t status;
469 
470  // Create helper reference pointers.
471  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
472 
473  // Set the default return status.
474  int32_t retStat = DSA_ERR_END_DATA;
475 
476  // Check the device descriptor.
477  if (NULL == pDeviceDescriptor)
478  return retStat;
479 
480  // Lock the device descriptor.
481  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
482 
483  // Check the driver state.
484  if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
485  goto unlockdescriptor;
486 
487  // Check that the adapter is not already started.
488  if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
489  // If it is, then stop the Bus Manager (BM) sample timer.
490  isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
491  if (BM_ERROR & bmStopStatus)
492  goto unlockdescriptor;
493  }
494 
495  // Set the sensor into STANDBY mode for configuration.
496  mpl3115_SetMode(&status, pSensorHandle, SENSOR_STANDBY);
497  if (ISF_SUCCESS != status) {
498  goto unlockdescriptor;
499  }
500 
502  retStat = ISF_SUCCESS;
503 
504 
505  unlockdescriptor:
506  // Unlock the device descriptor.
507  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
508 
509  return retStat;
510 }
511 
512 /*
513  ** ===================================================================
514  ** Method : fsl_mpl3115_i2c_1D_press_Calibrate (component ISFDSA)
515  ** @brief
516  **
517  ** Parameters :
518  ** NAME - DESCRIPTION
519  ** @param
520  ** isf_SensorHandle_t *pSensorHandle
521  ** @return
522  ** isf_dsa_status_t -
523  ** ===================================================================
524  */
526 {
527  int32_t retStat = ISF_SUCCESS;
528 
529  return retStat;
530 }
531 
532 /*
533  ** ===================================================================
534  ** Method : fsl_mpl3115_i2c_1D_press_Shutdown (component ISFDSA)
535  ** @brief
536  **
537  ** Parameters :
538  ** NAME - DESCRIPTION
539  ** @param
540  ** isf_SensorHandle_t *pSensorHandle
541  ** @return
542  ** isf_dsa_status_t -
543  ** ===================================================================
544  */
546 {
547  if(NULL == pSensorHandle){
548  return DSA_ERR_PARAM;
549  }
550 
551  // Create helper reference pointers.
552  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
553 
554  // Remove the sensor adapter from the Bus Manager callbacks.
555  bm_unregister_callback(pDeviceDescriptor->token);
556  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
557  return ISF_SUCCESS;
558 
559 }
560 
561 /*
562  ** ===================================================================
563  ** Method : fsl_mpl3115_i2c_1D_press_PeriodicCallback (component ISFDSA)
564  ** @brief
565  **
566  ** Parameters :
567  ** NAME - DESCRIPTION
568  ** @param
569  ** void* pSensorHandle -
570  ** @return
571  ** void -
572  ** ===================================================================
573  */
575 {
576  // Check pointers.
577  if(NULL == pSensorHandle){
578  return;
579  }
580 
581  // Create helper reference pointers.
582  volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
584  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
585  isf_status_t st;
586  int32 numBytes;
587 
588  // Check the device descriptor
589  if (NULL == pDeviceDescriptor){
590  return;
591  }
592 
593  // Create a helper pointer to the current sample buffer.
594  mpl3115_DataBuffer_t *pCurrentSampleBuffer = (mpl3115_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
595 
596  // Apply sample skip if necessary.
597  if (pDeviceDescriptor->skipFramecnt) {
598  // Not done skipping samples.
599  --pDeviceDescriptor->skipFramecnt;
600  return;
601  }
602 
603  // Get the time stamp
604  pCurrentSampleBuffer->timestamp = isf_time_util_get_usec();
605 
606  // Lock the device descriptor.
607  if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0))
608  {
609  goto unlockdescriptor;
610  }
611 
612 
613  // Check the driver state.
614  if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
615  {
616  goto unlockdescriptor;
617  }
618 
619  // Get sensor data.
620  mpl3115_GetData(pSensorHandle, pCurrentSampleBuffer); // Returns samples in big endian.
621 
622  // Lock the fifo for update.
623  if(MQX_OK != isf_fifo_lock(pFifo)){
624  return;
625  }
626 
628 
629 
630  // write the new data
632  {
633  *pFifoEntry = *pCurrentSampleBuffer;
634  }
635  else
636  {
638  pSensorHdl,
641  pCurrentSampleBuffer,
642  pFifoEntry,
643  &numBytes);
644  }
645 
646  // Increment the fifo to the next sample entry.
647  st = isf_fifo_el_increment(pFifo);
648 
649  // Unlock the fifo.
650  isf_fifo_unlock(pFifo);
651 
652  if (st == ISF_FIFO_FULL)
653  {
654  // Notify the user using their registered event information
655  _lwevent_set(pSensorHdl->controlData.pEventGroup,(_mqx_uint)pSensorHdl->controlData.nEventFieldIndex);
656  }
657 
658  unlockdescriptor:
659  // Unlock the device descriptor.
660  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
661 
662 }
663 
664 /*!
665  * @brief This function coverts the raw sample data to the desired output type.
666  */
668 (
669  volatile isf_SensorHandle_t *pSensorHandle,
670  isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
671  void *pNativeSample,
672  void *pConvertedSample,
673  int32 *numBytes
674 )
675 {
678 
679  pConverter = NULL;
680 
681  switch (convertToType)
682  {
683  case TYPE_PRESSURE:
684  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
685  pConverter = float_press1d_converter;
686  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
687  pConverter = fixed_press1d_converter;
688  break;
689 
690  case TYPE_ALTITUDE:
691  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
692  pConverter = float_alt1d_converter;
693  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
694  pConverter = fixed_alt1d_converter;
695  break;
696 
697  case TYPE_TEMPERATURE:
698  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
699  pConverter = float_temp1d_converter;
700  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
701  pConverter = fixed_temp1d_converter;
702  break;
703 
704  default:
706  }
707  if (pConverter == NULL)
709 
710  retStat = pConverter(
712  (mpl3115_DataBuffer_t *)pNativeSample,
713  pConvertedSample
714  );
715 
716  return retStat;
717 }
718 
719 static isf_dsa_status_t float_press1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
720 {
721  isf_KiloPascals1D_float_t *convertedSample = (isf_KiloPascals1D_float_t *)vpConvertedSample;
722  convertedSample->timestamp = nativeSample->timestamp;
724  return ISF_SUCCESS;
725 }
726 
727 static isf_dsa_status_t fixed_press1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
728 {
729  isf_KiloPascals1D_EngFixed_t *convertedSample = (isf_KiloPascals1D_EngFixed_t *)vpConvertedSample;
730  convertedSample->timestamp = nativeSample->timestamp;
732  return ISF_SUCCESS;
733 }
734 
735 
736 static isf_dsa_status_t float_alt1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
737 {
738  isf_Meters1D_float_t *convertedSample = (isf_Meters1D_float_t *)vpConvertedSample;
739  convertedSample->timestamp = nativeSample->timestamp;
740  // Convert the sensor pressure measurement into altitude.
742  return ISF_SUCCESS;
743 }
744 
745 static isf_dsa_status_t fixed_alt1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
746 {
747  isf_Meters1D_EngFixed_t *convertedSample = (isf_Meters1D_EngFixed_t *)vpConvertedSample;
748  convertedSample->timestamp = nativeSample->timestamp;
750  return ISF_SUCCESS;
751 }
752 
753 static isf_dsa_status_t float_temp1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
754 {
755  isf_DegreesCelsius1D_float_t *convertedSample = (isf_DegreesCelsius1D_float_t *)vpConvertedSample;
756  convertedSample->timestamp = nativeSample->timestamp;
758  return ISF_SUCCESS;
759 }
760 
761 static isf_dsa_status_t fixed_temp1d_converter(mpl3115_Sensor_Specific_Settings_t *pSensorSpecificConfig, mpl3115_DataBuffer_t *nativeSample, void *vpConvertedSample )
762 {
763  isf_DegreesCelsius1D_EngFixed_t *convertedSample = (isf_DegreesCelsius1D_EngFixed_t *)vpConvertedSample;
764  convertedSample->timestamp = nativeSample->timestamp;
766  return ISF_SUCCESS;
767 }
768 
769 /*!
770  * @brief This function resets the MPL3115 sensor resulting in a default configuration for
771  * all registers.
772  */
773 void mpl3115_Reset(int32_t* status, void* pSensorHandle)
774 {
775  uint8 buffer[1] = {0};
776 
777  // Create and validate helper reference pointers.
778  isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
779  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
780  dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
781 
782  // Reset the device.
783  // Put the device the STANDBY state which is required before any configuration registers are set.
784  buffer[0]= MPL3115_RST_MASK; // no shift
785  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, MPL3115_CTRL_REG1, buffer, 1, 1)){
786  *status = DSA_ERR_INITIALIZE;
787  return;
788  }
789 
790  _time_delay_ticks(1000/5); // Turn-on time = 1 second (MPL3115 Data Sheet) for OSR = 2^7 (128).
791 
792  *status = ISF_SUCCESS;
793 }
794 
795 /*!
796  * @brief This function validates the MPL3115 sensor is connected via the I2C bus.
797  */
798 void mpl3115_CheckId(int32_t *status, void* pSensorHandle)
799 {
800  uint8 buffer[1] = {0};
801  int32 retStat = SENSOR_ERROR_CHECKID;
802 
803  // Create and validate helper reference pointers.
804  isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
805  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
806  dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
807 
808  if (ISF_SUCCESS != dm_device_read(pDeviceHandle, MPL3115_WHO_AM_I, &buffer[0], 1, 1)){
809  *status = retStat;
810  }
811  if (MPL3115_WHOAMI_VALUE != buffer[0]) {
812  *status = retStat;
813  }
814 
815  *status = ISF_SUCCESS;
816 }
817 
818 /*!
819  * @brief This function validates the configuration for the MPL3115 sensor.
820  */
821 void mpl3115_ValidateConfig(int32_t* status, void* pSensorHandle, void* pSettings)
822 {
823  isf_dsa_SensorSettings_t *pConfig = (isf_dsa_SensorSettings_t*)pSettings;
824 
825  // Validate the configuration data using the global data
826  if (pConfig->nSamplePeriod != MPL3115_ONE_SECOND)
827  {
829  *status = DSA_RET_SETTINGS_CHANGED;
830  return;
831  }
832 
833  *status = ISF_SUCCESS;
834 }
835 
836 /*!
837  * @brief This function sets the MPL3115 part to the requested mode.
838  */
839 void mpl3115_SetMode(int32_t* status, void* pSensorHandle, int32_t Mode)
840 {
841  isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
842  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
843  dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
844 
845  uint8 buffer[1] = {0x00};
846 
847  switch(Mode)
848  {
849  // This will put the sensor into the standby mode
850  case SENSOR_STANDBY:
851  case SENSOR_BOOT:
852  case SENSOR_READY:
853  {
854  // this sensor requires read-modify-write
855  if (ISF_SUCCESS != dm_device_read(pDeviceHandle, MPL3115_CTRL_REG1, buffer, 1, 1) ){
856  *status = SENSOR_ERROR_SETMODE;
857  return;
858  }
859  buffer[0] = (buffer[0] & ~MPL3115_ACTIVE_MASK);
860  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, MPL3115_CTRL_REG1, buffer, 1, 1) ){
861  *status = SENSOR_ERROR_SETMODE;
862  return;
863  }
864  }
865  break;
866 
867  // This will put the sensor into the active state
868  case SENSOR_ACTIVE:
869  {
870  // this sensor requires read-modify-write
871  if (ISF_SUCCESS != dm_device_read(pDeviceHandle, MPL3115_CTRL_REG1, buffer, 1, 1) ){
872  *status = SENSOR_ERROR_SETMODE;
873  return;
874  }
875  buffer[0] = (buffer[0] | MPL3115_ACTIVE_MASK);
876  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, MPL3115_CTRL_REG1, buffer, 1, 1) ){
877  *status = SENSOR_ERROR_SETMODE;
878  return;
879  }
880  // Read the value of the status register to wait for valid data
881  buffer[0] = 0;
882  do {
883  if (ISF_SUCCESS != dm_device_read(pDeviceHandle, MPL3115_STATUS_00, buffer, 1, 1) ){
884  *status = SENSOR_ERROR_SETMODE;
885  return;
886  }
887  _time_delay_ticks(1); // short delay to yield CPU/RTOS.
888  } while (0 == MPL3115_GET_FIELD(PTDR,buffer[0]) ); // Wait for Data Ready.
889  }
890  break;
891 
892  default:
893  *status = SENSOR_ERROR_SETMODE;
894  return;
895  }
896  // return success
897  *status = ISF_SUCCESS;
898 }
899 /*!
900  * @brief This function retrieves the raw data from the MPL3115 sensor.
901  */
902 #define BYTES_FOR_FULL_READ 5
903 
905 {
907 
908  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
909  dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
910 
911  uint8 registerData[BYTES_FOR_FULL_READ];
912 
913  // read the full width of the data for both full or short reads
915  {
916  return retStat;
917  }
918  // copy the pressure data into the raw sample buffer.
919  pData->pressure = (((uint32)registerData[0]) << 24) | (((uint32)registerData[1] << 16)) | (((uint32)registerData[2] << 8));
921  // copy the temperature data into the destination buffer.
922  pData->temperature = (int16)(((int16)registerData[3]) << 8) | (((uint32)registerData[4]));
923 
924  // return success
925  return ISF_SUCCESS;
926 }
927 
928 #define MPL3115_DEBUG 0
929 #ifdef MPL3115_DEBUG
930 static uint8 mpl3115_Reg[50];
932 {
933  uint8 buffer[1];
934  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
935  dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
936 
937  for (uint8 i = MPL3115_WHO_AM_I; i<=MPL3115_OFF_H; i++)
938  {
939  dm_device_read(pDeviceHandle, i, buffer, 1, 1);
940  mpl3115_Reg[i] = buffer[0];
941  }
942 }
943 #endif
944 
945 /*!
946  * @brief This function sets the MPL3115 sensor configuration.
947  */
949 {
950  int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
951 
952  // Create helper reference pointers.
953  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) pSensorHandle->pDeviceDescriptor;
955  dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
956 
957  /* Write the sensor specific data based on the pre-computed register level pairs (Addr, Value) */
958  uint8 buffer[1];
959  for (uint32 reg=0; reg < pConfigSpecific->regCount; reg++)
960  {
961  buffer[0] = pConfigSpecific->regPairs[reg].regValue;
962  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, pConfigSpecific->regPairs[reg].regAddr,&buffer[0],1,1))
963  {
964  return retStat;
965  }
966  }
967 
968  // Set up the Control register #1 functions: ODR override for SLEEP mode and the WAKE mode ODR.
969  buffer[0] = MPL3115_SET_FIELD(ST,0); // Set to 1 Hz
970  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, MPL3115_CTRL_REG2, buffer, 1, 1) ) return MPL3115_ERROR;
971 
972 #ifdef MPL3115_DEBUG
973  // DEBUG: Read back the entire set of device registers
974  mpl3115_ReadRegisters( pSensorHandle );
975 #endif
976 
977  return ISF_SUCCESS;
978 }
979 
981 {
982  // pressure from sensor is 20-bit unsigned and shift to LSB.
983  // LS 2-bits are fractional Pascals, so shift, cast, then divide by 2^2.
984  float fPressure = ((float)(pressure >> 12)/(float)4.0);
985  float fHeight;
986 
987  fLfi(&pressure_to_height,fPressure,&fHeight);
988 
989  return (((int32)(fHeight*16.0))<<12);
990 }
991 
992 
993 
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 )
997 long fLfi(const fLfiTable_t *lookupTable, float x_in, float *y_out)
998 {
999  int i = 0;
1000  float delta_x_table;
1001  float delta_y_table;
1002  float delta_x_point;
1003 
1004  if (lookupTable == 0 ) return LFI_BAD_PTR;
1005 
1006  if (lookupTable->maxIdx < 1) return LFI_BAD_TABLE;
1007 
1008  /* Check if x_in is below the table bottom */
1009  if ( x_in < lookupTable->dataPoints[i].x )
1010  {
1011  if ( lookupTable->extrapolationBehavior == LFI_TABLE_LIMITS )
1012  {
1013  *y_out = lookupTable->dataPoints[i].y;
1014  return LFI_SUCCESS;
1015  }
1016  else if (lookupTable->extrapolationBehavior == LFI_NO_EXTRAPOLATION )
1017  {
1018  return LFI_OUT_OF_RANGE;
1019  }
1020  }
1021 
1022  /* just use sequential search for now */
1023  for (i=1; i < lookupTable->maxIdx; i++ )
1024  {
1025  if ( x_in < lookupTable->dataPoints[i].x ) break;
1026  }
1027 
1028  /* Check if x_in is above the table top */
1029  if ( x_in > lookupTable->dataPoints[i].x )
1030  {
1031  if (lookupTable->extrapolationBehavior == LFI_TABLE_LIMITS)
1032  {
1033  *y_out = lookupTable->dataPoints[i].y;
1034  return LFI_SUCCESS;
1035  }
1036  else if ( lookupTable->extrapolationBehavior == LFI_NO_EXTRAPOLATION )
1037  {
1038  return LFI_OUT_OF_RANGE;
1039  }
1040  }
1041 
1042  /* Perform interpolation/extrapolation */
1043  delta_x_table = lookupTable->dataPoints[i].x - lookupTable->dataPoints[i-1].x;
1044  if ( IS_PRACTICALLY_ZERO(delta_x_table))
1045  {
1046  return LFI_BAD_TABLE;
1047  }
1048  delta_y_table = lookupTable->dataPoints[i].y - lookupTable->dataPoints[i-1].y;
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;
1051 
1052  return LFI_SUCCESS;
1053 }
1054 /*
1055  * Local Subroutines
1056  */
1057 
1058 /*!
1059  ** @}
1060  */
1061 /* END fsl_mpl3115_i2c_1D_press.c */
1062 
1063 
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.
Definition: isf_types.h:18
#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.
Definition: isf_util.c:52
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.
const void * commInfo
isf_dsa_ControlData_t controlData
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
Definition: isf_fifo.c:171
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.
Definition: isf_fifo.c:202
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.
Definition: isf_fifo.c:240
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
#define FALSE
Definition: isf_types.h:56
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
Definition: isf_sensors.h:52
#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.
Definition: isf_sensors.h:49
LWSEM_STRUCT deviceSemaphore
Definition: isf_sensors.h:54
#define MPL3115_TEMP_FLOAT_CONVERSION_OFFSET
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
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
isf_SensorTypes_t
dm_ChannelDescriptor_t cDescriptor
Definition: isf_sensors.h:51
unsigned char maxIdx
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
Definition: mpl3115.h:102
#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
Definition: mpl3115.h:109
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
mpl3115_status_t
Definition: mpl3115.h:219
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)
#define MPL3115_RST_MASK
Definition: mpl3115.h:148
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.
#define MPL3115_ALT_FLOAT_CONVERSION_FACTOR
isf_dsa_result_types_t resultFormat
isf_SensorDataTypes_t
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.
Definition: isf_types.h:32
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.
Definition: isf_types.h:23
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)
Definition: mpl3115.h:82
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_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...
Definition: isf_bm.h:57
unsigned char extrapolationBehavior
int32 isf_status_t
ISF return status type.
Definition: isf.h:51
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)
Definition: mpl3115.h:83
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:232
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.
Definition: isf_devmsg.h:61
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.
Definition: isf_devmsg.h:50
#define ISF_FIFO_FULL
Definition: isf_fifo.h:32
dataPair_t dataPoints[]
bm_callback_token_t token
Definition: isf_sensors.h:53
#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.