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