ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
fsl_fxas21002_i2cspi_3D_gyro.c
Go to the documentation of this file.
1 /**
2  ********************************************************************************
3  * File: fsl_fxas21002_i2cspi_3D_gyro.c.c
4  *
5  * Copyright (c) 2015, Freescale Semiconductor, Inc.
6  *
7  *******************************************************************************/
8 /**
9  * @file fsl_fxas21002_i2cspi_3D_gyro.c
10  * @brief The FXAS21002 is a 3-axis Angular Rate Gyroscope from Freescale that supports both I2C and SPI
11  * protocols. This source file implements the interface for the FXAS21002 Sensor Adapter.
12  * It uses Device Messaging (DM), which abstracts away the differences between the I2C and
13  * SPI protocols, to communicate with the device. This choice is made via the system
14  * communication file, isf_sysconf_comms.c. This file also uses the Bus Manager (BM) to
15  * schedule a periodic callback for reading new sensor data and sending the data to the
16  * Sensor Manager (SM).
17  */
18 #include <isf.h>
19 #include <isf_types.h>
20 #include <isf_sm_api.h>
21 #include <isf_dsa_adapter.h>
22 #include <isf_bm.h>
23 #include <isf_sensor_types.h>
24 #include <isf_fifo.h>
25 #include <isf_gyrometer_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 "fsl_os_abstraction.h"
32 #include "fxas21002.h"
33 
34 /**
35  * @brief Local function declaration for validating the Device ID using the "WHOAMI" command.
36  */
37 static fxas21002_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami);
38 /**
39  * @brief Local function declaration for setting the appropriate power mode.
40  */
41 static fxas21002_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxas21002_Power_t power);
42 /**
43  * @brief Local function declaration for handling the wait state during device activation.
44  */
45 static fxas21002_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle);
46 /**
47  * @brief Local function declaration for getting ODR value from the given sample period.
48  */
49 static int32 get_ODR(uint32 samplePeriod);
50 
52 
53 /*! @brief Supported sensor and data types for FXAS21002 */
56 
57 // Converter routines for the supported data types
58 static isf_dsa_status_t float_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample );
59 static isf_dsa_status_t fixed_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample );
60 static isf_dsa_status_t count_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample );
61 static isf_dsa_status_t float_temp1d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample );
62 static isf_dsa_status_t fixed_temp1d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample );
63 
64 #define MAX_GYRO_FULL_SCALE_RANGE 2
65 
66 #define FXAS21002_SAMPLE_PERIOD_MAX 640000 // Maximum sample period supported by the FXAS21002.
67 #define FXAS21002_SAMPLE_PERIOD_MIN 5000 // Minimum sample period supported by the FXAS21002.
68 #define GET_ODR_CONFIG 0x0 // Flag enables the configuration value.
69 #define GET_ODR_VALUE 0x01 // Flag enables the ODR value.
70 
71 #define MAX_FXAS21002_DM_BYTES 0x16 // Maximum number of read/write using direct device messaging to address the registers. This is the maximum number of register in 8700.
72 #define NUM_INTERNAL_ADDRESS_BYTES 0x1 // Size of the internal address byte.
73 
74 /**
75  *
76  *@brief The table that describes the configuration value based on ODR (output data rate).
77  *Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.
78  */
80  { 5000, 0},
81  { 10000, 1},
82  { 20000, 2},
83  { 40000, 3},
84  { 80000, 4},
85  { 160000, 5},
86  { 320000, 6},
87  { 640000, 7},
88 };
89 /**
90  *
91  *@brief The table that describes the configuration value based on ODR (output data rate).
92  *Note: This table is irregular after the 25HZ, so can't use FLOORLOG2 algorithm.
93  */
95  { 1250, 0},
96  { 2500, 1},
97  { 5000, 2},
98  { 10000, 3},
99  { 20000, 4},
100  { 40000, 5},
101  { 80000, 6},
102  { 80000, 7},
103 };
104 /*
105  * @brief This table contains the Gyro conversion factors based on the full-scale range selected.
106  */
107 const struct
108 {
109  float floatFactor;
110  float floatOffset;
114 {
115  { 0.200, 0.0, 13107, 0},
116  { 0.100, 0.0, 6554, 0},
117  { 0.050, 0.0, 3277, 0},
118  { 0.025, 0.0, 1638, 0}
119 },
121 {
122  { 0.0625, 0.0, 4096, 0},
123  { 0.03125, 0.0, 2048, 0},
124  { 0.01563, 0.0, 1024, 0},
125  { 0.00782, 0.0, 512, 0}
126 };
127 
128 //fxas21002_DeviceDescriptor_t* gpDeviceDescriptor = NULL;
129 /**
130  *
131  *@brief The table that describes the extended address space.
132  */
134 
135 #define MAX_DATA_READ_SIZE 6 // Maximum number of data
136 #define MAX_BUF_SIZE 6 // Maximum buffer size
137 
138 /*!
139  * @def TEMPERATURE_DATA_READ_SIZE
140  * @brief Size of Device Temperature Data to be Read
141 */
142 #define TEMPERATURE_DATA_READ_SIZE 1
143 
144 /*!
145  * @def TEMPERATURE_BUF_SIZE
146  * @brief Size of Temperature buffer size
147 */
148 #define TEMPERATURE_BUF_SIZE 1
149 
150 /*!
151  * @def FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR
152  * @brief FXAS21002 temperature conversion to store in
153  * ISF sensors standard floating point temperature (degC)
154 */
155 #define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR (1.0F/65536.0F)
156 #define FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET 0.0
157 
158 /*!
159  * @def FXAS21002_TEMP_FIXED_CONVERSION_FACTOR
160  * @brief FXAS21002 temperature conversion to store in
161  * ISF sensors standard fixed point temperature (degC)
162 */
163 #define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR 65536 /* 16bits left shift */
164 #define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET 0
165 
166 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter initialization.
167  * @details This function allocates memory for the device descriptor.
168  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
169  *
170  * @return ::fsl_fxas21002_i2cspi_3D_gyro_Initialize() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
171  * @retval ::ISF_SUCCESS is returned when the device is initialized properly.
172  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter was passed into the function, i.e. an invalid or NULL parameter.
173  * @retval ::DSA_ERR_INITIALIZE is returned when the driver could not be initialized successfully.
174 
175  *
176  * @Constraints None
177  *
178  * @Reentrant Yes
179  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
180  */
182 {
183  // Check the input argument
184  if (NULL == pSensorHandle) {
185  return DSA_ERR_PARAM;
186  }
187 
188  // Check if the sensor is available, and that it has already been initialized.
189  if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
190  return DSA_ERR_INITIALIZE;
191  }
192  // Allocate memory for the device descriptor
193  //pSensorHandle->pDeviceDescriptor = _lwmem_alloc(sizeof(DeviceDescriptor_t));
194  pSensorHandle->pDeviceDescriptor = OSA_MemAllocZero(sizeof(DeviceDescriptor_t));
195  // Hold the descriptor pointers in local variables for upcoming operations
196  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
197 
198  if (NULL == pDeviceDescriptor) {
199  return DSA_ERR_INITIALIZE;
200  }
201 
202  // Allocate the current sample data buffer and initialize it.
203  //pDeviceDescriptor->pCurrentSample = _lwmem_alloc_system_zero(sizeof(fxas21002_DataBuffer_t));
204  pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(fxas21002_DataBuffer_t));
205  fxas21002_DataBuffer_t *pCurrentSampleBuffer = (fxas21002_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
206  pCurrentSampleBuffer->timeStamp = 0;
207  pCurrentSampleBuffer->gyro[0] = 0;
208  pCurrentSampleBuffer->gyro[1] = 0;
209  pCurrentSampleBuffer->gyro[2] = 0;
210 
211  dm_ChannelDescriptor_t * pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
212 
213  // Initialize the channel
214  if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
215  return DSA_ERR_INITIALIZE;
216  }
217  // Start the Bus
218  if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
219  return DSA_ERR_INITIALIZE;
220  }
221 
222  // Get the Channel state to check if it is ready to use
223  if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
224  return DSA_ERR_INITIALIZE;
225  }
226  // Open the device and get the device handler
227  if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
228  return DSA_ERR_INITIALIZE;
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, FXAS21000_WHOAMI_VALUE)) &&
232  (ISF_SUCCESS != device_check_whoami(&pDeviceDescriptor->deviceHandle, FXAS21002_WHOAMI_VALUE_PRE_RELEASE)) &&
233  (ISF_SUCCESS != device_check_whoami(&pDeviceDescriptor->deviceHandle, FXAS21002_WHOAMI_VALUE_RELEASE)) )
234  {
235  return DSA_ERR_INITIALIZE;
236  }
237 
238  // Set the adapter state to be initialized.
239  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
240 
241  // Create a semaphore to synchronize the device descriptor across tasks
242  //if (MQX_OK != _lwsem_create(&pDeviceDescriptor->deviceSemaphore, 1)){
243  if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
244  return DSA_ERR_INITIALIZE;
245  }
246 
247  pDeviceDescriptor->skipFramecnt = 0;
248 
249  return ISF_SUCCESS;
250 }
251 
252 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for validating current settings.
253  * @details This function is responsible for validating the current settings and if the current settings are not valid settings,
254  * it provides the best suitable settings.
255  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
256  * @param[in] pSensorSettings The reference to the sensor settings.
257  *
258  * @return ::fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
259  * @retval ::ISF_SUCCESS is returned when the device settings are successfully validated.
260  * @retval ::DSA_RET_SETTINGS_CHANGED is returned when the current settings have been changed.
261  *
262  * @Constraints None
263  *
264  * @Reentrant Yes
265  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
266  */
268 {
269  // Check the input arguments.
270  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
271  return DSA_ERR_PARAM;
272  }
273 
274  // Set the default return status
275  isf_dsa_status_t retStatus = ISF_SUCCESS;
276 
277  // Check the sample period
278  int32 odr = get_ODR(pSensorSettings->nSamplePeriod);
279 
280  if (odr < 0)
281  {
282  retStatus = DSA_RET_SETTINGS_CHANGED;
283  }
284 
285  return retStatus;
286 }
287 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for configuration.
288  * @details This function resets the sensor, applies the settings, and registers a callback with the Bus Manager(BM) timer. It does
289  * not yet start the timer, as this is done by fsl_fxas21002_i2cspi_3D_gyro_StartData().
290  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21000 sensor adapter.
291  * @param[in] pSensorSettings The reference to the sensor configuration settings.
292  *
293  * @return ::fsl_fxas21002_i2cspi_3D_gyro_Configure() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
294  * @retval ::ISF_SUCCESS is returned when the device is configured successfully.
295  * @retval ::DSA_ERR_CONFIGURE is returned when the provided configuration settings could not be applied.
296  *
297  * @Constraints None
298  *
299  * @Reentrant Yes
300  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
301  */
302 //#define DEBUG_READ_ALL_REGS
303 #ifdef DEBUG_READ_ALL_REGS
304 static uint8 debugRegs[120];
305 #endif
307 {
308  // Check the input arguments
309  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
310  return DSA_ERR_PARAM;
311  }
312 
313  int32_t status;
315 
316  // Get the device descriptor and sensor specific settings
317  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
318 
320 
321  // Check the device descriptor pointer.
322  if ((NULL == pDeviceDescriptor) || (NULL == pSpecificSettings))
323  {
324  return DSA_ERR_PARAM;
325  }
326 
327 
328  // Lock the device descriptor.
329  //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
330  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
331  // Check the driver state.
332  if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
333  goto unlockdescriptor;
334  }
335 
336  // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
337  // or any number of undesirable things may occur.
338  if (ISF_SUCCESS != dm_channel_acquire_lock(&pDeviceDescriptor->cDescriptor, 0)) {
339  goto unlockdescriptor;
340  }
341 
342  /* Set FXAS21002 into Standby before configuration */
343  {
344  uint8 buffer[1];
345  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXAS21002_CTRL_REG1, buffer, 1, 1))
346  {
347  goto unlockchannel;
348  }
349  buffer[0] = (buffer[0] & ~ (FXAS21002_ACTIVE_MASK | FXAS21002_READY_MASK ));
350  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXAS21002_CTRL_REG1, buffer, 1 ,1))
351  {
352  goto unlockchannel;
353  }
354  }
355 
356  /* Write the sensor specific data based on the pre-computed register level pairs (Addr, Value) */
357  {
358  uint8 buffer[1];
359 
360  uint32 cnt=pSpecificSettings->regCount;
362  {
363  cnt=2;
364  }
365  for (uint32 reg=0; reg < cnt ; reg++)
366  {
367  buffer[0] = pSpecificSettings->regPairs[reg].regValue;
368  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, pSpecificSettings->regPairs[reg].regAddr,&buffer[0],1,1))
369  {
370  goto unlockchannel;
371  }
372  }
373  }
374 
375  /* Configure the ODR based on the calculated value */
376  {
377  uint8 buffer[1];
378  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXAS21002_CTRL_REG1, buffer, 1, 1))
379  {
380  goto unlockchannel;
381  }
382  buffer[0] |= FXAS21002_SET_FIELD(DR,(uint8)get_ODR(pSensorSettings->nSamplePeriod));
383  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXAS21002_CTRL_REG1,buffer,1,1))
384  {
385  goto unlockchannel;
386  }
387  }
388 #ifdef DEBUG_READ_ALL_REGS
389  for (int i=0; i<sizeof(debugRegs); i++)
390  {
391  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
392  }
393 #endif
394  // Register to bus management timer
396 
397  // Check if there was an error registering with the bus management timer
398  if(BM_ERROR & pDeviceDescriptor->token){
399  goto unlockchannel;
400  }
401 
403  retStatus = ISF_SUCCESS;
404 
405  unlockchannel:
406  // Unlock the channel.
407  // The explicit lock must be released when the configuration is done allowing the bus to be used by others.
408  // User Notice: This is a required function call.
409  status = dm_channel_release_lock(&pDeviceDescriptor->cDescriptor);
410  if (ISF_SUCCESS != status)
411  {
412  retStatus = DSA_ERR_CONFIGURE;
413  }
414 
415  unlockdescriptor:
416 
417  // Unlock the device descriptor.
418  //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
419  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
420 
421  return retStatus;
422 }
423 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for start Data.
424  * @details This function tells the Bus Manager to start the callbacks periodically as defined in the bus configuration and enable the data collection.
425  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
426  *
427  * @return ::fsl_fxas21002_i2cspi_3D_gyro_StartData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
428  * @retval ::ISF_SUCCESS is returned when the data collection callback triggered successfully.
429  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
430  *
431  * @Constraints None
432  *
433  * @Reentrant Yes
434  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
435  */
437 {
438  // Check the input argument
439  if (NULL == pSensorHandle) {
440  return DSA_ERR_PARAM;
441  }
442 
444  // Get the device descriptor and specific settings
445  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
446 
447  // Check the device descriptor.
448  if (NULL == pDeviceDescriptor)
449  return DSA_ERR_PARAM;
450 
451  // Lock the device descriptor.
452  //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
453  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
454 
455  // Check the driver state.
456  if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
457  {
458  goto unlockdescriptor;
459  }
460 
461  // Put the device into active mode
462  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXAS21002_POWER_ACTIVE)) {
463  goto unlockdescriptor;
464  }
465 
466  // Wait for transition into active mode to complete
467  if (ISF_SUCCESS != device_wait_for_active(&pDeviceDescriptor->deviceHandle)) {
468  goto unlockdescriptor;
469  }
470  // Start the Bus Manager sampling timer.
471  if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)){ // Check for Bus Manager error and return on failure.
472  goto unlockdescriptor;
473  }
474  // Set device to active state.
476  retStatus = ISF_SUCCESS;
477 
478  unlockdescriptor:
479  // Unlock the device descriptor.
480  //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
481  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
482 
483  return retStatus;
484 }
485 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for End Data.
486  * @details This function tells the Bus Manager to stop the callbacks and disable data collection.
487  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
488  *
489  * @return ::fsl_fxas21002_i2cspi_3D_gyro_EndData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
490  * @retval ::ISF_SUCCESS is returned when the data collection stopped successfully.
491  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
492  *
493  * @Constraints None
494  *
495  * @Reentrant Yes
496  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
497  */
499 {
500  // Check pointers.
501  if(NULL == pSensorHandle){
502  return DSA_ERR_PARAM;
503  }
504  // Set the default return status
506  // Create helper reference pointers.
507  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
508 
509  // Check the device descriptor.
510  if (NULL == pDeviceDescriptor)
511  return DSA_ERR_PARAM;
512 
513  // Lock the device descriptor.
514  //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
515  OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
516 
517  // Check the driver state.
518  if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
519  {
520  goto unlockdescriptor;
521  }
522 
523  // Check that the adapter is not already started.
524  if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
525  // If it is, then stop the Bus Manager (BM) sample timer.
526  isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
527  if (BM_ERROR & bmStopStatus)
528  {
529  goto unlockdescriptor;
530  }
531 
532  }
533 #if 0
534  // Put the device into standby mode
535  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXAS21002_POWER_STANDBY)) {
536  goto unlockdescriptor;
537  }
538 #endif
540  retStatus = ISF_SUCCESS;
541 
542 
543  unlockdescriptor:
544  // Unlock the device descriptor.
545  //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
546  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
547 
548  return retStatus;
549 }
550 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for calibration .
551  * @details The FXAS21000 does not provide the capability to be dynamically calibrated. Therefore, this function simply returns success.
552  *
553  * @param[in] pSensorHandle This is a pointer to the instance of the FXAS21002 sensor adapter.
554  * @param[in] pCalData This is a void pointer to the calibration data.
555  @return ::fsl_fxas21002_i2cspi_3D_gyro_Calibrate() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
556  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
557  * \b Note: Currently, there is no return error type defined for this API.
558  *
559  * @Constraints None
560  *
561  * @Reentrant Yes
562  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
563  */
565 {
566  return ISF_SUCCESS;
567 }
568 /*! @brief This is the concrete implementation of the FXAS21002 sensor adapter for shutdown .
569  *
570  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
571  *
572  @return ::fsl_fxas21002_i2cspi_3D_gyro_Shutdown() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
573  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
574  * \b Note: Currently, there is no return error type defined for this API.
575  *
576  * @Constraints None
577  *
578  * @Reentrant Yes
579  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
580  */
582 {
583  if(NULL == pSensorHandle){
584  return DSA_ERR_PARAM;
585  }
586  // Set the default return status
587  isf_dsa_status_t retStatus = ISF_SUCCESS;
588  // Create helper reference pointers.
589  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
590 
591  // Remove the sensor adapter from the Bus Manager callbacks.
592  if(ISF_SUCCESS != bm_unregister_callback(pDeviceDescriptor->token))
593  {
594  return DSA_ERR_SHUTDOWN;
595  }
596  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
597  return retStatus;
598 }
599 /*! @brief The callback function for the Bus Manager(BM).
600  * @details The Bus Manager calls this function periodically based on the period configured for the FXAS21002.
601  *
602  * @param[in] pSensorHandle This is a void pointer to the instance of the FXAS21002 sensor adapter.
603  *
604  * @return Void There is no return value.
605  *
606  * @Constraints None
607  *
608  * @Reentrant Yes
609  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
610  */
612 {
613  // Check the input argument
614  if (NULL == pSensorHandle) {
615  return;
616  }
617 
618  // Get the device descriptor and specific settings
619  volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
621  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
622 
623  isf_status_t st;
624  int32 numBytes;
625 
626  // Check the device descriptor
627  if (NULL == pDeviceDescriptor){
628  return;
629  }
630 
631  // Create a helper pointer to the current sample buffer.
632  fxas21002_DataBuffer_t *pCurrentSampleBuffer = (fxas21002_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
633 
634  // Apply sample skip if necessary.
635  if (pDeviceDescriptor->skipFramecnt) {
636  // Not done skipping samples.
637  --pDeviceDescriptor->skipFramecnt;
638  return;
639  }
640 
641  // Get the time stamp
642  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
643 
644  // Lock the device descriptor.
645  //if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0))
646  if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
647  {
648  goto unlockdescriptor;
649  }
650 
651  // Check the driver state.
652  if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
653  {
654  goto unlockdescriptor;
655  }
656 
657  // Get the time stamp
658  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
659 
660 #ifdef DEBUG_READ_ALL_REGS
661  for (int i=0; i<sizeof(debugRegs); i++)
662  {
663  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
664  }
665 #endif
666 
667  // read the gyroscope data.
668  dm_device_read(&pDeviceDescriptor->deviceHandle, FXAS21002_OUT_X_MSB, (uint8 *)&pCurrentSampleBuffer->gyro[0], MAX_BUF_SIZE,MAX_DATA_READ_SIZE);
669 
670  // Convert the samples to big endian.
671  pCurrentSampleBuffer->gyro[0] = isf_swap2byte(pCurrentSampleBuffer->gyro[0]);
672  pCurrentSampleBuffer->gyro[1] = isf_swap2byte(pCurrentSampleBuffer->gyro[1]);
673  pCurrentSampleBuffer->gyro[2] = isf_swap2byte(pCurrentSampleBuffer->gyro[2]);
674 
675 
676  // read the device temperature data (in Celsius).
677  dm_device_read(&pDeviceDescriptor->deviceHandle, FXAS21002_TEMP, (uint8 *)&pCurrentSampleBuffer->temperature,
679 
680 
681  // Lock the fifo for update.
682  if(kStatus_OSA_Success != isf_fifo_lock(pFifo)){
683  return;
684  }
685 
687 
688  // write the new data
690  {
691  *pFifoEntry = *pCurrentSampleBuffer;
692  }
693  else
694  {
696  pSensorHdl,
699  pCurrentSampleBuffer,
700  pFifoEntry,
701  &numBytes);
702  }
703 
704  // Increment the fifo to the next sample entry.
705  st = isf_fifo_el_increment(pFifo);
706 
707  // Unlock the fifo.
708  isf_fifo_unlock(pFifo);
709 
710  if (st == ISF_FIFO_FULL)
711  {
712  // Notify the user using their registered event information
713  //_lwevent_set(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
714  OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
715  }
716 
717  unlockdescriptor:
718  // Unlock the device descriptor.
719  //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
720  OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
721 
722 }
723 /*!
724  * @brief This function coverts the raw sample data to the desired output type.
725  */
727 (
728  volatile isf_SensorHandle_t *pSensorHandle,
729  isf_SensorDataTypes_t convertToType,
730  isf_dsa_result_types_t resultType,
731  void *pNativeSample,
732  void *pConvertedSample,
733  int32 *numBytes
734 )
735 {
738 
739  pConverter = NULL;
740 
741  switch (convertToType)
742  {
744  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
745  pConverter = float_gyro3d_converter;
746  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
747  pConverter = fixed_gyro3d_converter;
748  else if(resultType == DSA_RESULT_TYPE_RAW_COUNTS)
749  pConverter = count_gyro3d_converter;
750  break;
751 
752  case TYPE_TEMPERATURE:
753  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
754  pConverter = float_temp1d_converter;
755  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
756  pConverter = fixed_temp1d_converter;
757  break;
758 
759  default:
761  }
762  if (pConverter == NULL)
764 
765  retStatus = pConverter(
767  (fxas21002_DataBuffer_t *)pNativeSample,
768  pConvertedSample
769  );
770 
771  return retStatus;
772 }
773 
774 static isf_dsa_status_t float_temp1d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample )
775 {
776  isf_DegreesCelsius1D_float_t *convertedSample = (isf_DegreesCelsius1D_float_t *)vpConvertedSample;
777  convertedSample->timestamp = nativeSample->timeStamp;
779  return ISF_SUCCESS;
780 }
781 
782 static isf_dsa_status_t fixed_temp1d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample )
783 {
784  isf_DegreesCelsius1D_EngFixed_t *convertedSample = (isf_DegreesCelsius1D_EngFixed_t *)vpConvertedSample;
785  convertedSample->timestamp = nativeSample->timeStamp;
787  return ISF_SUCCESS;
788 }
789 
790 static isf_dsa_status_t float_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample )
791 {
793  {
794  isf_AngularVelocity3D__float_t *convertedSample = (isf_AngularVelocity3D__float_t *)vpConvertedSample;
795  convertedSample->timestamp = nativeSample->timeStamp;
796  // Convert the sample based on the full-scale range.
797  convertedSample->angularVelocity[0] = nativeSample->gyro[0] * fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatFactor + fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
798  convertedSample->angularVelocity[1] = nativeSample->gyro[1] * fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatFactor + fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
799  convertedSample->angularVelocity[2] = nativeSample->gyro[2] * fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatFactor + fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
800  return ISF_SUCCESS;
801  }
803  {
804  isf_AngularVelocity3D__float_t *convertedSample = (isf_AngularVelocity3D__float_t *)vpConvertedSample;
805  convertedSample->timestamp = nativeSample->timeStamp;
806  // Convert the sample based on the full-scale range.
807  float conversionFactor = fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatFactor;
808  if(pSensorSpecificConfig->fsdouble)
809  {
810  conversionFactor *= 2.0;
811  }
812  convertedSample->angularVelocity[0] = nativeSample->gyro[0] * conversionFactor + fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
813  convertedSample->angularVelocity[1] = nativeSample->gyro[1] * conversionFactor + fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
814  convertedSample->angularVelocity[2] = nativeSample->gyro[2] * conversionFactor + fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].floatOffset;
815  return ISF_SUCCESS;
816  }
817 
818  return ISF_SUCCESS;
819 }
820 
821 static isf_dsa_status_t fixed_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample )
822 {
824  {
825  isf_AngularVelocity3D_EngFixed_t *convertedSample = (isf_AngularVelocity3D_EngFixed_t *)vpConvertedSample;
826  convertedSample->timestamp = nativeSample->timeStamp;
827 
828  // Convert the sample based on the full-scale range.
829  int32 conversionFactor = fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].fixedFactor;
830  int32 conversionOffset = fxas21000GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].fixedOffset;
831 
832  convertedSample->angularVelocity[0] = (nativeSample->gyro[0] * conversionFactor) + conversionOffset;
833  convertedSample->angularVelocity[1] = (nativeSample->gyro[1] * conversionFactor) + conversionOffset;
834  convertedSample->angularVelocity[2] = (nativeSample->gyro[2] * conversionFactor) + conversionOffset;
835  return ISF_SUCCESS;
836  }
838  {
839  isf_AngularVelocity3D_EngFixed_t *convertedSample = (isf_AngularVelocity3D_EngFixed_t *)vpConvertedSample;
840  convertedSample->timestamp = nativeSample->timeStamp;
841 
842  // Convert the sample based on the full-scale range.
843  int32 conversionFactor = fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].fixedFactor << pSensorSpecificConfig->fsdouble;
844  int32 conversionOffset = fxas21002GyroConvTable[pSensorSpecificConfig->gyroFullScaleRange].fixedOffset;
845 
846  convertedSample->angularVelocity[0] = (nativeSample->gyro[0] * conversionFactor) + conversionOffset;
847  convertedSample->angularVelocity[1] = (nativeSample->gyro[1] * conversionFactor) + conversionOffset;
848  convertedSample->angularVelocity[2] = (nativeSample->gyro[2] * conversionFactor) + conversionOffset;
849  return ISF_SUCCESS;
850  }
851 
852  return ISF_SUCCESS;
853 }
854 static isf_dsa_status_t count_gyro3d_converter(fxas21002_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxas21002_DataBuffer_t *nativeSample, void *vpConvertedSample )
855 {
856  isf_AngularVelocity3D_RawCount_t *convertedSample = (isf_AngularVelocity3D_RawCount_t *)vpConvertedSample;
857  convertedSample->timestamp = nativeSample->timeStamp;
858  convertedSample->angularVelocity[0] = nativeSample->gyro[0] ;
859  convertedSample->angularVelocity[1] = nativeSample->gyro[1] ;
860  convertedSample->angularVelocity[2] = nativeSample->gyro[2] ;
861 
862 }
863 
864 /*! @brief The local function for validating the device id.
865  * @details This function reads the WHOAMI register value and compares it against the known FXAS21002 WHOAMI value.
866  *
867  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
868  * @param[in] whoami The known WHOAMI value of the FXAS21002
869  *
870  * @return ::device_check_whoami() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
871  * @retval ::ISF_SUCCESS is returned when the device is validated with its WHOAMI value.
872  * @retval ::FXAS21002_ERROR_WHOAMI is returned when device could validates with its WHOAMI value.
873  * *
874  * @Constraints None
875  *
876  * @Reentrant Yes
877  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
878  */
879 static fxas21002_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami) {
880 
881 
882  uint8 buffer[1] = {0x00};
883 
884  dm_device_read(pDeviceHandle, FXAS21002_WHO_AM_I, buffer, 1, 1); // don't check the return code
885  whoami_read_val=buffer[0];
886  if (whoami == buffer[0]) {
887  return ISF_SUCCESS;
888  }
889  else
890  {
891  return FXAS21002_ERROR_WHOAMI;
892  }
893 }
894 
895 /*! @brief The local function to set the power mode in the FXAS21002.
896  * @details This function sets the POWER MODE from options such as ACTIVE, READY and STANDBY Mode.
897  *
898  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
899  * @param[in] power The value of the power.
900  *
901  * @return ::device_set_power_mode() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
902  * @retval ::ISF_SUCCESS is returned when the device is configured with the specified power mode.
903  * @retval ::FXAS21002_ERROR_SETPOWER is returned when the device could not be configured with the specified power mode.
904  * *
905  * @Constraints None
906  *
907  * @Reentrant Yes
908  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
909  */
910 static fxas21002_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxas21002_Power_t power) {
911  // Read the current power mode from the device
912 
913  uint8 buffer[1];
914 
915  if (ISF_SUCCESS != dm_device_read(pDeviceHandle,FXAS21002_CTRL_REG1, buffer, 1, 1))
916  {
918  }
919 
920  // Set or clear the active bit
921  if (FXAS21002_POWER_ACTIVE == power)
922  {
923  buffer[0] |= FXAS21002_SET_FIELD(ACTIVE,1);
924  }
925  else
926  {
927  buffer[0] &= ~FXAS21002_SET_FIELD(ACTIVE,1);
928  }
929 
930  // Write the modified value back to the device
931  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXAS21002_CTRL_REG1, buffer, 1, 1))
932  {
934  }
935 
936  return ISF_SUCCESS;
937 }
938 /*! @brief The local function to validate the device is in the active state.
939  * @details This function keeps checking the state of the device until it becomes active.
940  *
941  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
942  *
943  * @return ::device_wait_for_active() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
944  * @retval ::ISF_SUCCESS is returned when the device becomes active.
945  * @retval ::FXAS21002_ERROR_WAITFORACTIVE is returned when the device is unable to read the active state.
946  * *
947  * @Constraints None
948  *
949  * @Reentrant Yes
950  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
951  */
952 static fxas21002_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle) {
953 
954 
955  uint8 buffer[1];
956  do {
957  if (ISF_SUCCESS != dm_device_read(pDeviceHandle,FXAS21002_DR_STATUS , buffer, 1, 1))
958  {
960  }
961  OSA_TimeDelay(1); // short delay to yield CPU/RTOS.
962  } while (!(buffer[0] & FXAS21002_ZYXDR_MASK));
963  return ISF_SUCCESS;
964 }
965 /*! @brief The local function to decode the ODR..
966  * @details This function decode the ODR value based on the data mode. set GET_ODR_CONFIG for register value correspond to
967  * ODR sample period else it gives ODR sample period in milli second.
968  *
969  * @param[in] samplePeriod This sample period.
970  * @param[in] mode The operational mode
971  * @param[in] dataMode The data mode in which the user requested.
972  *
973  * @return ::get_ODR() returns a value of uint32 indicating the ODR value.
974  *
975  * @Constraints None
976  *
977  * @Reentrant Yes
978  * @Libs fsl_fxas21002_i2cspi_3D_gyro.lib
979  */
980 static int32 get_ODR(uint32 samplePeriod)
981 {
982  uint8 i = 0, flag=0;
983 
985  {
986  for (i = 0; i < sizeof(fxas21000_odrTable); i++)
987  {
988  if(fxas21000_odrTable[i].periodNormalMode == samplePeriod)
989  {
990  flag=1;break;
991  }
992 
993  }
994  if(flag==1)
995  {
996  return fxas21000_odrTable[i].configVal;
997  }
998  else
999  {
1000  return -1;
1001  }
1002  }
1004  {
1005  for (i = 0; i < sizeof(fxas21002_odrTable); i++)
1006  {
1007  if(fxas21002_odrTable[i].periodNormalMode == samplePeriod)
1008  {
1009  flag=1;break;
1010  }
1011 
1012  }
1013  if(flag==1)
1014  {
1015  return fxas21002_odrTable[i].configVal;
1016  }
1017  else
1018  {
1019  return -1;
1020  }
1021  } // if we found a valid ODR, then return it.
1022 
1023  return -1; // Should never get here.
1024 }
1025 
1026 /*!
1027 ** @}
1028 */
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
isf_temperature_degC_float_t temperature
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This is the concrete implementation of the FXAS21002 sensor adapter for calibration ...
void * pSensorSpecificSettings
unsigned char uint8
Definition: isf_types.h:76
the structure defines the ODR table between Hybrid and normal mode of FXAS21000 operation.
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_EndData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for End Data. ...
#define FXAS21002_TEMP_FIXED_CONVERSION_FACTOR
FXAS21002 temperature conversion to store in ISF sensors standard fixed point temperature (degC) ...
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_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.
Standard fixed type for three axis accelerometers.
int32 fxas21002_Status_t
FXAS21002 internal return codes.
#define FXAS21002_ACTIVE_MASK
Definition: fxas21002.h:150
#define MAX_DATA_READ_SIZE
const struct @15 fxas21002GyroConvTable[]
const uint8 fxas21002_extendAddress[]
The table that describes the extended address space.
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.
This structure defines the dummy DSA data buffer format.
const void * commInfo
The fsl_fxas21002_i2cspi_3D_gyro.h file contains the definitions and functions supporting the FXAS210...
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
Standard floating point type for single axis temperature sensor.
isf_SensorTypes_t fxas21002_SupportedSensorTypes[]
Supported sensor and data types for FXAS21002.
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_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
#define FALSE
Definition: isf_types.h:86
const struct @15 fxas21000GyroConvTable[]
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
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_fxas21002_i2cspi_3D_gyro_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXAS21002 sensor adapter for configuration.
#define FXAS21002_ZYXDR_MASK
Definition: fxas21002.h:80
Define the sensor device descriptor.
Definition: isf_sensors.h:49
#define FXAS21002_WHOAMI_VALUE_RELEASE
Definition: fxas21002.h:190
The fxas21002.h file contains the FXAS21002 Magnetometer register definitions, access macros...
#define FXAS21002_TEMP_FLOAT_CONVERSION_FACTOR
FXAS21002 temperature conversion to store in ISF sensors standard floating point temperature (degC) ...
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.
#define FXAS21002_WHOAMI_VALUE_PRE_RELEASE
Definition: fxas21002.h:189
const fxas21002_ODR_Table_t fxas21002_odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
#define FXAS21000_WHOAMI_VALUE
Definition: fxas21002.h:188
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_StartData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for start Data.
isf_temperature_degC_fixed_32s1i16_t temperature
Standard raw type for three axes accelerometers.
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
The isf_gyrometer_types.h file contains the ISF data type definitions for use with the ISF generic gy...
uint16 isf_swap2byte(uint16 n)
2 byte swapping method
Definition: isf_util.c:156
Standard float type for three axis accelerometers.
isf_gyrometer_dps_fixed_32s1i16_t angularVelocity[3]
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.
The isf_util.h file contains the utility method declarations and macros.
#define FXAS21002_SET_FIELD(name, val)
Definition: fxas21002.h:66
enum isf_dsa_result_enums isf_dsa_result_types_t
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_gyrometer_dps_raw_16count_t angularVelocity[3]
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXAS21002 sensor adapter for validating current settings...
isf_dsa_result_types_t resultFormat
isf_SensorDataTypes_t
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
The isf_temperature_fixed_t.h file contains the ISF data type definitions for use with the ISF generi...
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...
#define FXAS21002_TEMP_FIXED_CONVERSION_OFFSET
isf_dsa_AdapterStatus_t adapterStatus
signed long int int32
Definition: isf_types.h:74
sys_channelId_t channelId
#define TEMPERATURE_DATA_READ_SIZE
Size of Device Temperature Data to be Read.
Standard fixed type for single axis pressure sensor.
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Shutdown(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for shutdown .
uint8 whoami_read_val
isf_SensorDataTypes_t fxas21002_SupportedDataTypes[]
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
void fsl_fxas21002_i2cspi_3D_gyro_PeriodicCallback(void *pSensorHandle)
The callback function for the Bus Manager(BM).
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
Definition: isf_bm.h:57
isf_gyrometer_dps_float_t angularVelocity[3]
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Initialize(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter initialization.
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 FXAS21002_TEMP_FLOAT_CONVERSION_OFFSET
enum fxas21002_Power_tag fxas21002_Power_t
Enumeration for the FXAS21002 power modes.
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
const fxas21000_ODR_Table_t fxas21000_odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
#define FXAS21002_READY_MASK
Definition: fxas21002.h:152
#define MAX_BUF_SIZE
fxas21002_Sensor_Specific_Reg_t regPairs[]
Definition: fxas21002.h:218
#define TEMPERATURE_BUF_SIZE
Size of Temperature buffer size.
semaphore_t deviceSemaphore
Definition: isf_sensors.h:54
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
#define ISF_FIFO_FULL
Definition: isf_fifo.h:33
bm_callback_token_t token
Definition: isf_sensors.h:53
the structure defines the ODR table between Hybrid and normal mode of FXAS21002 operation.