ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_fxos8700_i2cspi_6D_AccMag.c
Go to the documentation of this file.
1 /**
2  ********************************************************************************
3  * File: fsl_fxos8700_i2cspi_6D_AccMag.c.c
4  *
5  * Copyright (c) 2013, Freescale Semiconductor, Inc.
6  *
7  *******************************************************************************/
8 /**
9  * @file fsl_fxos8700_i2cspi_6D_AccMag.c
10  * @brief The FXOS8700 is a 6-axis consumer combo device that includes an
11  * accelerometer and magnetometer from Freescale that supports both I2C and SPI
12  * protocols. This source file implements the interface for the FXOS8700 Sensor Adapter.
13  * It uses Device Messaging (DM), which abstracts away the differences between the I2C and
14  * SPI protocols, to communicate with the device. This choice is made via the system
15  * communication file, isf_sysconf_comms.c. This file also uses the Bus Manager (BM) to
16  * schedule a periodic callback for reading new sensor data and sending the data to the
17  * Sensor Manager (SM).
18  */
19 #include <mqxlite.h>
20 #include <isf.h>
21 #include <isf_types.h>
22 #include <lwmem.h>
23 #include <lwsem.h>
24 #include <lwevent.h>
25 #include <isf_sm_api.h>
26 #include <isf_dsa_adapter.h>
27 #include <isf_bm.h>
28 #include <isf_sensor_types.h>
29 #include <isf_fifo.h>
31 #include <isf_magnetometer_types.h>
32 #include <isf_comm.h>
33 #include <isf_util.h>
34 #include <isf_sensors.h>
35 #include "fsl_i2c_master_driver.h"
37 #include "fxos8700.h"
38 #include "lwmem.h"
39 
40 /**
41  * @brief Local function declaration for validating the Device ID using the "WHOAMI" command.
42  */
43 static fxos8700_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami);
44 /**
45  * @brief Local function declaration for setting the appropriate power mode.
46  */
47 static fxos8700_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxos8700_Power_t power);
48 /**
49  * @brief Local function declaration for handling the wait state during device activation.
50  */
51 static fxos8700_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle, fxos8700_Mode_t mode);
52 /**
53  * @brief Local function declaration for getting ODR value from the given sample period.
54  */
55 static uint32 get_ODR(uint32 samplePeriod, fxos8700_Mode_t mode, uint8 dataMode);
56 
57 /*! @brief Supported sensor and data types for FXOS8700 */
60 
61 // Converter routines for the supported data types
62 static isf_dsa_status_t float_accel3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample );
63 static isf_dsa_status_t fixed_accel3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample );
64 static isf_dsa_status_t float_mag3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample );
65 static isf_dsa_status_t fixed_mag3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample );
66 
67 #define FXOS8700_MAG_FLOAT_CONVERSION_FACTOR (0.1)
68 #define FXOS8700_MAG_FLOAT_CONVERSION_OFFSET (0.0)
69 #define FXOS8700_MAG_FIXED_CONVERSION_FACTOR (1638)
70 #define FXOS8700_MAG_FIXED_CONVERSION_OFFSET (0)
71 
72 #define MAX_ACCEL_FULL_SCALE_RANGE 2
73 
74 #define FXOS8700_SAMPLE_PERIOD_MAX 640000 // Maximum sample period supported by the FXOS8700.
75 #define FXOS8700_SAMPLE_PERIOD_MIN 1250 // Minimum sample period supported by the FXOS8700.
76 #define GET_ODR_CONFIG 0x0 // Flag enables the configuration value.
77 #define GET_ODR_VALUE 0x01 // Flag enables the ODR value.
78 
79 #define NUM_STATUS_BYTES 1 // Number of status byte.
80 
81 #define NUMBER_OF_AXES_3D 0x3 // Number of Axes for 3 dimension.
82 #define NUMBER_OF_AXES_6D 0x6 // Number of axes of 6 dimension.
83 #define MAX_NUM_AXES 0x6 // Maximum number of axes.
84 #define MAX_FXOS8700_DM_BYTES 0x79 // Maximum number of read/write using direct device messaging to address the registers,
85 
86 // This is the maximum number of register in 8700.
87 #define NUM_INTERNAL_ADDRESS_BYTES 0x1 // Size of the internal address byte.
88 
89 // Macro to assign certain bits in a register.
90 
91 //#define ASSIGN_REG_BITS_VALUE(addr, val, mask, shift) (addr) = (((addr) & ~ (mask)) | (((val) << shift)& (mask)) )
92 
93 // Macro to get the operational mode.
94 #define GET_MODE(mode) ((mode) <= FXOS8700_MODE_HYBRID) ? (mode) : FXOS8700_MODE_HYBRID
95 
96 // Macro to get the member in a structure.
97 #define GET_STRUCT_MEMBER_ADDRESS(p, m) (&(p)->m)
98 // Macro to get the size of the member.
99 #define GET_MEMBER_SIZE(p, m) sizeof((p)->m)
100 /**
101  *
102  *@brief The table that describes the configuration value based on ODR (output data rate).
103  *Note: This table is irregular after the 50HZ, so can't use FLOORLOG2 algorithm.
104  */
106  { 1250, 2500, 0},
107  { 2500, 5000, 1},
108  { 5000, 10000, 2},
109  { 10000, 20000, 3},
110  { 20000, 80000, 4},
111  { 80000, 160000, 5},
112  {160000, 320000, 6},
113  {640000, 1280000, 7},
114 };
115 /*
116  * @brief This table contains the Accel conversion factors based on the full-scale range selected.
117  */
118 const struct
119 {
120  float floatFactor;
121  float floatOffset;
125 {
126  { 0.000061, 0.0, 8, 0},
127  { 0.000122, 0.0, 16, 0},
128  { 0.000244, 0.0, 32, 0}
129 };
130 
131 //fxos8700_DeviceDescriptor_t* gpDeviceDescriptor = NULL;
132 /**
133  *
134  *@brief The table that describes the extended address space.
135  */
137 
138 #define MAX_DATA_READ_SIZE (NUMBER_OF_AXES_6D * 2 + NUM_STATUS_BYTES + sizeof (extendAddress) / sizeof(uint8)) // Maximum number of data
139 
140 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter initialization.
141  * @details This function allocates memory for the device descriptor.
142  * @param[in] pSensorHandle This is a void pointer to the instance of the FXOS8700 sensor adapter.
143  *
144  * @return ::fsl_fxos8700_i2cspi_6D_AccMag_Initialize() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
145  * @retval ::ISF_SUCCESS is returned when the device is initialized properly.
146  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter was passed into the function, i.e. an invalid or NULL parameter.
147  * @retval ::DSA_ERR_INITIALIZE is returned when the driver could not be initialized successfully.
148 
149  *
150  * @Constraints None
151  *
152  * @Reentrant Yes
153  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
154  */
156 {
157  // Check the input argument
158  if (NULL == pSensorHandle) {
159  return DSA_ERR_PARAM;
160  }
161 
162  // Check if the sensor is available, and that it has already been initialized.
163  if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
164  return DSA_ERR_INITIALIZE;
165  }
166 
167  // Allocate memory for the device descriptor
168  pSensorHandle->pDeviceDescriptor = _lwmem_alloc(sizeof(DeviceDescriptor_t));
169 
170  // Hold the descriptor pointers in local variables for upcoming operations
171  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
172 
173  if (NULL == pDeviceDescriptor) {
174  return DSA_ERR_INITIALIZE;
175  }
176 
177  // Allocate the current sample data buffer and initialize it.
178  pDeviceDescriptor->pCurrentSample = _lwmem_alloc_system_zero(sizeof(fxos8700_DataBuffer_t));
179  fxos8700_DataBuffer_t *pCurrentSampleBuffer = (fxos8700_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
180  pCurrentSampleBuffer->timeStamp = 0;
181  pCurrentSampleBuffer->accel[0] = 0;
182  pCurrentSampleBuffer->accel[1] = 0;
183  pCurrentSampleBuffer->accel[2] = 0;
184  pCurrentSampleBuffer->mag[0] = 0;
185  pCurrentSampleBuffer->mag[1] = 0;
186  pCurrentSampleBuffer->mag[2] = 0;
187  pCurrentSampleBuffer->addr = ((i2c_device_t *)pSensorHandle->pSensorStaticConfig->commInfo)->address;
188 
189  dm_ChannelDescriptor_t * pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
190 
191  // Initialize the channel
192  if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
193  return DSA_ERR_INITIALIZE;
194  }
195  // Start the Bus
196  if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
197  return DSA_ERR_INITIALIZE;
198  }
199 
200  // Get the Channel state to check if it is ready to use
201  if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
202  return DSA_ERR_INITIALIZE;
203  }
204 
205  // Open the device and get the device handler
206  if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
207  return DSA_ERR_INITIALIZE;
208  }
209 
210  // Check that it's Gauss and not some other device with the same address
211  if ((ISF_SUCCESS != device_check_whoami(&pDeviceDescriptor->deviceHandle, FXOS8700_WHO_AM_I_VALUE1)) &&
212  (ISF_SUCCESS != device_check_whoami(&pDeviceDescriptor->deviceHandle, FXOS8700_WHO_AM_I_VALUE2)))
213  {
214  return DSA_ERR_INITIALIZE;
215  }
216 
217  // Set the adapter state to be initialized.
218  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
219 
220  // Create a semaphore to synchronize the device descriptor across tasks
221  if (MQX_OK != _lwsem_create(&pDeviceDescriptor->deviceSemaphore, 1)){
222  return DSA_ERR_INITIALIZE;
223  }
224 
225  pDeviceDescriptor->skipFramecnt = 0;
226 
227  return ISF_SUCCESS;
228 }
229 
230 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for validating current settings.
231  * @details This function is responsible for validating the current settings and if the current settings are not valid settings,
232  * it provides the best suitable settings.
233  * @param[in] pSensorHandle This is a pointer to the instance of the FXOS8700 sensor adapter.
234  * @param[in] pSensorSettings The reference to the sensor settings.
235  *
236  * @return ::fsl_fxos8700_i2cspi_6D_AccMag_ValidateSettings() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
237  * @retval ::ISF_SUCCESS is returned when the device settings are successfully validated.
238  * @retval ::DSA_RET_SETTINGS_CHANGED is returned when the current settings have been changed.
239  *
240  * @Constraints None
241  *
242  * @Reentrant Yes
243  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
244  */
246 {
247  // Check the input arguments.
248  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
249  return DSA_ERR_PARAM;
250  }
251 
252  // Set the default return status
253  isf_dsa_status_t retStat = ISF_SUCCESS;
254 
256 
257  // Check the sample period
258  uint32 samplePeriod = get_ODR(pSensorSettings->nSamplePeriod, pSpecificSettings->mode, GET_ODR_VALUE);
259 
260  if (pSensorSettings->nSamplePeriod != samplePeriod) {
261  pSensorSettings->nSamplePeriod = samplePeriod;
262  retStat = DSA_RET_SETTINGS_CHANGED;
263  }
264 
265  return retStat;
266 }
267 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for configuration.
268  * @details This function resets the sensor, applies the settings, and registers a callback with the Bus Manager(BM) timer. It does
269  * not yet start the timer, as this is done by fsl_fxos8700_i2cspi_6D_AccMag_StartData().
270  * @param[in] pSensorHandle This is a pointer to the instance of the FXAS21000 sensor adapter.
271  * @param[in] pSensorSettings The reference to the sensor configuration settings.
272  *
273  * @return ::fsl_fxos8700_i2cspi_6D_AccMag_Configure() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
274  * @retval ::ISF_SUCCESS is returned when the device is configured successfully.
275  * @retval ::DSA_ERR_CONFIGURE is returned when the provided configuration settings could not be applied.
276  *
277  * @Constraints None
278  *
279  * @Reentrant Yes
280  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
281  */
282 //#define DEBUG_READ_ALL_REGS
283 #ifdef DEBUG_READ_ALL_REGS
284 static uint8 debugRegs[120];
285 #endif
287 {
288  // Check the input arguments
289  if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
290  return DSA_ERR_PARAM; // Direct return is okay at this point because no resources have been claimed.
291  }
292 
293  int32_t status;
295 
296  // Get the device descriptor and sensor specific settings
297  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
298 
299  // Create helper pointer for the sensor specific configuration.
301 
302  // Check the device descriptor pointer.
303  if ((NULL == pDeviceDescriptor) || (NULL == pSpecificSettings))
304  {
305  return DSA_ERR_PARAM; // Direct return is okay at this point because no resources have been claimed.
306  }
307 
308 
309  // Lock the device descriptor.
310  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
311 
312  // Check the driver state.
313  if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
314  goto unlockdescriptor;
315  }
316 
317  // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
318  // or any number of undesirable things may occur.
319  if (ISF_SUCCESS != dm_channel_acquire_lock(&pDeviceDescriptor->cDescriptor, 0)) {
320  goto unlockdescriptor;
321  }
322 
323  /* Set FXOS8700 into Standby before configuration */
324  {
325  uint8 buffer[1];
326  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXOS8700_CTRL_REG1, buffer, 1, 1))
327  {
328  goto unlockchannel;
329  }
330  buffer[0] = (buffer[0] & ~FXOS8700_ACTIVE_MASK);
331  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXOS8700_CTRL_REG1,buffer,1,1))
332  {
333  goto unlockchannel;
334  }
335  }
336 
337  /* Write the sensor specific data based on the pre-computed register level pairs (Addr, Value) */
338  {
339  uint8 buffer[1];
340  for (uint32 reg=0; reg < pSpecificSettings->regCount; reg++)
341  {
342  buffer[0] = pSpecificSettings->regPairs[reg].regValue;
343  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, pSpecificSettings->regPairs[reg].regAddr,&buffer[0],1,1))
344  {
345  goto unlockchannel;
346  }
347  }
348  }
349 
350  /* Configure the ODR based on the calculated value */
351  {
352  uint8 buffer[1];
353  if (ISF_SUCCESS != dm_device_read(&pDeviceDescriptor->deviceHandle,FXOS8700_CTRL_REG1, buffer, 1, 1))
354  {
355  goto unlockchannel;
356  }
357  buffer[0] |= FXOS8700_SET_FIELD(DR,(uint8)get_ODR(pSensorSettings->nSamplePeriod, FXOS8700_MODE_HYBRID, GET_ODR_CONFIG));
358  if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXOS8700_CTRL_REG1,buffer,1,1))
359  {
360  goto unlockchannel;
361  }
362  }
363 #ifdef DEBUG_READ_ALL_REGS
364  for (int i=0; i<sizeof(debugRegs); i++)
365  {
366  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
367  }
368 #endif
370 
371  // Check if there was an error registering with the bus management timer
372  if(BM_ERROR & pDeviceDescriptor->token){
373  goto unlockchannel;
374  }
375 
376  //Store the configured settings
377  pSensorHandle->controlData.sensorSettings = *pSensorSettings;
378 
380  retStatus = ISF_SUCCESS;
381 
382 unlockchannel:
383  // Unlock the channel.
384  // The explicit lock must be released when the configuration is done allowing the bus to be used by others.
385  // User Notice: This is a required function call.
386  status = dm_channel_release_lock(&pDeviceDescriptor->cDescriptor);
387  if (ISF_SUCCESS != status)
388  {
389  retStatus = DSA_ERR_CONFIGURE;
390  }
391 
392 unlockdescriptor:
393 
394  // Unlock the device descriptor.
395  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
396 
397  return retStatus;
398 }
399 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for start Data.
400  * @details This function tells the Bus Manager to start the callbacks periodically as defined in the bus configuration and enable the data collection.
401  * @param[in] pSensorHandle This is a pointer to the instance of the FXOS8700 sensor adapter.
402  *
403  * @return ::fsl_fxos8700_i2cspi_6D_AccMag_StartData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
404  * @retval ::ISF_SUCCESS is returned when the data collection callback triggered successfully.
405  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
406  *
407  * @Constraints None
408  *
409  * @Reentrant Yes
410  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
411  */
413 {
414  // Check the input argument
415  if (NULL == pSensorHandle) {
416  return DSA_ERR_PARAM;
417  }
418 
419  int32_t retStat = DSA_ERR_START_DATA;
420 
421  // Create helper pointer for the sensor specific configuration.
423 
424  // Get the device descriptor and specific settings
425  DeviceDescriptor_t* pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
426 
427  // Check the device descriptor.
428  if (NULL == pDeviceDescriptor)
429  return DSA_ERR_PARAM;
430 
431  // Lock the device descriptor.
432  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
433 
434  // Check the driver state.
435  if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
436  {
437  goto unlockdescriptor;
438  }
439 
440  // Put the device into active mode
441  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXOS8700_POWER_ACTIVE)) {
442  goto unlockdescriptor;
443  }
444 
445  // Wait for transition into active mode to complete
446  if (ISF_SUCCESS != device_wait_for_active(&pDeviceDescriptor->deviceHandle, pSpecificSettings->mode)) {
447  goto unlockdescriptor;
448  }
449  // Start the Bus Manager sampling timer.
450  if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) { // Check for Bus Manager error and return on failure.
451  goto unlockdescriptor;
452  }
453 
454  // Set device to active state.
456  retStat = ISF_SUCCESS;
457 
458 unlockdescriptor:
459  // Unlock the device descriptor.
460  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
461 
462  return retStat;
463 }
464 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for End Data.
465  * @details This function tells the Bus Manager to stop the callbacks and disable data collection.
466  * @param[in] pSensorHandle This is a pointer to the instance of the FXOS8700 sensor adapter.
467  *
468  * @return ::fsl_fxos8700_i2cspi_6D_AccMag_EndData() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
469  * @retval ::ISF_SUCCESS is returned when the data collection stopped successfully.
470  * @retval ::DSA_ERR_PARAM is returned when a wrong parameter is passed into the function such as an invalid or NULL parameter.
471  *
472  * @Constraints None
473  *
474  * @Reentrant Yes
475  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
476  */
478 {
479  // Check pointers.
480  if(NULL == pSensorHandle){
481  return DSA_ERR_PARAM;
482  }
483 
484  // Create helper reference pointers.
485  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
486 
487  // Set the default return status.
488  int32_t retStat = DSA_ERR_END_DATA;
489 
490  // Check the device descriptor.
491  if (NULL == pDeviceDescriptor)
492  return DSA_ERR_END_DATA;
493 
494  // Lock the device descriptor.
495  _lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
496 
497  // Check the driver state.
498  if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus) {
499  goto unlockdescriptor;
500  }
501 
502  // Check that the adapter is not already started.
503  if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
504  // If it is, then stop the Bus Manager (BM) sample timer.
505  isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
506  if (BM_ERROR & bmStopStatus) {
507  goto unlockdescriptor;
508  }
509  }
510 
511  // Put the device into standby mode
512  if (ISF_SUCCESS != device_set_power_mode(&pDeviceDescriptor->deviceHandle, FXOS8700_POWER_STANDBY)) {
513  goto unlockdescriptor;
514  }
515 
517  retStat = ISF_SUCCESS;
518 
519 
520 unlockdescriptor:
521  // Unlock the device descriptor.
522  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
523 
524  return retStat;
525 }
526 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for calibration .
527  * @details The FXAS21000 does not provide the capability to be dynamically calibrated. Therefore, this function simply returns success.
528  *
529  * @param[in] pSensorHandle This is a pointer to the instance of the FXOS8700 sensor adapter.
530  * @param[in] pCalData This is a void pointer to the instance of the FXOS8700 calibration data.
531  *
532  @return ::fsl_fxos8700_i2cspi_6D_AccMag_Calibrate() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
533  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
534  * \b Note: Currently, there is no return error type defined for this API.
535  *
536  * @Constraints None
537  *
538  * @Reentrant Yes
539  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
540  */
542 {
543  return ISF_SUCCESS;
544 }
545 /*! @brief This is the concrete implementation of the FXOS8700 sensor adapter for shutdown .
546  *
547  * @param[in] pSensorHandle This is a pointer to the instance of the FXOS8700 sensor adapter.
548  *
549  @return ::fsl_fxos8700_i2cspi_6D_AccMag_Shutdown() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
550  * @retval ::ISF_SUCCESS is returned when the device is calibrated properly.
551  * \b Note: Currently, there is no return error type defined for this API.
552  *
553  * @Constraints None
554  *
555  * @Reentrant Yes
556  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
557  */
559 {
560  if(NULL == pSensorHandle){
561  return DSA_ERR_PARAM;
562  }
563 
564  // Create helper reference pointers.
565  DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
566 
567  // Remove the sensor adapter from the Bus Manager callbacks.
568  bm_unregister_callback(pDeviceDescriptor->token);
569  pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
570  return ISF_SUCCESS;
571 }
572 /*! @brief The callback function for the Bus Manager(BM).
573  * @details The Bus Manager calls this function periodically based on the period configured for the FXOS8700.
574  *
575  * @param[in] pSensorHandle This is a void pointer to the instance of the FXOS8700 sensor adapter.
576  *
577  * @return Void There is no return value.
578  *
579  * @Constraints None
580  *
581  * @Reentrant Yes
582  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
583  */
585 {
586  // Check the input argument
587  if (NULL == pSensorHandle) {
588  return;
589  }
590 
591  // Get the device descriptor and specific settings
592  volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
594  DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
595 
596 
597  isf_status_t st;
598  int32 numBytes;
599 
600  // Check the device descriptor
601  if (NULL == pDeviceDescriptor){
602  return;
603  }
604 
605  // Create a helper pointer to the current sample buffer.
606  fxos8700_DataBuffer_t *pCurrentSampleBuffer = (fxos8700_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
607 
608  // Create a helper pointer to the sensor specific configuration information.
610 
611  // Apply sample skip if necessary.
612  if (pDeviceDescriptor->skipFramecnt) {
613  // Not done skipping samples.
614  --pDeviceDescriptor->skipFramecnt;
615  return;
616  }
617 
618  // Get the time stamp
619  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
620 
621  // Lock the device descriptor.
622  if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0))
623  {
624  goto unlockdescriptor;
625  }
626 
627 
628  // Check the driver state.
629  if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
630  {
631  goto unlockdescriptor;
632  }
633 
634  // Get the time stamp
635  pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
636 
637 #ifdef DEBUG_READ_ALL_REGS
638  for (int i=0; i<sizeof(debugRegs); i++)
639  {
640  dm_device_read(&pDeviceDescriptor->deviceHandle,i, &debugRegs[i], 1, 1);
641  }
642 #endif
643 
644  switch(pSpecificSettings->mode)
645  {
647  // read the accelerometer data only.
648  dm_device_read(&pDeviceDescriptor->deviceHandle, FXOS8700_OUT_X_MSB, (uint8 *)&pCurrentSampleBuffer->accel[0], 6, 6);
649 
650  // Convert the accelerometer samples to big endian and zero the magnetometer samples.
651  pCurrentSampleBuffer->accel[0] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[0]);
652  pCurrentSampleBuffer->accel[1] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[1]);
653  pCurrentSampleBuffer->accel[2] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[2]);
654  pCurrentSampleBuffer->mag[0] = 0;
655  pCurrentSampleBuffer->mag[1] = 0;
656  pCurrentSampleBuffer->mag[2] = 0;
657  break;
658 
660  // read the magnetometer data only.
661  dm_device_read(&pDeviceDescriptor->deviceHandle, FXOS8700_M_OUT_X_MSB, (uint8 *)&pCurrentSampleBuffer->mag[0], 6, 6);
662 
663  // Zero the accelerometer samples and convert the magenetometer samples to big endian.
664  pCurrentSampleBuffer->accel[0] = 0;
665  pCurrentSampleBuffer->accel[1] = 0;
666  pCurrentSampleBuffer->accel[2] = 0;
667  pCurrentSampleBuffer->mag[0] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[0]);
668  pCurrentSampleBuffer->mag[1] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[1]);
669  pCurrentSampleBuffer->mag[2] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[2]);
670  break;
671 
673  // read the accelerometer and magnetometer data.
674  dm_device_read(&pDeviceDescriptor->deviceHandle, FXOS8700_OUT_X_MSB, (uint8 *)&pCurrentSampleBuffer->accel[0], 12, 12);
675 
676  // Convert the samples to big endian.
677  pCurrentSampleBuffer->accel[0] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[0]);
678  pCurrentSampleBuffer->accel[1] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[1]);
679  pCurrentSampleBuffer->accel[2] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->accel[2]);
680  pCurrentSampleBuffer->mag[0] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[0]);
681  pCurrentSampleBuffer->mag[1] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[1]);
682  pCurrentSampleBuffer->mag[2] = SHORT_BE_TO_HOST(pCurrentSampleBuffer->mag[2]);
683 
684  break;
685  default:
686  break;
687  }
688  // Lock the fifo for update.
689  if(MQX_OK != isf_fifo_lock(pFifo)){
690  return;
691  }
692 
694 
695  // write the new data
697  {
698  *pFifoEntry = *pCurrentSampleBuffer;
699  }
700  else
701  {
703  pSensorHdl,
706  pCurrentSampleBuffer,
707  pFifoEntry,
708  &numBytes);
709  }
710 
711  // Increment the fifo to the next sample entry.
712  st = isf_fifo_el_increment(pFifo);
713 
714  // Unlock the fifo.
715  isf_fifo_unlock(pFifo);
716 
717  if (st == ISF_FIFO_FULL)
718  {
719  // Notify the user using their registered event information
720  _lwevent_set(pSensorHdl->controlData.pEventGroup,(_mqx_uint)pSensorHdl->controlData.nEventFieldIndex);
721  }
722 
723 unlockdescriptor:
724  // Unlock the device descriptor.
725  _lwsem_post(&pDeviceDescriptor->deviceSemaphore);
726 
727 }
728 /*!
729  * @brief This function coverts the raw sample data to the desired output type.
730  */
732 (
733  volatile isf_SensorHandle_t *pSensorHandle,
734  isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
735  void *pNativeSample,
736  void *pConvertedSample,
737  int32 *numBytes
738 )
739 {
742 
743  pConverter = NULL;
744 
745  switch (convertToType)
746  {
748  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
749  pConverter = float_accel3d_converter;
750  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
751  pConverter = fixed_accel3d_converter;
752  break;
753 
755  if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
756  pConverter = float_mag3d_converter;
757  else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
758  pConverter = fixed_mag3d_converter;
759  break;
760 
761  default:
763  }
764  if (pConverter == NULL)
766 
767  retStat = pConverter(
769  (fxos8700_DataBuffer_t *)pNativeSample,
770  pConvertedSample
771  );
772 
773  return retStat;
774 }
775 
776 static isf_dsa_status_t float_accel3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample )
777 {
778  isf_Acceleration3D_Float_t *convertedSample = (isf_Acceleration3D_Float_t *)vpConvertedSample;
779  convertedSample->timestamp = nativeSample->timeStamp;
780  // Convert the sample based on the full-scale range.
781  convertedSample->accel[0] = nativeSample->accel[0] * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
782  convertedSample->accel[1] = nativeSample->accel[1] * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
783  convertedSample->accel[2] = nativeSample->accel[2] * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
784 
785  return ISF_SUCCESS;
786 }
787 
788 static isf_dsa_status_t fixed_accel3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample )
789 {
790  isf_Acceleration3D_EngFixed_t *convertedSample = (isf_Acceleration3D_EngFixed_t *)vpConvertedSample;
791  convertedSample->timestamp = nativeSample->timeStamp;
792  // Convert the sample based on the full-scale range.
793  convertedSample->accel[0] = (nativeSample->accel[0]/4 * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset);
794  convertedSample->accel[1] = (nativeSample->accel[1]/4 * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset);
795  convertedSample->accel[2] = (nativeSample->accel[2]/4 * fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxos8700AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset);
796 
797  return ISF_SUCCESS;
798 }
799 
800 static isf_dsa_status_t float_mag3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample )
801 {
802  isf_MagneticFieldStrength3D_float_t *convertedSample = (isf_MagneticFieldStrength3D_float_t *)vpConvertedSample;
803  convertedSample->timestamp = nativeSample->timeStamp;
804  // FXOS8700 has a fixed range, so use the fixed conversion constants.
808 
809  return ISF_SUCCESS;
810 }
811 
812 static isf_dsa_status_t fixed_mag3d_converter(fxos8700_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxos8700_DataBuffer_t *nativeSample, void *vpConvertedSample )
813 {
815  convertedSample->timestamp = nativeSample->timeStamp;
816  // FXOS8700 has a fixed range, so use the fixed conversion constants.
820 
821  return ISF_SUCCESS;
822 }
823 
824 /*! @brief The local function for validating the device id.
825  * @details This function reads the WHOAMI register value and compares it against the known FXOS8700 WHOAMI value.
826  *
827  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
828  * @param[in] whoami The known WHOAMI value of the FXOS8700
829  *
830  * @return ::device_check_whoami() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
831  * @retval ::ISF_SUCCESS is returned when the device is validated with its WHOAMI value.
832  * @retval ::FXOS8700_ERROR_WHOAMI is returned when device could validates with its WHOAMI value.
833  * *
834  * @Constraints None
835  *
836  * @Reentrant Yes
837  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
838  */
839 static fxos8700_Status_t device_check_whoami(dm_DeviceDescriptor_t* pDeviceHandle, uint8 whoami) {
840 
841 
842  uint8 buffer[1] = {0x00};
843 
844  dm_device_read(pDeviceHandle, FXOS8700_WHO_AM_I, buffer, 1, 1); // don't check the return code
845  if (whoami != buffer[0]) {
846  return FXOS8700_ERROR_WHOAMI;
847  }
848  return ISF_SUCCESS;
849 }
850 
851 /*! @brief The local function to set the power mode in the FXOS8700.
852  * @details This function sets the POWER MODE from options such as ACTIVE, READY and STANDBY Mode.
853  *
854  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
855  * @param[in] power The value of the power.
856  *
857  * @return ::device_set_power_mode() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
858  * @retval ::ISF_SUCCESS is returned when the device is configured with the specified power mode.
859  * @retval ::FXOS8700_ERROR_SETPOWER is returned when the device could not be configured with the specified power mode.
860  * *
861  * @Constraints None
862  *
863  * @Reentrant Yes
864  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
865  */
866 static fxos8700_Status_t device_set_power_mode(dm_DeviceDescriptor_t* pDeviceHandle, fxos8700_Power_t power) {
867  // Read the current power mode from the device
868 
869  uint8 buffer[1];
870 
871  if (ISF_SUCCESS != dm_device_read(pDeviceHandle,FXOS8700_CTRL_REG1, buffer, 1, 1))
872  {
874  }
875 
876  // Set or clear the active bit
877  if (FXOS8700_POWER_ACTIVE == power)
878  {
879  buffer[0] |= FXOS8700_SET_FIELD(ACTIVE,1);
880  }
881  else
882  {
883  buffer[0] &= ~FXOS8700_SET_FIELD(ACTIVE,1);
884  }
885 
886  // Write the modified value back to the device
887  if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXOS8700_CTRL_REG1, buffer, 1, 1))
888  {
890  }
891 
892  return ISF_SUCCESS;
893 }
894 /*! @brief The local function to validate the device is in the active state.
895  * @details This function keeps checking the state of the device until it becomes active.
896  *
897  * @param[in] pDeviceHandle This is a reference to the device handle holding information about the device communication.
898  *
899  * @return ::device_wait_for_active() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function call.
900  * @retval ::ISF_SUCCESS is returned when the device becomes active.
901  * @retval ::FXOS8700_ERROR_WAITFORACTIVE is returned when the device is unable to read the active state.
902  * *
903  * @Constraints None
904  *
905  * @Reentrant Yes
906  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
907  */
908 static fxos8700_Status_t device_wait_for_active(dm_DeviceDescriptor_t* pDeviceHandle, fxos8700_Mode_t mode) {
909 
910  /* The ADC samples the magnetometer after the accelerometer, therefore if
911  * M_DR_STATUS[ZYXDR] is set then both accelerometer and magnetometer data
912  * should be ready. However, if we're in accelerometer only mode, then
913  * check DR_STATUS[XYZDR]. */
914  int8 internalAddress = (mode == FXOS8700_MODE_MAGNETOMETER) ? FXOS8700_M_DR_STATUS : FXOS8700_STATUS ;
915  uint8 buffer[1];
916  do {
917  if (ISF_SUCCESS != dm_device_read(pDeviceHandle, internalAddress, buffer, 1, 1))
918  {
920  }
921  _time_delay_ticks(1); // short delay to yield CPU/RTOS.
922  } while (!(buffer[0] & FXOS8700_ZYXDR_MASK));
923  return ISF_SUCCESS;
924 }
925 /*! @brief The local function to decode the ODR..
926  * @details This function decode the ODR value based on the data mode. set GET_ODR_CONFIG for register value correspond to
927  * ODR sample period else it gives ODR sample period in milli second.
928  *
929  * @param[in] samplePeriod This sample period.
930  * @param[in] mode The operational mode
931  * @param[in] dataMode The data mode in which the user requested.
932  *
933  * @return ::get_ODR() returns a value of uint32 indicating the ODR value.
934  *
935  * @Constraints None
936  *
937  * @Reentrant Yes
938  * @Libs fsl_fxos8700_i2cspi_6D_AccMag.lib
939  */
940 static uint32 get_ODR(uint32 samplePeriod, fxos8700_Mode_t mode, uint8 dataMode)
941 {
942  uint8 i = 0;
943  mode = GET_MODE(mode);
944 
945  for (i = 0; i < sizeof(odrTable)/sizeof(fxo8700_ODR_Table_t); i++){
946  if(mode == FXOS8700_MODE_HYBRID){
947  if(odrTable[i].periodHybridMode == samplePeriod){
948  break;
949  }
950  }else{
951  if(odrTable[i].periodNormalMode == samplePeriod){
952  break;
953  }
954  }
955  }
956  i = (i >= sizeof(odrTable)/sizeof(fxo8700_ODR_Table_t)) ? 0 : i;
957  if(dataMode){
958  return ((mode == FXOS8700_MODE_HYBRID )? odrTable[i].periodHybridMode : odrTable[i].periodNormalMode);
959  }else{
960  return odrTable[i].configVal;
961  }
962 }
963 
964 /*!
965 ** @}
966 */
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
void * pSensorSpecificSettings
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
#define FXOS8700_SET_FIELD(name, val)
Definition: fxos8700.h:144
int32 fxos8700_Status_t
FXOS8700 internal return codes.
fsl_i2c_master_driver.h defines structures and types for the i2c master driver.
This structure defines the dummy DSA data buffer format.
void fsl_fxos8700_i2cspi_6D_AccMag_PeriodicCallback(void *pSensorHandle)
The callback function for the Bus Manager(BM).
Standard fixed type for three axis accelerometers.
#define GET_ODR_VALUE
Standard fixed type for three axis accelerometers.
The isf_magnetometer_types.h file contains the ISF data type definitions for use with the ISF generic...
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
Definition: isf_util.c:52
isf_status_t dm_device_open(dm_ChannelDescriptor_t *apChannelDescriptor, void *apDevice, dm_DeviceDescriptor_t *apDeviceDescriptor)
This function creates a device handle for a device at a specified channel address.
const void * commInfo
isf_dsa_ControlData_t controlData
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
Definition: isf_fifo.c:171
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
isf_fifo_status_t isf_fifo_unlock(isf_fifo_t *pFifo)
Release the exclusive access lock on a sample buffer.
Definition: isf_fifo.c:202
const struct @20 fxos8700AccelConvTable[]
#define FXOS8700_MAG_FIXED_CONVERSION_FACTOR
isf_fifo_status_t isf_fifo_el_increment(isf_fifo_t *pFifo)
Routine increments the insert pointer after direct access.
Definition: isf_fifo.c:240
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
Information necessary to communicate with an I2C slave device.
#define FALSE
Definition: isf_types.h:56
isf_fieldStrength_uT_float_t fieldStrength[3]
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_fxos8700_i2cspi_6D_AccMag_Initialize(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter initialization.
const uint8 extendAddress[]
The table that describes the extended address space.
enum fxos8700_Power_tag fxos8700_Power_t
Enumeration for the FXOS8700 power modes.
Define the sensor device descriptor.
Definition: isf_sensors.h:49
LWSEM_STRUCT deviceSemaphore
Definition: isf_sensors.h:54
signed char int8
Definition: basic_types.h:12
The fxos8700.h file describes the FXOS8700 register definition and its bit mask.
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
#define FXOS8700_MAG_FLOAT_CONVERSION_OFFSET
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 FXOS8700_WHO_AM_I_VALUE1
FXOS8700 expected WHO_AM_I value.
isf_SensorTypes_t fxos8700_SupportedSensorTypes[]
Supported sensor and data types for FXOS8700.
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXOS8700 sensor adapter for configuration.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_StartData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for start Data.
isf_acceleration_g_fixed_32s1i16_t accel[3]
#define FXOS8700_MAG_FIXED_CONVERSION_OFFSET
const fxo8700_ODR_Table_t odrTable[]
The table that describes the configuration value based on ODR (output data rate). Note: This table is...
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This is the concrete implementation of the FXOS8700 sensor adapter for calibration ...
isf_acceleration_g_float_t accel[3]
#define FXOS8700_WHO_AM_I_VALUE2
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.
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_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.
The isf_util.h file contains the utility method declarations and macros.
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_SensorDataTypes_t fxos8700_SupportedDataTypes[]
#define FXOS8700_ACTIVE_MASK
Definition: fxos8700.h:281
fxos8700_Sensor_Specific_Reg_t regPairs[]
Definition: fxos8700.h:443
#define FXOS8700_ZYXDR_MASK
Definition: fxos8700.h:349
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.
#define GET_MODE(mode)
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.
#define FXOS8700_MAG_FLOAT_CONVERSION_FACTOR
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:59
long int32
This defines int32 as long.
Definition: isf_types.h:32
isf_SensorDataTypes_t resultType
Main ISF header file. Contains code common to all ISF components.
LWEVENT_STRUCT * pEventGroup
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
sys_channelId_t channelId
isf_microTeslas_fixed_32s1i14_t fieldStrength[3]
Standard float type for three axis accelerometers.
enum fxos8700_Mode_tag fxos8700_Mode_t
The enumeration, fxos8700_Mode_tag, defines the operational modes of the FXOS8700.
#define GET_ODR_CONFIG
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:51
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_status_t fsl_fxos8700_i2cspi_6D_AccMag_Shutdown(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for shutdown . ...
isf_dsa_SensorSettings_t sensorSettings
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:232
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
the structure defines the ODR table between Hybrid and normal mode of device operation.
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_EndData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXOS8700 sensor adapter for End Data.
isf_SensorDataTypes_t TYPE_MAGNETIC_FIELD_STRENGTH_3D
The fsl_fxos8700_i2cspi_6D_AccMag.h file contains the definitions and functions supporting the FXOS87...
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
#define ISF_FIFO_FULL
Definition: isf_fifo.h:32
isf_dsa_status_t fsl_fxos8700_i2cspi_6D_AccMag_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXOS8700 sensor adapter for validating current settings...
bm_callback_token_t token
Definition: isf_sensors.h:53