ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
fsl_fxls8952_i2c_3D_accel.c
Go to the documentation of this file.
1 /*!
2  ********************************************************************************
3  * File: fsl_FXLS8952_i2c_3D_accel.c
4  *
5  * Copyright (c) 2015, Freescale Semiconductor, Inc.
6  *
7  *******************************************************************************/
8 /*!
9  * @file fsl_FXLS8952_i2c_3D_accel.c
10  * @brief The FXLS8952 Sensor Adapter for the 3-axis consumer accelerometer that supports I2C protocol.
11  */
12 /**
13  ** @addtogroup fsl_fxls8952_i2c_3D_accel_module fsl_fxls8952_i2c_3D_accel module documentation
14  ** @{
15  */
16 
17 #include <isf.h>
18 #include <isf_types.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>
25 #include <isf_comm.h>
26 #include <isf_util.h>
27 #include <isf_sensors.h>
28 #include "fxls8952.h"
29 #include "fsl_os_abstraction.h"
30 #include "isf_eventhandler.h"
32 
33 
34 #if 0
35 /**
36  * @brief Local function declaration for reseting the device.
37  */
38 static fxls8952_Status_t device_reset(dm_DeviceDescriptor_t* pDeviceHandle);
39 #endif
40 /**
41  * @brief Local function declaration for validating the Device ID using the "WHOAMI" command.
42  */
43 static fxls8952_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami);
44 #if 0
45 /**
46  * @brief Local function declaration for burst write on the device.
47  */
48 static fxls8952_Status_t device_burst_write(dm_DeviceDescriptor_t* pDeviceHandle, void* pSource, uint8 numBytes, uint8 internalAddress);
49 #endif
50 /**
51  * @brief Local function declaration for setting the appropriate power mode.
52  */
53 static fxls8952_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxls8952_Power_t power);
54 /**
55  * @brief Local function declaration for handling the wait state during device activation.
56  */
57 static fxls8952_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle);
58 /**
59  * @brief Local function declaration for getting ODR value from the given sample period.
60  */
61 static int32 get_ODR(uint32 samplePeriod);
62 
63 #if 0
64 static void _mem_copy(const void *pSource, void *pDestination, int32 numBytes);
65 #endif
66 
67 //uint8 LE_BE_check=0;
69 
70 /*! @brief Supported sensor and data types for FXLS8952 */
73 
74 // Converter routines for the supported data types
75 static isf_dsa_status_t float_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample );
76 static isf_dsa_status_t fixed_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample );
77 static isf_dsa_status_t float_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample );
78 static isf_dsa_status_t fixed_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample );
79 static isf_dsa_status_t count_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample );
80 #define FXLS8952_ACCEL_FLOAT_CONVERSION_FACTOR (0.1)
81 #define FXLS8952_ACCEL_FLOAT_CONVERSION_OFFSET (0.0)
82 #define FXLS8952_ACCEL_FIXED_CONVERSION_FACTOR (1638)
83 #define FXLS8952_ACCEL_FIXED_CONVERSION_OFFSET (0)
84 
85 #define MAX_ACCEL_FULL_SCALE_RANGE FXLS8952_RANGE_MAX
86 
87 #define FXLS8952_SAMPLE_PERIOD_MAX 1280409 // Maximum sample period supported by the FXLS8952.
88 #define FXLS8952_SAMPLE_PERIOD_MIN 312 // Minimum sample period supported by the FXLS8952.
89 #define GET_ODR_CONFIG 0x0 // Flag enables the configuration value.
90 #define GET_ODR_VALUE 0x01 // Flag enables the ODR value.
91 
92 #define NUM_STATUS_BYTES 1 // Number of status byte.
93 
94 #define NUMBER_OF_AXES_3D 0x3 // Number of Axes for 3 dimension.
95 #define MAX_NUM_AXES 0x3 // Maximum number of axes.
96 #define MAX_FXLS8952_DM_BYTES 0x30 // Maximum number of read/write using direct device messaging to address the registers,
97 // This is the maximum number of register in 8952.
98 #define NUM_INTERNAL_ADDRESS_BYTES 0x1 // Size of the internal address byte.
99 
100 // Macro to assign certain bits in a register.
101 
102 #define ASSIGN_REG_BITS_VALUE(addr, val, mask, shift) (addr) = (((addr) & ~ (mask)) | (((val) << shift)& (mask)) )
103 
104 // Macro to get the operational mode.
105 #define GET_MODE(mode) ((mode) <= FXLS8952_MODE_HYBRID) ? (mode) : FXLS8952_MODE_HYBRID
106 
107 // Macro to get the member in a structure.
108 #define GET_STRUCT_MEMBER_ADDRESS(p, m) (&(p)->m)
109 // Macro to get the size of the member.
110 #define GET_MEMBER_SIZE(p, m) sizeof((p)->m)
111 /**
112  *
113  *@brief The table that describes the configuration value based on ODR (output data rate).
114  *Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.
115  */
116 
117 /**
118  *
119  *@brief The table that describes the configuration value based on ODR (output data rate).
120  *Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.
121  */
123  { 312, 0},
124  { 625, 1},
125  { 1250, 2},
126  { 2500, 3},
127  { 5000, 4},
128  { 10000, 5},
129  { 20000, 6},
130  { 40000, 7},
131  { 80000, 8},
132  { 160000, 9},
133  { 320000, 10},
134  { 640000, 11},
135  { 1280000, 12},
136  { 1280000, 13},
137  { 1280000, 14},
138  { 1280000, 15},
139 
140 };
141 /*
142  * @brief This table contains the accel conversion factors based on the full-scale range selected.
143  */
144 const struct
145 {
146  float floatFactor;
147  float floatOffset;
151 //{
152 // { 0.98, 0.0, 2, 0},
153 // { 1.95, 0.0, 4, 0},
154 // { 3.91, 0.0, 8, 0},
155 // { 7.81, 0.0, 16,0}
156 //};
157 {
158  { 0.000061, 0.0, 16, 0},
159  { 0.000122, 0.0, 32, 0},
160  { 0.000244, 0.0, 64, 0},
161  { 0.000488, 0.0, 128, 0}
162 };
163 
164 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter initialization.
165  * @details This function allocates memory for the device descriptor.
166  * @param[in] pSensorHandle This is a void pointer to the instance of the FXLS8952 sensor adapter.
167  *
168  * @return ::fsl_FXLS8952_i2c_3D_accel_Initialize() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
169  * @retval ::ISF_SUCCESS is returned when the device is initialized properly.
170  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter was passed into the function, i.e. an invalid or NULL parameter.
171  * @retval ::DSA_ERR_INITIALIZE is returned when the driver could not be initialized successfully.
172 
173  *
174  * @Constraints None
175  *
176  * @Reentrant Yes
177  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
178  */
180 {
181  // Check the input argument
182  if (NULL == pSensorHandle) {
183  return DSA_ERR_PARAM;
184  }
185 
186  // Check if the sensor is available, and that it has already been initialized.
187  if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
188  return DSA_ERR_INITIALIZE;
189  }
190 
191  // Allocate memory for the device descriptor
192  pSensorHandle->pDeviceDescriptor = OSA_MemAllocZero(sizeof(DeviceDescriptor_t));
193 
194  // Hold the descriptor pointers in local variables for upcoming operations
195  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
196 
197  if (NULL == pDeviceDescriptor) {
198  return DSA_ERR_INITIALIZE;
199  }
200 
201  // Allocate the current sample data buffer and initialize it.
202  pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(fxls8952_DataBuffer_t));
203  fxls8952_DataBuffer_t *pCurrentSampleBuffer = (fxls8952_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
204  pCurrentSampleBuffer->timeStamp = 0;
205  pCurrentSampleBuffer->accel[0] = 0;
206  pCurrentSampleBuffer->accel[1] = 0;
207  pCurrentSampleBuffer->accel[2] = 0;
208 
209  dm_ChannelDescriptor_t * pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
210 
211  // Initialize the channel
212  if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
213  return DSA_ERR_INITIALIZE;
214  }
215  // Start the Bus
216  if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
217  return DSA_ERR_INITIALIZE;
218  }
219 
220  // Get the Channel state to check if it is ready to use
221  if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
222  return DSA_ERR_INITIALIZE;
223  }
224 
225  // Open the device and get the device handler
226  if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
227  return DSA_ERR_INITIALIZE;
228  }
229 
230  // Check that it's LEON2 and not some other device with the same address
231  if (ISF_SUCCESS != device_check_whoami(&pDeviceDescriptor->deviceHandle, FXLS8952_WHOAMI_VALUE)) {
232  return DSA_ERR_INITIALIZE;
233  }
234 
235 
236  // Set the adapter state to be initialized.
237  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
238 
239  // Create a semaphore to synchronize the device descriptor across tasks
240  if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
241  return DSA_ERR_INITIALIZE;
242  }
243 
244  pDeviceDescriptor->skipFramecnt = 0;
245 
246  return ISF_SUCCESS;
247 }
248 
249 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for validating current settings.
250  * @details This function is responsible for validating the current settings and if the current settings are not valid settings,
251  * it provides the best suitable settings.
252  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
253  * @param[in] pSettings The reference to the sensor settings.
254  *
255  * @return ::fsl_FXLS8952_i2c_3D_accel_ValidateSettings() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
256  * @retval ::ISF_SUCCESS is returned when the device settings are successfully validated.
257  * @retval ::SM_DSA_RET_SETTINGS_CHANGED is returned when the current settings have been changed.
258  *
259  * @Constraints None
260  *
261  * @Reentrant Yes
262  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
263  */
265 {
266  // Check the input arguments.
267  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
268  return DSA_ERR_PARAM;
269  }
270 
271  // Set the default return status
272  isf_dsa_status_t retStat = ISF_SUCCESS;
273 
275 
276  // Check the sample period
277  int32 odr = get_ODR(pSensorSettings->nSamplePeriod);
278 
279  if (odr < 0)
280  {
281  //retStat = DSA_RET_SETTINGS_CHANGED;
282  retStat = DSA_ERR_PARAM;
283  }
284 
285  // Save the sample period
286  pSpecificSettings->samplePeriod = pSensorSettings->nSamplePeriod;
287 
288  return retStat;
289 }
290 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for configuration.
291  * @details This function resets the sensor, applies the settings, and registers a callback with the Bus Manager(BM) timer. It does
292  * not yet start the timer, as this is done by fsl_FXLS8952_i2c_3D_accel_StartData().
293  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
294  * @param[in] pConfig The reference to the sensor configuration settings.
295  *
296  * @return ::fsl_FXLS8952_i2c_3D_accel_Configure() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
297  * @retval ::ISF_SUCCESS is returned when the device is configured successfully.
298  * @retval ::DSA_ERR_CONFIGURE is returned when the provided configuration settings could not be applied.
299  *
300  * @Constraints None
301  *
302  * @Reentrant Yes
303  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
304  */
305 //#define DEBUG_READ_ALL_REGS
306 #ifdef DEBUG_READ_ALL_REGS
307 static uint8 debugRegs[120];
308 #endif
310 {
311 
312 
313  // Check the input arguments
314  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
315  return DSA_ERR_PARAM;
316  }
317 
318  int32_t status;
320 
321  // Get the device descriptor and sensor specific settings
322  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
323 
325 
326  // Check the device descriptor pointer.
327  if ((NULL == pDeviceDescriptor) || (NULL == pSpecificSettings))
328  {
329  return retStatus;
330  }
331 
332  // Lock the device descriptor.
333  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
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 fxls8952 into Standby before configuration */
347  {
348  uint8 buffer[1];
349  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXLS8952_SENS_CONFIG1, buffer, 1, 1))
350  {
351  goto unlockchannel;
352  }
353  buffer[0] = (buffer[0] & ~ (FXLS8952_ACTIVE_MASK ));
354  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXLS8952_SENS_CONFIG1,buffer,1,1))
355  {
356  goto unlockchannel;
357  }
358  }
359 
360  /* Write the sensor specific data based on the pre-computed register level pairs (Addr, Value) */
361  {
362  uint8 buffer[1];
363 
364  for (uint32 reg=0; reg < pSpecificSettings->regCount ; reg++)
365  {
366  buffer[0] = pSpecificSettings->regPairs[reg].regValue;
367  if (reg==1)
368  {LE_BE_check = (buffer[0] & FXLS8952_LE_BE_MASK) >> 3;}
369 // else
370 // {LE_BE_check = 0;}
371  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, pSpecificSettings->regPairs[reg].regAddr,&buffer[0],1,1))
372  {
373  goto unlockchannel;
374  }
375  }
376  }
377 
378  /* Configure the ODR based on the calculated value */
379  {
380  uint8 buffer[1];
381  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXLS8952_SENS_CONFIG3, buffer, 1, 1))
382  {
383  goto unlockchannel;
384  }
385  buffer[0] |= FXLS8952_SET_FIELD(WAKE_ODR,(uint8)get_ODR(pSensorSettings->nSamplePeriod));
386  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXLS8952_SENS_CONFIG3,buffer,1,1))
387  {
388  goto unlockchannel;
389  }
390  }
391 #ifdef DEBUG_READ_ALL_REGS
392  for (int i=0; i<sizeof(debugRegs); i++)
393  {
394  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
395  }
396 #endif
397 
398  if (!pSpecificSettings->usesInterrupts)
399  {
400  // Register to bus management timer
401  pDeviceDescriptor->token = bm_register_periodic_callback((isf_duration_t) pSensorSettings->nSamplePeriod, fsl_fxls8952_i2c_3D_accel_PeriodicCallback, pSensorHandle);
402  if(BM_ERROR & pDeviceDescriptor->token){
403  goto unlockchannel;
404  }
405  }
406  else
407  {
409  if (pDeviceDescriptor->token < 0)
410  {
411  goto unlockchannel;
412  }
413  pSpecificSettings->signal = isf_EventHandler_GetSignal(pDeviceDescriptor->token);
414  }
415 
416 
418  retStatus = ISF_SUCCESS;
419 
420 unlockchannel:
421  // Unlock the channel.
422  // The explicit lock must be released when the configuration is done allowing the bus to be used by others.
423  // User Notice: This is a required function call.
424  status = dm_channel_release_lock(&pDeviceDescriptor->cDescriptor);
425  if (ISF_SUCCESS != status)
426  {
427  retStatus = status;
428  }
429 
430 unlockdescriptor:
431 
432  // Unlock the device descriptor.
433  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
434 
435  return retStatus;
436 }
437 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for start Data.
438  * @details This function tells the Bus Manager to start the callbacks periodically as defined in the bus configuration and enable the data collection.
439  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
440  *
441  * @return ::fsl_FXLS8952_i2c_3D_accel_StartData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
442  * @retval ::ISF_SUCCESS is returned when the data collection callback triggered successfully.
443  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
444  *
445  * @Constraints None
446  *
447  * @Reentrant Yes
448  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
449  */
451 {
452  // Check the input argument
453  if (NULL == pSensorHandle) {
454  return DSA_ERR_PARAM;
455  }
456 
458 
459  int32_t retStat = DSA_ERR_START_DATA;
460 
461  // Get the device descriptor and specific settings
462  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
463 
464  // Check the device descriptor.
465  if (NULL == pDeviceDescriptor)
466  return DSA_ERR_PARAM;
467 
468  // Lock the device descriptor.
469  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
470 
471  // Check the driver state.
472  if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
473  {
474  goto unlockdescriptor;
475  }
476 
477  // Put the device into active mode
478  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXLS8952_POWER_ACTIVE)) {
479  goto unlockdescriptor;
480  }
481 
482  // Wait for transition into active mode to complete
483  if ((retStat == ISF_SUCCESS) && (ISF_SUCCESS != device_wait_for_active(&pDeviceDescriptor->deviceHandle))) {
484  goto unlockdescriptor;
485  }
486 
487  if (!pSpecificSettings->usesInterrupts)
488  {
489  // Start the Bus Manager sampling timer.
490  if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) // Check for Bus Manager error and return on failure.
491  goto unlockdescriptor;
492  }
493 
494  // Set device to active state.
496  retStat = ISF_SUCCESS;
497 
498 unlockdescriptor:
499  // Unlock the device descriptor.
500  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
501 
502  return retStat;
503 }
504 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for End Data.
505  * @details This function tells the Bus Manager to stop the callbacks and disable data collection.
506  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
507  *
508  * @return ::fsl_FXLS8952_i2c_3D_accel_EndData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
509  * @retval ::ISF_SUCCESS is returned when the data collection stopped successfully.
510  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
511  *
512  * @Constraints None
513  *
514  * @Reentrant Yes
515  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
516  */
518 {
519  // Check pointers.
520  if(NULL == pSensorHandle){
521  return DSA_ERR_PARAM;
522  }
523 
524  // Create helper reference pointers.
525  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
526 
527  // Set the default return status.
528  int32_t retStat = DSA_ERR_END_DATA;
529 
530  // Check the device descriptor.
531  if (NULL == pDeviceDescriptor)
532  return retStat;
533 
534  // Lock the device descriptor.
535  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
536 
537  // Check the driver state.
538  if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
539  goto unlockdescriptor;
540 
541  // Check that the adapter is not already started.
542  if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
543  // If it is, then stop the Bus Manager (BM) sample timer.
544  isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
545  if (BM_ERROR & bmStopStatus)
546  goto unlockdescriptor;
547  }
548 
549  // Put the device into standby mode
550  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXLS8952_POWER_STANDBY)) {
551  goto unlockdescriptor;
552  }
553 
555  retStat = ISF_SUCCESS;
556 
557 
558 unlockdescriptor:
559  // Unlock the device descriptor.
560  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
561 
562  return retStat;
563 }
564 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for calibration .
565  * @details The FXLS8952 does not provide the capability to be dynamically calibrated. Therefore, this function simply returns success.
566  *
567  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
568  *
569  @return ::fsl_FXLS8952_i2c_3D_accel_Calibrate() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
570  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
571  * \b Note: Currently, there is no return error type defined for this API.
572  *
573  * @Constraints None
574  *
575  * @Reentrant Yes
576  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
577  */
579 {
580  return ISF_SUCCESS;
581 }
582 /*! @brief This is the concrete implementation of the FXLS8952 sensor adapter for shutdown .
583  *
584  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
585  *
586  @return ::fsl_FXLS8952_i2c_3D_accel_Shutdown() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
587  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
588  * \b Note: Currently, there is no return error type defined for this API.
589  *
590  * @Constraints None
591  *
592  * @Reentrant Yes
593  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
594  */
596 {
597  if(NULL == pSensorHandle){
598  return DSA_ERR_PARAM;
599  }
600 
602 
603  // Create helper reference pointers.
604  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
605 
606  if (!pSpecificSettings->usesInterrupts)
607  {
608  // Remove the sensor adapter from the Bus Manager callbacks.
609  bm_unregister_callback(pDeviceDescriptor->token);
610  }
611  else
612  {
613  if (isf_EventHandler_UnregisterEvent(pDeviceDescriptor->token) < 0)
614  {
615  return DSA_ERR_PARAM;
616  }
617  }
618 
619  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
620  return ISF_SUCCESS;
621 }
622 /*! @brief The callback function for the Bus Manager(BM).
623  * @details The Bus Manager calls this function periodically based on the period configured for the FXLS8952.
624  *
625  * @param[in] pSensorHdl This is a void pointer to the instance of the FXLS8952 sensor adapter.
626  *
627  * @return Void There is no return value.
628  *
629  * @Constraints None
630  *
631  * @Reentrant Yes
632  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
633  */
635 {
636  // Check the input argument
637  if (NULL == pSensorHandle) {
638  return;
639  }
640 
641  // Get the device descriptor and specific settings
642  volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
645  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
646  int32 numBytes;
647  uint8 bufStatus;
648  uint32 sampleCount;
649  uint8 intStatus;
650  uint8 sysMode;
651  uint32 sample;
652  uint8 bufConfig2;
653  uint32 currentTimestamp;
654 
655 
656  isf_status_t st;
657 
658  // Check the device descriptor
659  if (NULL == pDeviceDescriptor){
660  return;
661  }
662 
663  // Create a helper pointer to the current sample buffer.
664  fxls8952_DataBuffer_t *pCurrentSampleBuffer = (fxls8952_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
665 
666  // Apply sample skip if necessary.
667  if (pDeviceDescriptor->skipFramecnt) {
668  // Not done skipping samples.
669  --pDeviceDescriptor->skipFramecnt;
670  return;
671  }
672 
673  // Get the time stamp
674  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
675 
676  // Lock the device descriptor.
677  if (kStatus_OSA_Success != OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
678  {
679  goto unlockdescriptor;
680  }
681 
682 
683  // Check the driver state.
684  if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
685  {
686  goto unlockdescriptor;
687  }
688 
689  // Get the time stamp
690  currentTimestamp = isf_time_util_get_usec();
691 
692 #ifdef DEBUG_READ_ALL_REGS
693  for (int i=0; i<sizeof(debugRegs); i++)
694  {
695  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
696  }
697 #endif
698  // get the interrupt status in general
699  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_INT_STATUS, &intStatus, 1,1);
700 
701  // get the system mode
702  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_SYS_MODE, &sysMode, 1,1);
703 
704 
705  if (pSpecificSettings->usesBuffer) // using FXLS8952 buffer
706  {
707  // get the count of the number of data samples available in the device buffer (FIFO)
708  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_BUF_STATUS, &bufStatus, 1,1);
709  sampleCount = FXLS8952_GET_FIELD(BUF_CNT,bufStatus);
710 
711  if (sampleCount == 0)
712  {
713  // dummy read to clear interrupt
714  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_BUF_CONFIG2, &bufConfig2, 1,1);
715  bufConfig2 = (bufConfig2 & ~FXLS8952_BUF_FLUSH_MASK) | FXLS8952_BUF_FLUSH_MASK;
716  dm_device_write(&pDeviceDescriptor->deviceHandle, FXLS8952_BUF_CONFIG2, &bufConfig2, 1,1);
717  }
718  }
719  else // not using buffer, so read only one sample
720  {
721  sampleCount = 1;
722  }
723 
724  for (sample=0; sample < sampleCount; sample++)
725  {
726  // adjust the sample timestamp based on the timing inside the buffer
727  pCurrentSampleBuffer->timeStamp = currentTimestamp - ((sampleCount - (sample+1)) * pSpecificSettings->samplePeriod);
728 
729  // read the accel data.
730  if (pSpecificSettings->usesBuffer) // using FXLS8952 buffer
731  {
732  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_BUF_X_LSB, (uint8 *)&pCurrentSampleBuffer->accel[0], 6,6);
733  }
734  else // using unbuffered output
735  {
736  dm_device_read(&pDeviceDescriptor->deviceHandle, FXLS8952_OUT_X_LSB, (uint8 *)&pCurrentSampleBuffer->accel[0], 6,6);
737  }
738 
739  if (LE_BE_check==0)
740  {
741  // Convert the samples to big endian.
742  pCurrentSampleBuffer->accel[0]<<= 4;
743  pCurrentSampleBuffer->accel[1]<<= 4;
744  pCurrentSampleBuffer->accel[2]<<= 4;
745  }
746  else
747  {
748  // Keep big endian.
749  pCurrentSampleBuffer->accel[0] = isf_swap2byte(pCurrentSampleBuffer->accel[0]);
750  pCurrentSampleBuffer->accel[1] = isf_swap2byte(pCurrentSampleBuffer->accel[1]);
751  pCurrentSampleBuffer->accel[2] = isf_swap2byte(pCurrentSampleBuffer->accel[2]);
752  }
753 
754 
755 
756 
757  // Lock the fifo for update.
758  if(kStatus_OSA_Success != isf_fifo_lock(pFifo)){
759  return;
760  }
761 
763 
764  // write the new data
766  {
767  *pFifoEntry = *pCurrentSampleBuffer;
768  }
769  else
770  {
772  pSensorHdl,
775  pCurrentSampleBuffer,
776  pFifoEntry,
777  &numBytes);
778  }
779 
780  // Increment the fifo to the next sample entry.
781  st = isf_fifo_el_increment(pFifo);
782 
783  // Unlock the fifo.
784  isf_fifo_unlock(pFifo);
785 
786  if (st == ISF_FIFO_FULL)
787  {
788  // Notify the user using their registered event information
789  OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
790  }
791  }
792 
793 unlockdescriptor:
794  // Unlock the device descriptor.
795  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
796 }
797 /*!
798  * @brief This function coverts the raw sample data to the desired output type.
799  */
801  (
802  volatile isf_SensorHandle_t *pSensorHandle,
803  isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
804  void *pNativeSample,
805  void *pConvertedSample,
806  int32 *numBytes
807  )
808 {
811 
812  pConverter = NULL;
813 
814  switch (convertToType)
815  {
817  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
818  pConverter = float_accel3d_converter;
819  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
820  pConverter = fixed_accel3d_converter;
821  else if (resultType == DSA_RESULT_TYPE_RAW_COUNTS)
822  pConverter = count_accel3d_converter;
823  break;
824 
825  default:
827  }
828  if (pConverter == NULL)
830 
831  retStat = pConverter(
833  (fxls8952_DataBuffer_t *)pNativeSample,
834  pConvertedSample
835  );
836 
837  return retStat;
838 }
839 
840 static isf_dsa_status_t float_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample )
841 {
842  isf_Acceleration3D_Float_t *convertedSample = (isf_Acceleration3D_Float_t *)vpConvertedSample;
843  convertedSample->timestamp = nativeSample->timeStamp;
844  // Convert the sample based on the full-scale range.
845  convertedSample->accel[0] = nativeSample->accel[0] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
846  convertedSample->accel[1] = nativeSample->accel[1] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
847  convertedSample->accel[2] = nativeSample->accel[2] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
848  return ISF_SUCCESS;
849 }
850 
851 static isf_dsa_status_t fixed_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample )
852 {
853  isf_Acceleration3D_EngFixed_t *convertedSample = (isf_Acceleration3D_EngFixed_t *)vpConvertedSample;
854  convertedSample->timestamp = nativeSample->timeStamp;
855  // Convert the sample based on the full-scale range.
856  convertedSample->accel[0] = ((nativeSample->accel[0] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset))/4;
857  convertedSample->accel[1] = ((nativeSample->accel[1] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset))/4;
858  convertedSample->accel[2] = ((nativeSample->accel[2] * fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8952AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset))/4;
859  return ISF_SUCCESS;
860 
861 }
862 static isf_dsa_status_t count_accel3d_converter(fxls8952_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8952_DataBuffer_t *nativeSample, void *vpConvertedSample )
863 {
864  isf_Acceleration3D_RawCount_t *convertedSample = (isf_Acceleration3D_RawCount_t *)vpConvertedSample;
865  convertedSample->timestamp = nativeSample->timeStamp;
866  // Convert the sample based on the full-scale range.
867  convertedSample->accel[0] = nativeSample->accel[0];
868  convertedSample->accel[1] = nativeSample->accel[1];
869  convertedSample->accel[2] = nativeSample->accel[2];
870 
871  return ISF_SUCCESS;
872 }
873 #if 0
874 /*! @brief The local function for the device reset.
875  * @details This function sends the device reset command to FXLS8952.
876  *
877  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
878  *
879  * @return ::device_reset() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
880  * @retval ::ISF_SUCCESS is returned when the device is reset successfully.
881  * *
882  * @Constraints None
883  *
884  * @Reentrant Yes
885  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
886  */
887 static fxls8952_Status_t device_reset(dm_DeviceDescriptor_t* pDeviceHandle)
888 {
889  uint8 buffer[1] = {0x00};
890  buffer[0] = FXLS8952_SET_FIELD(RST,1);
891  dm_device_write(pDeviceHandle, FXLS8952_SENS_CONFIG1, buffer, 1, 1); // don't check the return code
892  // Wait for device reset to complete
893  const uint32 RESET_WAIT_MS = 1;
894  OSA_TimeDelay(RESET_WAIT_MS);
895 
896  return ISF_SUCCESS;
897 }
898 #endif
899 /*! @brief The local function for validating the device id.
900  * @details This function reads the WHOAMI register value and compares it against the known FXLS8952 WHOAMI value.
901  *
902  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
903  * @param[in] whoami The known WHOAMI value of the FXLS8952
904  *
905  * @return ::device_check_whoami() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
906  * @retval ::ISF_SUCCESS is returned when the device is validated with its WHOAMI value.
907  * @retval ::FXLS8952_ERROR_WHOAMI is returned when device could validates with its WHOAMI value.
908  * *
909  * @Constraints None
910  *
911  * @Reentrant Yes
912  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
913  */
914 static fxls8952_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami) {
915 
916 
917  uint8 buffer[1] = {0x00};
918 
919  dm_device_read(pDeviceHandle, FXLS8952_WHO_AM_I, buffer, 1, 1); // don't check the return code
920  if (whoami == buffer[0]) {
921  return ISF_SUCCESS;
922  }
923  else
924  {
925  return FXLS8952_ERROR_WHOAMI;
926  }
927 
928  return ISF_SUCCESS;
929 }
930 #if 0
931 /*! @brief The local function for burst write to the device.
932  * @details This function perform the burst write from the given start memory address.
933  *
934  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
935  * @param[in] pSource This is a reference to the source buffer.
936  * @param[in] numBytes The number of bytes to write.
937  * @param[in] internalAddress The start address of the register for burst write.
938  *
939  * @return ::device_burst_write() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
940  * @retval ::ISF_SUCCESS is returned when burst write successfully performed.
941  * @retval ::FXLS8952_ERROR_BURSTWRITE is returned when burst write fails.
942  * *
943  * @Constraints None
944  *
945  * @Reentrant Yes
946  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
947  */
948 static fxls8952_Status_t device_burst_write(dm_DeviceDescriptor_t* pDeviceHandle, void* pSource, uint8 numBytes, uint8 internalAddress) {
949 
950  if (numBytes > MAX_FXLS8952_DM_BYTES - 1) {
952  }
954  _mem_copy(pSource, &buffer[0], numBytes);
955 
956  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, internalAddress, buffer, 1, (uint16) (NUM_INTERNAL_ADDRESS_BYTES + numBytes)))
957  {
959  }
960 
961  return ISF_SUCCESS;
962 }
963 #endif
964 /*! @brief The local function to set the power mode in the FXLS8952.
965  * @details This function sets the POWER MODE from options such as ACTIVE, READY and STANDBY Mode.
966  *
967  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
968  * @param[in] power The value of the power.
969  *
970  * @return ::device_set_power_mode() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
971  * @retval ::ISF_SUCCESS is returned when the device is configured with the specified power mode.
972  * @retval ::FXLS8952_ERROR_SETPOWER is returned when the device could not be configured with the specified power mode.
973  * *
974  * @Constraints None
975  *
976  * @Reentrant Yes
977  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
978  */
979 static fxls8952_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxls8952_Power_t power) {
980  // Read the current power mode from the device
981 
982  uint8 buffer[1];
983 
984  if (ISF_SUCCESS != dm_device_read(pDeviceHandle,FXLS8952_SENS_CONFIG1, buffer, 1, 1))
985  {
987  }
988 
989  // Set or clear the active bit
990  if (FXLS8952_POWER_ACTIVE == power)
991  {
992  buffer[0] |= FXLS8952_SET_FIELD(ACTIVE,1);
993  }
994  else
995  {
996  buffer[0] &= ~FXLS8952_SET_FIELD(ACTIVE,1);
997  }
998 
999  // Write the modified value back to the device
1000  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXLS8952_SENS_CONFIG1, buffer, 1, 1))
1001  {
1002  return FXLS8952_ERROR_SETPOWER;
1003  }
1004 
1005  return ISF_SUCCESS;
1006 }
1007 /*! @brief The local function to validate the device is in the active state.
1008  * @details This function keeps checking the state of the device until it becomes active.
1009  *
1010  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
1011  *
1012  * @return ::device_wait_for_active() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
1013  * @retval ::ISF_SUCCESS is returned when the device becomes active.
1014  * @retval ::FXLS8952_ERROR_WAITFORACTIVE is returned when the device is unable to read the active state.
1015  * *
1016  * @Constraints None
1017  *
1018  * @Reentrant Yes
1019  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
1020  */
1021 static fxls8952_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle) {
1022 
1023 
1024  uint8 buffer[1];
1025  do {
1026  if (ISF_SUCCESS != dm_device_read(pDeviceHandle,FXLS8952_INT_STATUS , buffer, 1, 1))
1027  {
1029  }
1030  OSA_TimeDelay(1); // short delay to yield CPU/RTOS.
1031  } while (!(buffer[0] & FXLS8952_SRC_DRDY_MASK));
1032  return ISF_SUCCESS;
1033 }
1034 /*! @brief The local function to decode the ODR..
1035  * @details This function decode the ODR value based on the data mode. set GET_ODR_CONFIG for register value correspond to
1036  * ODR sample period else it gives ODR sample period in milli second.
1037  *
1038  * @param[in] samplePeriod This sample period.
1039  * @param[in] mode The operational mode
1040  * @param[in] dataMode The data mode in which the user requested.
1041  *
1042  * @return ::get_ODR() returns a value of uint32 indicating the ODR value.
1043  *
1044  * @Constraints None
1045  *
1046  * @Reentrant Yes
1047  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
1048  */
1049 static int32 get_ODR(uint32 samplePeriod)
1050 {
1051  uint8 i = 0, flag=0;
1052 
1053  for (i = 0; i < sizeof(fxls8952_odrTable); i++)
1054  {
1055  if(fxls8952_odrTable[i].periodNormalMode == samplePeriod)
1056  {
1057  flag=1;break;
1058  }
1059 
1060  }
1061  if(flag==1)
1062  {
1063  return fxls8952_odrTable[i].configVal;
1064  }
1065  else
1066  {
1067  return -1;
1068  }
1069 } // if we found a valid ODR, then return it.
1070 
1071 #if 0
1072 /*! @brief The local function for a memory copy.
1073  *
1074  * @param[in] pSource The reference to the source address.
1075  * @param[in] pDestination The reference to the destination address.
1076  * @param[in] numBytes The number of bytes to be copied.
1077  *
1078  * @return None
1079  * @Constraints None
1080  *
1081  * @Reentrant Yes
1082  * @Libs fsl_FXLS8952_i2c_3D_accel.lib
1083  */
1084 static void _mem_copy(const void *pSource, void *pDestination, int32 numBytes) {
1085  const uint8 *pSourceByte = pSource;
1086  uint8 *pDestinationByte = pDestination;
1087  while (numBytes--) {
1088  *pDestinationByte++ = *pSourceByte++;
1089  }
1090 }
1091 #endif
1092 
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Standard raw type for three axes accelerometers.
void * pSensorSpecificSettings
void fsl_fxls8952_i2c_3D_accel_PeriodicCallback(void *pSensorHandle)
The callback function for the Bus Manager(BM).
unsigned char uint8
Definition: isf_types.h:76
int32 isf_EventHandler_RegisterEvent(eventCallback_t *pCallback, void *pUserData)
Standard fixed type for three axis accelerometers.
int32 fixedOffset
isf_SensorDataTypes_t fxls8952_SupportedDataTypes[]
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
Definition: isf_util.c:55
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:170
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: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
the structure defines the ODR table between Hybrid and normal mode of device operation.
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
#define FXLS8952_LE_BE_MASK
Definition: fxls8952.h:143
#define FALSE
Definition: isf_types.h:86
#define MAX_FXLS8952_DM_BYTES
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
#define NUM_INTERNAL_ADDRESS_BYTES
dm_DeviceDescriptor_t deviceHandle
Definition: isf_sensors.h:52
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_Shutdown(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXLS8952 sensor adapter for shutdown . ...
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This is the concrete implementation of the FXLS8952 sensor adapter for calibration ...
Define the sensor device descriptor.
Definition: isf_sensors.h:49
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXLS8952 sensor adapter for validating current settings...
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXLS8952 sensor adapter for configuration.
The fxls8952.h contains the FXLS8952 Accelerometer register definitions, access macros, and device access functions.
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_Initialize(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXLS8952 sensor adapter initialization.
isf_SensorTypes_t
dm_ChannelDescriptor_t cDescriptor
Definition: isf_sensors.h:51
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.
uint8 LE_BE_check
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_acceleration_g_fixed_32s1i16_t accel[3]
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
const struct @19 fxls8952AccelConvTable[]
int32 fixedFactor
uint16 isf_swap2byte(uint16 n)
2 byte swapping method
Definition: isf_util.c:156
const fxls8952_ODR_Table_t fxls8952_odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
#define FXLS8952_WHOAMI_VALUE
Definition: fxls8952.h:71
isf_acceleration_g_float_t accel[3]
int32 fxls8952_Status_t
fxls8952 internal return codes.
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.
#define FXLS8952_SRC_DRDY_MASK
Definition: fxls8952.h:85
The isf_util.h file contains the utility method declarations and macros.
enum isf_dsa_result_enums isf_dsa_result_types_t
fxls8952_Sensor_Specific_Reg_t regPairs[]
Definition: fxls8952.h:360
int32 isf_EventHandler_GetSignal(uint32 token)
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.
isf_SensorTypes_t fxls8952_SupportedSensorTypes[]
Supported sensor and data types for FXLS8952.
The fsl_fxls8952_i2c_3D_accel.h file contains the definitions and functions supporting the FXLS8952 S...
isf_dsa_result_types_t resultFormat
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_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.
isf_SensorDataTypes_t
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
enum fxls8952_Power_tag fxls8952_Power_t
Enumeration for the fxls8952 power modes.
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.
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:84
isf_SensorDataTypes_t resultType
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...
isf_dsa_AdapterStatus_t adapterStatus
signed long int int32
Definition: isf_types.h:74
sys_channelId_t channelId
unsigned short int uint16
Definition: isf_types.h:77
float floatOffset
float floatFactor
Standard float type for three axis accelerometers.
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_StartData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXLS8952 sensor adapter for start Data.
int32 isf_EventHandler_UnregisterEvent(uint32 token)
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
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
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 FXLS8952_SET_FIELD(name, val)
Definition: fxls8952.h:79
#define FXLS8952_BUF_FLUSH_MASK
Definition: fxls8952.h:237
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:229
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
unsigned long int uint32
Definition: isf_types.h:78
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
#define FXLS8952_GET_FIELD(name, val)
Definition: fxls8952.h:80
#define FXLS8952_ACTIVE_MASK
Definition: fxls8952.h:133
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
semaphore_t deviceSemaphore
Definition: isf_sensors.h:54
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
isf_dsa_status_t fsl_fxls8952_i2c_3D_accel_EndData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXLS8952 sensor adapter for End Data.
#define ISF_FIFO_FULL
Definition: isf_fifo.h:33
isf_acceleration_g_rawCount_t accel[3]
bm_callback_token_t token
Definition: isf_sensors.h:53
This structure defines the dummy DSA data buffer format.