ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
fsl_Sensor_Analog_1_Functions.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** Filename : fsl_Sensor_Analog_1_Functions.c
3 ** Project : ISF2P2_K64F_MQX_PROJ
4 ** Processor : MK64FN1M0VLL12
5 ** Component : Events
6 ** Version : Driver 01.00
7 ** Compiler : GNU C Compiler
8 ** Date/Time : 2016-10-06, 13:38, # CodeGen: 0
9 ** Abstract :
10 ** This is user's event module.
11 ** Put your event handler code here.
12 ** Settings :
13 ** Contents :
14 ** Analog_1__Void_ - void Analog_1__Void_(void);
15 ** Analog_1_fsl_Sensor_Generic_Analog_Convert - void Analog_1_fsl_Sensor_Generic_Analog_Convert(void);
16 ** Analog_1_fsl_Sensor_Generic_AnalogCallback - void Analog_1_fsl_Sensor_Generic_AnalogCallback(void);
17 ** Analog_1_fsl_Sensor_Generic_Analog_Shutdown - void Analog_1_fsl_Sensor_Generic_Analog_Shutdown(void);
18 ** Analog_1_fsl_Sensor_Generic_Analog_EndData - void Analog_1_fsl_Sensor_Generic_Analog_EndData(void);
19 ** Analog_1_fsl_Sensor_Generic_Analog_StartData - void Analog_1_fsl_Sensor_Generic_Analog_StartData(void);
20 ** Analog_1_fsl_Sensor_Generic_Analog_Configure - void Analog_1_fsl_Sensor_Generic_Analog_Configure(void);
21 ** Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings - void Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings(void);
22 ** Analog_1_fsl_Sensor_Generic_Analog_Initialize - void Analog_1_fsl_Sensor_Generic_Analog_Initialize(void);
23 **
24 ** ###################################################################*/
25 /*!
26 ** @file fsl_Sensor_Analog_1_Functions.c
27 ** @version 01.00
28 ** @brief
29 ** This is user's event module.
30 ** Put your event handler code here.
31 */
32 /*!
33 ** @addtogroup fsl_Sensor_Analog_1_Functions_module fsl_Sensor_Analog_1_Functions module documentation
34 ** @{
35 */
36 /* MODULE fsl_Sensor_Analog_1_Functions */
37 
38 #include "Cpu.h"
39 #include "Events.h"
40 #include "rtos_main_task.h"
41 #include "os_tasks.h"
42 #include "App1_Functions.h"
43 #include "BasicApp1_Functions.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 
52 /* User includes (#include below this line is not maintained by Processor Expert) */
53 
54 
56 {} /* This function is a place holder used to contain TypeDefs and not used. */
57 
58 #define Analog_1_CONVERT_FLOAT_FACTOR (1.0F/32767.0F)
59 #define Analog_1_CONVERT_FIXED_FACTOR (32767)
60 #define NUM_MESSAGES 64
61 #define MSG_SIZE 1
62 
63 uint8_t sensorType = 0;
64 uint8_t numGpios = 1;
65 uint8_t configuredADCh = 1;
66 
67 uint32_t operating_mode;
68 
69 /*! Dummy non i2c device settings. */
71 {
72  .dummy = 0,
73  .address = NULL // Device address.
74 };
75 
76 
77 /* Updated as per FXLN83xxQ sensor configuration. */
79 {
80  .fullScaleRange = 0, // Min Accelerometer Operating Range for FXLN83x1Qs.
81  .offset = 0, // Fixed zero-g offset of FXLN83xxQ.
82 
83 };
84 
85 /*! @brief Supported sensor and data types for the Sensor */
87 {
89 };
90 
92 {
94 };
95 
96 static isf_dsa_status_t apply_sensor_specific_configurations();
97 
98 /*
99  * @brief This table contains the Analog Voltage to Accel conversion factors based on
100  the full-scale range selected. /More Work on Conversion Factor /
101  */
102 typedef struct
103 {
104  /* Fixed zero-g offset */
105  float offset;
106  /* Conversion Factor */
107  float convFactor;
109 
110 static AnalogVoltagetoOutputConvTable_t AnalogVoltagetoOutputConvTable;
111 
112 //{
113 // { 0.750, 4.367 }, /* Conversion Table for FXLN83x1Q +-2 g mode */
114 // { 0.750, 17.544 }, /* Conversion Table for FXLN83x1Q +-8 g mode */
115 // { 0.750, 8.696 }, /* Conversion Table for FXLN83x2Q +-4 g mode */
116 // { 0.750, 34.483 } /* Conversion Table for FXLN83x2Q +-16 g mode */
117  /* Insert custom conversion table here for any analog sensor */
118 //};
119 
120 static isf_dsa_status_t apply_sensor_specific_configurations()
121 {
122  uint32_t st_pin;
123  uint32_t en_pin;
124  uint32_t gselect_pin;
125 
126 
127  return ISF_SUCCESS;
128 
129 }
130 
131 isf_dsa_status_t Analog_1_float_converter(Analog_1_Sensor_Specific_Settings_t *pSensorSpecificConfig, Analog_1_DataBuffer_t *nativeSample, void *vpConvertedSample)
132 {
133  uint8_t index;
134  Analog_1_SensorData_Float_t *convertedSample = (Analog_1_SensorData_Float_t *)vpConvertedSample;
135  convertedSample->timestamp = nativeSample->timeStamp;
136  // Convert the sensor analog output voltage to the chosen output format full-scale range.
137  for (index = 0; index < configuredADCh; index++)
138  {
139  convertedSample->sensorData[index] =
140  ((nativeSample->data[index] * AnalogVoltagetoOutputConvTable.convFactor) - AnalogVoltagetoOutputConvTable.offset) * Analog_1_CONVERT_FLOAT_FACTOR;
141  }
142 
143  return ISF_SUCCESS;
144 }
145 
146 isf_dsa_status_t Analog_1_fixed_converter(Analog_1_Sensor_Specific_Settings_t *pSensorSpecificConfig, Analog_1_DataBuffer_t *nativeSample, void *vpConvertedSample)
147 {
148  uint8_t index;
149  Analog_1_SensorData_Fixed_t *convertedSample = (Analog_1_SensorData_Fixed_t *)vpConvertedSample;
150  convertedSample->timestamp = nativeSample->timeStamp;
151  // Convert the sensor analog output voltage to the chosen output format full-scale range.
152  for (index = 0; index < configuredADCh; index++)
153  {
154  convertedSample->sensorData[index] =
155  ((nativeSample->data[index] * AnalogVoltagetoOutputConvTable.convFactor) - AnalogVoltagetoOutputConvTable.offset) * Analog_1_CONVERT_FIXED_FACTOR;
156  }
157 
158  return ISF_SUCCESS;
159 }
160 
161 /* Warning: Do not edit the wraper functions below, all changes should be confined to the actual functions defined later. */
162 isf_dsa_status_t fsl_Sensor_Analog_1_Convert(isf_SensorHandle_t* pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void* pNativeSample, void* pConvertedSample, int32_t *numBytes)
163 {
164  int8_t retVal = 0;
165  Analog_1_fsl_Sensor_Generic_Analog_Convert(pSensorHandle, convertToType, resultType, pNativeSample, pConvertedSample, numBytes, &retVal);
166  return retVal;
167 }
169 {
170  int8_t retVal = 0;
171  Analog_1_fsl_Sensor_Generic_Analog_Configure(pSensorHandle, pSensorSettings, &retVal);
172  return retVal;
173 }
175 {
176  int8_t retVal = 0;
177  Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings(pSensorHandle, pSensorSettings, &retVal);
178  return retVal;
179 }
181 {
182  int8_t retVal = 0;
183  Analog_1_fsl_Sensor_Generic_Analog_Initialize(pSensorHandle, &retVal);
184  return retVal;
185 }
187 {
188  int8_t retVal = 0;
189  Analog_1_fsl_Sensor_Generic_Analog_StartData(pSensorHandle, &retVal);
190  return retVal;
191 }
193 {
194  int8_t retVal = 0;
195  Analog_1_fsl_Sensor_Generic_Analog_EndData(pSensorHandle, &retVal);
196  return retVal;
197 }
199 {
200  int8_t retVal = 0;
201  Analog_1_fsl_Sensor_Generic_Analog_Shutdown(pSensorHandle, &retVal);
202  return retVal;
203 }
204 
205 
206 /*
207 ** ===================================================================
208 ** Event : Analog_1_fsl_Sensor_Generic_Analog_Convert (module fsl_Sensor_Analog_1_Functions)
209 **
210 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
211 ** @brief
212 ** Parameters :
213 ** NAME - DESCRIPTION
214 ** @param
215 ** @param
216 ** @param
217 ** @param
218 ** @param
219 ** @param
220 ** @param
221 ** @return
222 ** Returns : Nothing
223 ** ===================================================================
224 */
225 void Analog_1_fsl_Sensor_Generic_Analog_Convert(void* pSensorHandle, uint32_t convertToType, uint8_t resultType, void* pNativeSample, void* pConvertedSample, int32_t *numBytes, int8_t *retValue)
226 {
229 
230  pConverter = NULL;
231  switch (convertToType)
232  {
234  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
235  {
236  pConverter = Analog_1_float_converter;
237  }
238  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
239  {
240  pConverter = Analog_1_fixed_converter;
241  }
242  break;
243 
244  case TYPE_PRESSURE:
245  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
246  {
247  pConverter = Analog_1_float_converter;
248  }
249  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
250  {
251  pConverter = Analog_1_fixed_converter;
252  }
253  break;
254 
255  default:
256  *retValue = DSA_ERR_BAD_SENSOR_DATA_TYPE;
257  }
258  if (pConverter == NULL)
259  {
260  *retValue = DSA_ERR_BAD_RESULT_TYPE;
261  }
262 
263  retStat = pConverter(
264  (Analog_1_Sensor_Specific_Settings_t*)((isf_SensorHandle_t*)pSensorHandle)->pSensorStaticConfig->pSensorSpecificSettings,
265  (Analog_1_DataBuffer_t *)pNativeSample, pConvertedSample);
266 
267  *retValue = retStat;
268 }
269 
270 /*
271 ** ===================================================================
272 ** Event : Analog_1_fsl_Sensor_Generic_AnalogCallback (module fsl_Sensor_Analog_1_Functions)
273 **
274 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
275 ** @brief
276 ** Parameters :
277 ** NAME - DESCRIPTION
278 ** @param
279 ** @return
280 ** Returns : Nothing
281 ** ===================================================================
282 */
284 {
285  // Check the input argument
286  if (NULL == pSensorHandle)
287  {
288  return;
289  }
290 
291  // Get the sensor handle
292  isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
294  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
295  isf_status_t st;
296  int32 numBytes;
297  uint8_t index;
298 
299  // Check the device descriptor
300  if (NULL == pDeviceDescriptor)
301  {
302  return;
303  }
304 
305  // Create a helper pointer to the current sample buffer.
306  Analog_1_DataBuffer_t *pCurrentSampleBuffer = (Analog_1_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
307 
308  // Get the time stamp
309  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
310 
311  //Wait for the latest ADC conversion to be complete
312  //Get the conversion value using the ADC16 module
313  for (index = 0; index < configuredADCh; index++)
314  {
315  ADC16_DRV_WaitConvDone(FSL_ADC1, kAdc16Chn29);
316  pCurrentSampleBuffer->data[index] = ADC16_DRV_GetConvValueRAW(FSL_ADC1, kAdc16Chn29);
317  }
318 
319  // Lock the device descriptor.
320  if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
321  {
322  goto unlockdescriptor;
323  }
324 
325  // Check the driver state.
326  if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
327  {
328  goto unlockdescriptor;
329  }
330 
331  // Lock the fifo for update.
332  if(kStatus_OSA_Success != isf_fifo_lock(pFifo))
333  {
334  return;
335  }
336 
338  // write the new data
340  {
341  *pFifoEntry = *pCurrentSampleBuffer;
342  }
343  else
344  {
346  pSensorHdl,
349  pCurrentSampleBuffer, pFifoEntry, &numBytes);
350  }
351 
352  // Increment the fifo to the next sample entry.
353  st = isf_fifo_el_increment(pFifo);
354  // Unlock the fifo.
355  isf_fifo_unlock(pFifo);
356  if (st == ISF_FIFO_FULL)
357  { // Notify the user using their registered event information
358  OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
359  }
360 
361  unlockdescriptor:
362  // Unlock the device descriptor.
363  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
364 }
365 
366 /*
367 ** ===================================================================
368 ** Event : Analog_1_fsl_Sensor_Generic_Analog_Shutdown (module fsl_Sensor_Analog_1_Functions)
369 **
370 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
371 ** @brief
372 ** Parameters :
373 ** NAME - DESCRIPTION
374 ** @param
375 ** @param
376 ** @return
377 ** Returns : Nothing
378 ** ===================================================================
379 */
380 void Analog_1_fsl_Sensor_Generic_Analog_Shutdown(void* pSensorHandle, int8_t *retValue)
381 {
382  if(NULL == pSensorHandle)
383  {
384  *retValue = DSA_ERR_PARAM;
385  }
386 
387  int32_t status;
388 
389  // Create helper reference pointers.
390  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor;
391 
392  ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus = DSA_STATE_INITIALIZED;
393 
394  //De-initialize the ADC16 module
395  ADC16_DRV_Deinit(FSL_ADC1);
396 
397  *retValue = ISF_SUCCESS;
398 }
399 
400 /*
401 ** ===================================================================
402 ** Event : Analog_1_fsl_Sensor_Generic_Analog_EndData (module fsl_Sensor_Analog_1_Functions)
403 **
404 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
405 ** @brief
406 ** Parameters :
407 ** NAME - DESCRIPTION
408 ** @param
409 ** @param
410 ** @return
411 ** Returns : Nothing
412 ** ===================================================================
413 */
414 void Analog_1_fsl_Sensor_Generic_Analog_EndData(void* pSensorHandle, int8_t *retValue)
415 {
416  // Check pointers.
417  if(NULL == pSensorHandle)
418  {
419  *retValue = DSA_ERR_PARAM;
420  }
421 
422  // Set the default return status.
423  int32_t retStat = DSA_ERR_END_DATA;
424 
425  // Create helper reference pointers.
426  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor;
427 
428  // Check the device descriptor.
429  if (NULL == pDeviceDescriptor)
430  {
431  *retValue = retStat;
432  }
433 
434  // Lock the device descriptor.
435  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
436 
437  // Check the driver state.
438  if (DSA_STATE_CONFIGURED_STOPPED >= ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus)
439  {
440  goto unlockdescriptor;
441  }
442 
443  // Set the sensor into STANDBY mode for configuration.
444  /*** Write you interface specific device i/o code here ***/
445 
446  ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
447  retStat = ISF_SUCCESS;
448 
449  unlockdescriptor:
450  // Unlock the device descriptor.
451  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
452 
453  *retValue = retStat;
454 }
455 
456 /*
457 ** ===================================================================
458 ** Event : Analog_1_fsl_Sensor_Generic_Analog_StartData (module fsl_Sensor_Analog_1_Functions)
459 **
460 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
461 ** @brief
462 ** Parameters :
463 ** NAME - DESCRIPTION
464 ** @param
465 ** @param
466 ** @return
467 ** Returns : Nothing
468 ** ===================================================================
469 */
470 void Analog_1_fsl_Sensor_Generic_Analog_StartData(void* pSensorHandle, int8_t *retValue)
471 {
472  // Check pointers.
473  if(NULL == pSensorHandle)
474  {
475  *retValue = DSA_ERR_PARAM;
476  }
477 
478  int32_t status = ISF_SUCCESS;
479  int32_t retStat = DSA_ERR_START_DATA;
480 
481  // Create helper reference pointers.
482  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor;
483 
484  // Check the device descriptor.
485  if (NULL == pDeviceDescriptor)
486  {
487  *retValue = DSA_ERR_PARAM;
488  }
489 
490  // Lock the device descriptor.
491  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
492 
493  // Check the driver state.
494  if (DSA_STATE_CONFIGURED_STOPPED > ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus)
495  {
496  goto unlockdescriptor;
497  }
498 
499  /*** Write you interface specific device i/o code here ***/
500  //Configure the ADC conversion channel
501  ADC16_DRV_ConfigConvChn(FSL_ADC1, kAdc16Chn29, &(ADC1_ChnConfig0));
502 
503  // Set device to active state.
504  ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus = DSA_STATE_CONFIGURED_STARTED;
505  retStat = ISF_SUCCESS;
506 
507  unlockdescriptor:
508  // Unlock the device descriptor.
509  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
510 
511  *retValue = retStat;
512 }
513 
514 /*
515 ** ===================================================================
516 ** Event : Analog_1_fsl_Sensor_Generic_Analog_Configure (module fsl_Sensor_Analog_1_Functions)
517 **
518 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
519 ** @brief
520 ** Parameters :
521 ** NAME - DESCRIPTION
522 ** @param
523 ** @param
524 ** @param
525 ** @return
526 ** Returns : Nothing
527 ** ===================================================================
528 */
529 void Analog_1_fsl_Sensor_Generic_Analog_Configure(void* pSensorHandle, void* pSensorSettings, int8_t *retValue)
530 {
531  int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
532  int32_t sensorConfStat;
533  // Check the input arguments.
534  if((NULL == pSensorHandle) || (NULL == pSensorSettings))
535  {
536  *retValue = DSA_ERR_PARAM;
537  }
538 
539  // Create helper reference pointers.
540  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) ((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor;
541 
542  // Check the device descriptor pointer.
543  if (NULL == pDeviceDescriptor)
544  {
545  *retValue = retStat;
546  }
547 
548  // Configure GPIOs and output conversion table for chosen analog sensor type
549  sensorConfStat = apply_sensor_specific_configurations();
550  if (ISF_SUCCESS != sensorConfStat)
551  {
552  retStat = DSA_ERR_CONFIGURE;
553  }
554  retStat = ISF_SUCCESS;
555 
556  // Lock the device descriptor.
557  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
558 
559  // Check the driver state.
560  if (DSA_STATE_INITIALIZED > ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus)
561  {
562  goto unlockdescriptor;
563  }
564 
565  // Register the periodic callback function with the Bus Manager.
566  pDeviceDescriptor->token = bm_register_periodic_callback(((isf_dsa_SensorSettings_t*)pSensorSettings)->nSamplePeriod, Analog_1_fsl_Sensor_Generic_AnalogCallback , ((isf_SensorHandle_t *)pSensorHandle));
567  if(BM_ERROR & pDeviceDescriptor->token)
568  {
569  goto unlockdescriptor;
570  }
571 
572  //Store the configured settings
573  ((isf_SensorHandle_t *)pSensorHandle)->controlData.sensorSettings = *((isf_dsa_SensorSettings_t*)pSensorSettings);
574  ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
575 
576  unlockdescriptor:
577  // Unlock the device descriptor.
578  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
579 
580  *retValue = retStat;
581 }
582 
583 /*
584 ** ===================================================================
585 ** Event : Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings (module fsl_Sensor_Analog_1_Functions)
586 **
587 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
588 ** @brief
589 ** Parameters :
590 ** NAME - DESCRIPTION
591 ** @param
592 ** @param
593 ** @param
594 ** @return
595 ** Returns : Nothing
596 ** ===================================================================
597 */
598 void Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings(void* pSensorHandle, void* pSensorSettings, int8_t *retValue)
599 {
600  // Check the input arguments.
601  if ((NULL == pSensorHandle) || (NULL == pSensorSettings))
602  {
603  *retValue = DSA_ERR_PARAM;
604  }
605 
606  *retValue = ISF_SUCCESS;
607 }
608 
609 /*
610 ** ===================================================================
611 ** Event : Analog_1_fsl_Sensor_Generic_Analog_Initialize (module fsl_Sensor_Analog_1_Functions)
612 **
613 ** Component : Analog_1 [ISF_KSDK_Sensor_Generic_Analog]
614 ** @brief
615 ** Parameters :
616 ** NAME - DESCRIPTION
617 ** @param
618 ** @param
619 ** @return
620 ** Returns : Nothing
621 ** ===================================================================
622 */
623 void Analog_1_fsl_Sensor_Generic_Analog_Initialize(void* pSensorHandle, int8_t *retValue)
624 {
625  if ( NULL == pSensorHandle)
626  {
627  *retValue = DSA_ERR_PARAM;
628  }
629 
630  int32_t status;
631  uint8_t channelId;
632 
633  // Check if the sensor is available, and that it has already been initialized.
634  if (((isf_SensorHandle_t *)pSensorHandle)->adapterStatus > DSA_STATE_NOT_INITIALIZED)
635  {
636  *retValue = DSA_ERR_INITIALIZE;
637  }
638 
639  // Allocate the adapter specific memory for the descriptor
640  ((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor = (DeviceDescriptor_t *)OSA_MemAllocZero(sizeof(DeviceDescriptor_t));
641 
642  // Create and validate helper reference pointers.
643  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)((isf_SensorHandle_t *)pSensorHandle)->pDeviceDescriptor;
644 
645  if (NULL == pDeviceDescriptor)
646  {
647  *retValue = DSA_ERR_INITIALIZE;
648  }
649 
650  // Allocate the current sample data buffer and initialize it.
651  pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(Analog_1_DataBuffer_t));
652  Analog_1_DataBuffer_t *pCurrentSampleBuffer = (Analog_1_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
653 
654  pCurrentSampleBuffer->timeStamp = 0;
655  for(channelId = 0; channelId < configuredADCh; channelId++)
656  {
657  pCurrentSampleBuffer->data[channelId] = 0;
658  }
659 
660  // Set the adapter state to be initialized.
661  ((isf_SensorHandle_t *)pSensorHandle)->adapterStatus = DSA_STATE_INITIALIZED;
662 
663  // Create a semaphore to synchronize the device descriptor across tasks
664  if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
665  *retValue = DSA_ERR_INITIALIZE;
666  }
667 
668  // Initialize conversion table factor
669  AnalogVoltagetoOutputConvTable.offset = 0.0;
670  AnalogVoltagetoOutputConvTable.convFactor = 1.0;
671 
672  //Initialize the ADC16 module
673  if (kStatus_ADC16_Success != ADC16_DRV_Init(FSL_ADC1, &(ADC1_InitConfig0)))
674  {
675  *retValue = DSA_ERR_INITIALIZE;
676  }
677 
678  *retValue = ISF_SUCCESS;
679 }
680 
681 /* END fsl_Sensor_Analog_1_Functions */
682 
683 #ifdef __cplusplus
684 } /* extern "C" */
685 #endif
686 
687 /*!
688 ** @}
689 */
690 /*
691 ** ###################################################################
692 **
693 ** This file was created by Processor Expert 10.5 [05.21]
694 ** for the Freescale Kinetis series of microcontrollers.
695 **
696 ** ###################################################################
697 */
#define Analog_1_CONVERT_FLOAT_FACTOR
void Analog_1_fsl_Sensor_Generic_Analog_Configure(void *pSensorHandle, void *pSensorSettings, int8_t *retValue)
void Analog_1_fsl_Sensor_Generic_Analog_EndData(void *pSensorHandle, int8_t *retValue)
isf_dsa_status_t fsl_Sensor_Analog_1_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
const Analog_1_device_t Analog_1_DeviceInfo
This allows access to the sensor communications specific configuration.
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
Definition: isf_util.c:55
This is user's event module. Put your event handler code here.
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:170
isf_dsa_status_t fsl_Sensor_Analog_1_Initialize(isf_SensorHandle_t *pSensorHandle)
isf_fifo_status_t isf_fifo_unlock(isf_fifo_t *pFifo)
Release the exclusive access lock on a sample buffer.
Definition: isf_fifo.c:199
isf_fifo_status_t isf_fifo_el_increment(isf_fifo_t *pFifo)
Routine increments the insert pointer after direct access.
Definition: isf_fifo.c:237
isf_Analog_1_float_data_t sensorData[MAX_ADC_CHANNELS]
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
isf_dsa_status_t Analog_1_fixed_converter(Analog_1_Sensor_Specific_Settings_t *pSensorSpecificConfig, Analog_1_DataBuffer_t *nativeSample, void *vpConvertedSample)
isf_dsa_status_t fsl_Sensor_Analog_1_StartData(isf_SensorHandle_t *pSensorHandle)
Define the sensor device descriptor.
Definition: isf_sensors.h:49
void Analog_1_fsl_Sensor_Generic_AnalogCallback(void *pSensorHandle)
isf_dsa_status_t Analog_1_float_converter(Analog_1_Sensor_Specific_Settings_t *pSensorSpecificConfig, Analog_1_DataBuffer_t *nativeSample, void *vpConvertedSample)
This is user's event module. Put your event handler code here.
isf_dsa_status_t fsl_Sensor_Analog_1_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_SensorTypes_t
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
Analog_1_Sensor_Specific_Settings_t Analog_1_Sensor_Specific_Config
This allows access to the sensor specific configuration for the target sensor.
Standard fixed type for three axis accelerometers.
void Analog_1_fsl_Sensor_Generic_Analog_Shutdown(void *pSensorHandle, int8_t *retValue)
enum isf_dsa_result_enums isf_dsa_result_types_t
This structure stores sample Information necessary to communicate with non I2C slave device...
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.
const adc16_chn_config_t ADC1_ChnConfig0
Channel configuration declaration.
Definition: ADC1.c:81
void Analog_1__Void_()
isf_dsa_result_types_t resultFormat
isf_SensorDataTypes_t
This is user's event module. Put your event handler code here.
void Analog_1_fsl_Sensor_Generic_Analog_Initialize(void *pSensorHandle, int8_t *retValue)
isf_dsa_status_t fsl_Sensor_Analog_1_EndData(isf_SensorHandle_t *pSensorHandle)
isf_SensorDataTypes_t resultType
isf_dsa_status_t fsl_Sensor_Analog_1_Shutdown(isf_SensorHandle_t *pSensorHandle)
isf_dsa_AdapterStatus_t adapterStatus
signed long int int32
Definition: isf_types.h:74
isf_SensorDataTypes_t Analog_1_SupportedDataTypes[]
uint32_t operating_mode
const uint32_t en_pin
uint8_t sensorType
const adc16_converter_config_t ADC1_InitConfig0
ADC configuration declaration.
Definition: ADC1.c:57
void Analog_1_fsl_Sensor_Generic_Analog_StartData(void *pSensorHandle, int8_t *retValue)
isf_SensorTypes_t Analog_1_SupportedSensorTypes[]
Supported sensor and data types for the Sensor.
void Analog_1_fsl_Sensor_Generic_Analog_Convert(void *pSensorHandle, uint32_t convertToType, uint8_t resultType, void *pNativeSample, void *pConvertedSample, int32_t *numBytes, int8_t *retValue)
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
Definition: isf_bm.h:57
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
#define FSL_ADC1
Device instance number.
Definition: ADC1.h:76
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
uint8_t numGpios
This is user's event module. Put your event handler code here.
void Analog_1_fsl_Sensor_Generic_Analog_ValidateSettings(void *pSensorHandle, void *pSensorSettings, int8_t *retValue)
isf_dsa_SensorSettings_t sensorSettings
#define Analog_1_CONVERT_FIXED_FACTOR
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:229
This is user's event module. Put your event handler code here.
isf_Analog_1_fixed_data_t sensorData[MAX_ADC_CHANNELS]
semaphore_t deviceSemaphore
Definition: isf_sensors.h:54
This structure defines the dummy DSA data buffer format.
#define ISF_FIFO_FULL
Definition: isf_fifo.h:33
isf_dsa_status_t fsl_Sensor_Analog_1_Convert(isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32_t *numBytes)
bm_callback_token_t token
Definition: isf_sensors.h:53
uint8_t configuredADCh