| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

fsl_fxls8471_i2cspi_3D_accel.c
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2015, Freescale Semiconductor, Inc.
4 *
5 */
6 /**
7 ** @file fsl_fxls8471_i2cspi_3D_accel.c
8 ** @version 01.00
9 ** @brief
10 **
11 */
12 /**
13 ** @addtogroup fsl_fxls8471_i2cspi_3D_accel_module fsl_fxls8471_i2cspi_3D_accel module documentation
14 ** @{
15 */
16
17 /* MODULE fsl_fxls8471_i2cspi_3D_accel. */
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>
26 #include <isf_accelerometer_types.h>
27 #include <isf_comm.h>
28 #include <isf_util.h>
29 #include <isf_sensors.h>
30 #include "fsl_os_abstraction.h"
31 #include "fxls8471.h"
32 #include "fsl_fxls8471_i2cspi_3D_accel.h"
33
34
35 /*! @brief User specified settings that may change */
36 static fxls8471_Specific_Settings_t fxls8471_settings;
37
38
39 /*! @brief The constant array, fsl_fxls8471_period, maps the available sample rates into the compatible sampling periods. */
40 static const isf_duration_t fsl_fxls8471_period[] =
41 {
42 1250, // 800 Hz
43 2500, // 400 Hz
44 5000, // 200 Hz
45 10000, // 100 Hz
46 20000, // 50 Hz
47 80000, // 12.5 Hz
48 160000, // 6.25 Hz
49 640000 // 1.56 Hz
50 };
51
52 /*
53 * @brief This table contains the Accel conversion factors based on the full-scale range selected.
54 */
55 const struct
56 {
57 float floatFactor;
58 float floatOffset;
59 int32 fixedFactor;
60 int32 fixedOffset;
61 }fxls8471AccelConvTable[] =
62 {
63 { 0.000061, 0.0, 16, 0},
64 { 0.000122, 0.0, 32, 0},
65 { 0.000244, 0.0, 64, 0}
66 };
67 isf_SensorTypes_t fxls8471_SupportedSensorTypes[] = { TYPE_ACCELEROMETER_3D, TYPE_NATIVE_SENSOR_TYPE };
68 isf_SensorDataTypes_t fxls8471_SupportedDataTypes[] = { TYPE_RAW_ACCELERATION_3D, TYPE_NATIVE_SENSOR_DATA_TYPE };
69
70 // Define the FXLS8471 functional interface status return type.
71 typedef int32 fxls8471_status_t;
72
73 /*
74 * Local function prototypes.
75 */
76 void fxls8471_Reset(int32_t *status, void* pSensorHandle);
77 void fxls8471_CheckId(int32_t *status, void* pSensorHandle);
78 void fxls8471_SetMode(int32_t *status, void* pSensorHandle, int32_t Mode);
79 void fxls8471_ValidateConfig(int32_t *status, void* pSensorHandle, void* pSettings);
80 isf_dsa_status_t fxls8471_GetConfig(isf_dsa_SensorSettings_t* pRequiredSettings, DeviceDescriptor_t* pDeviceDes);
81 isf_dsa_status_t fxls8471_SetConfig(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pConfigSettings);
82 isf_dsa_status_t fxls8471_GetData(isf_SensorHandle_t *pSensorHandle, void* pBuffer);
83
84 // Converter routines for the supported data types
85 static isf_dsa_status_t float_accel3d_converter(fxls8471_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8471_DataBuffer_t *nativeSample, void *vpConvertedSample );
86 static isf_dsa_status_t fixed_accel3d_converter(fxls8471_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8471_DataBuffer_t *nativeSample, void *vpConvertedSample );
87
88 /*
89 ** ===================================================================
90 ** Method : fsl_fxls8471_i2cspi_3D_accel_Initialize (component ISFDSA)
91 ** @brief
92 **
93 ** Parameters :
94 ** NAME - DESCRIPTION
95 ** @param
96 ** isf_SensorHandle_t *pSensorHandle
97 ** @return
98 ** isf_dsa_status_t -
99 ** ===================================================================
100 */
101 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Initialize(isf_SensorHandle_t *pSensorHandle)
102 {
103 if ( NULL == pSensorHandle){
104 return DSA_ERR_PARAM;
105 }
106
107 int32_t status;
108
109 // Check if the sensor is available, and that it has already been initialized.
110 if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
111 return DSA_ERR_INITIALIZE;
112 }
113
114 // Allocate the adapter specific memory for the descriptor
115 //pSensorHandle->pDeviceDescriptor = (DeviceDescriptor_t *)_lwmem_alloc_system_zero(sizeof(DeviceDescriptor_t));
116 pSensorHandle->pDeviceDescriptor = OSA_MemAllocZero(sizeof(DeviceDescriptor_t));
117
118 // Create and validate helper reference pointers.
119 DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
120
121 if (NULL == pDeviceDescriptor) {
122 return DSA_ERR_INITIALIZE;
123 }
124
125 // Allocate the current sample data buffer and initialize it.
126 //pDeviceDescriptor->pCurrentSample = _lwmem_alloc_system_zero(sizeof(fxls8471_DataBuffer_t));
127 pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(fxls8471_DataBuffer_t));
128 fxls8471_DataBuffer_t *pCurrentSampleBuffer = (fxls8471_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
129 pCurrentSampleBuffer->timeStamp = 0;
130 pCurrentSampleBuffer->accel[0] = 0;
131 pCurrentSampleBuffer->accel[1] = 0;
132 pCurrentSampleBuffer->accel[2] = 0;
133
134 dm_ChannelDescriptor_t *pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
135
136 // Initialize the channel
137 if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
138 return DSA_ERR_INITIALIZE;
139 }
140
141 // Start the Bus
142 if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
143 return DSA_ERR_INITIALIZE;
144 }
145
146 // Get the Channel state to check if it is ready to use
147 if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
148 return DSA_ERR_INITIALIZE;
149 }
150
151 // Open the device and get the device handler
152 if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
153 return DSA_ERR_INITIALIZE;
154 }
155 // A very short delay is needed for device startup.
156 OSA_TimeDelay(1);
157
158 // Query the sensor to validate Device Messaging initialization and the sensor identity.
159 fxls8471_CheckId(&status,pSensorHandle);
160 if (ISF_SUCCESS != status)
161 {
162 return DSA_ERR_INITIALIZE;
163 }
164
165 // Set the adapter state to be initialized.
166 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
167
168 // Create a semaphore to synchronize the device descriptor across tasks
169 //if (MQX_OK != _lwsem_create(&pDeviceDescriptor->deviceSemaphore, 1)){
170 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
171 return DSA_ERR_INITIALIZE;
172 }
173
174 pDeviceDescriptor->skipFramecnt = 0;
175
176 return ISF_SUCCESS;
177 }
178
179 /*
180 ** ===================================================================
181 ** Method : fsl_fxls8471_i2cspi_3D_accel_ValidateSettings (component ISFDSA)
182 ** @brief
183 **
184 ** Parameters :
185 ** NAME
186 - DESCRIPTION
187 ** @param
188 ** isf_SensorHandle_t *pSensorHandle
189 ** @param
190 ** isf_SubscriptionSettings_t *pSettings
191 ** @return
192 ** isf_dsa_status_t -
193 ** ===================================================================
194 */
195 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
196 {
197 // Check the input arguments.
198 if ((NULL == pSensorHandle) || (NULL == pSensorSettings)) {
199 return DSA_ERR_PARAM;
200 }
201
202 int32_t status;
203
204 fxls8471_ValidateConfig(&status,pSensorHandle,pSensorSettings);
205
206 return status;
207 }
208
209 /*
210 ** ===================================================================
211 ** Method : fsl_fxls8471_i2cspi_3D_accel_Configure (component ISFDSA)
212 ** @brief
213 **
214 ** Parameters :
215 ** NAME - DESCRIPTION
216 ** @param
217 ** isf_SensorHandle_t *pSensorHandle
218 ** @param
219 ** isf_SubscriptionSettings_t *pConfigSettings
220 ** @return
221 ** isf_dsa_status_t -
222 ** ===================================================================
223 */
224 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
225 {
226 // Check pointers.
227 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
228 return DSA_ERR_PARAM;
229 }
230
231 int32_t status;
232
233 int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
234
235 // Create helper reference pointers.
236 DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) pSensorHandle->pDeviceDescriptor;
237
238 // Check the device descriptor pointer.
239 if (NULL == pDeviceDescriptor)
240 {
241 return retStat;
242 }
243
244 // Lock the device descriptor.
245 //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
246 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
247
248 // Check the driver state.
249 if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
250 goto unlockdescriptor;
251 }
252
253 // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
254 // or any number of undesirable things may occur.
255 if (ISF_SUCCESS != dm_channel_acquire_lock(&pDeviceDescriptor->cDescriptor, 0)) {
256 goto unlockdescriptor;
257 }
258
259 // Set the sensor into STANDBY mode for configuration.
260 fxls8471_SetMode(&status, pSensorHandle, SENSOR_STANDBY);
261 if (ISF_SUCCESS != status) {
262 goto unlockchannel;
263 }
264
265 // Configure the sensor.
266 retStat = fxls8471_SetConfig(pSensorHandle, pSensorSettings);
267 if (ISF_SUCCESS != retStat) {
268 goto unlockchannel;
269 }
270
271 // Register the periodic callback function with the Bus Manager.
272 pDeviceDescriptor->token = bm_register_periodic_callback( pSensorSettings->nSamplePeriod, fsl_fxls8471_i2cspi_3D_accel_PeriodicCallback , pSensorHandle);
273 if(BM_ERROR & pDeviceDescriptor->token){
274 goto unlockchannel;
275 }
276
277 //Store the configured settings
278 pSensorHandle->controlData.sensorSettings = *pSensorSettings;
279
280 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
281 retStat = ISF_SUCCESS;
282
283 unlockchannel:
284 // Unlock the channel.
285 // The explicit lock must be released when the configuration is done allowing the bus to be used by others.
286 // User Notice: This is a required function call.
287 status = dm_channel_release_lock(&pDeviceDescriptor->cDescriptor);
288 if (ISF_SUCCESS != status)
289 {
290 retStat = status;
291 }
292
293 unlockdescriptor:
294
295 // Unlock the device descriptor.
296 //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
297 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
298
299 return retStat;
300 }
301
302 /*
303 ** ===================================================================
304 ** Method : fsl_fxls8471_i2cspi_3D_accel_StartData (component ISFDSA)
305 ** @brief
306 **
307 ** Parameters :
308 ** NAME - DESCRIPTION
309 ** @param
310 ** isf_SensorHandle_t *pSensorHandle
311 ** @return
312 ** isf_dsa_status_t -
313 ** ===================================================================
314 */
315 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_StartData(isf_SensorHandle_t *pSensorHandle)
316 {
317 // Check pointers.
318 if(NULL == pSensorHandle){
319 return DSA_ERR_PARAM;
320 }
321
322 int32_t status;
323 int32_t retStat = DSA_ERR_START_DATA;
324
325 // Create helper reference pointers.
326 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
327
328 // Check the device descriptor.
329 if (NULL == pDeviceDescriptor)
330 return DSA_ERR_PARAM;
331
332 // Lock the device descriptor.
333 //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
334 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
335
336 // Check the driver state.
337 if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
338 {
339 goto unlockdescriptor;
340 }
341
342 // Set the sensor into ACTIVE mode for operation.
343 fxls8471_SetMode(&status, pSensorHandle, SENSOR_ACTIVE);
344 if (ISF_SUCCESS != status) {
345 goto unlockdescriptor;
346 }
347
348 // Start the Bus Manager sampling timer.
349 if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) // Check for Bus Manager error and return on failure.
350 goto unlockdescriptor;
351
352 // Set device to active state.
353 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STARTED;
354 retStat = ISF_SUCCESS;
355
356 unlockdescriptor:
357 // Unlock the device descriptor.
358 //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
359 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
360
361 return retStat;
362 }
363
364 /*
365 ** ===================================================================
366 ** Method : fsl_fxls8471_i2cspi_3D_accel_EndData (component ISFDSA)
367 ** @brief
368 **
369 ** Parameters :
370 ** NAME - DESCRIPTION
371 ** @param
372 ** isf_SensorHandle_t *pSensorHandle
373 ** @return
374 ** isf_dsa_status_t -
375 ** ===================================================================
376 */
377 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_EndData(isf_SensorHandle_t *pSensorHandle)
378 {
379 // Check pointers.
380 if(NULL == pSensorHandle){
381 return DSA_ERR_PARAM;
382 }
383
384 int32_t status;
385
386 // Create helper reference pointers.
387 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
388
389 // Set the default return status.
390 int32_t retStat = DSA_ERR_END_DATA;
391
392 // Check the device descriptor.
393 if (NULL == pDeviceDescriptor)
394 return retStat;
395
396 // Lock the device descriptor.
397 //_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0);
398 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
399
400 // Check the driver state.
401 if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
402 goto unlockdescriptor;
403
404 // Check that the adapter is not already started.
405 if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
406 // If it is, then stop the Bus Manager (BM) sample timer.
407 isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
408 if (BM_ERROR & bmStopStatus)
409 goto unlockdescriptor;
410 }
411 #if 0
412 // Set the sensor into STANDBY mode for configuration.
413 fxls8471_SetMode(&status, pSensorHandle, SENSOR_STANDBY);
414 #endif
415 if (ISF_SUCCESS != status) {
416 goto unlockdescriptor;
417 }
418
419 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
420 retStat = ISF_SUCCESS;
421
422
423 unlockdescriptor:
424 // Unlock the device descriptor.
425 //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
426 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
427
428 return retStat;
429 }
430
431 /*
432 ** ===================================================================
433 ** Method : fsl_fxls8471_i2cspi_3D_accel_Calibrate (component ISFDSA)
434 ** @brief
435 **
436 ** Parameters :
437 ** NAME - DESCRIPTION
438 ** @param
439 ** isf_SensorHandle_t *pSensorHandle
440 ** @return
441 ** isf_dsa_status_t -
442 ** ===================================================================
443 */
444 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData )
445 {
446 int32_t retStat = ISF_SUCCESS;
447
448 return retStat;
449 }
450
451 /*
452 ** ===================================================================
453 ** Method : fsl_fxls8471_i2cspi_3D_accel_Shutdown (component ISFDSA)
454 ** @brief
455 **
456 ** Parameters :
457 ** NAME - DESCRIPTION
458 ** @param
459 ** isf_SensorHandle_t *pSensorHandle
460 ** @return
461 ** isf_dsa_status_t -
462 ** ===================================================================
463 */
464 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Shutdown(isf_SensorHandle_t *pSensorHandle )
465 {
466 if(NULL == pSensorHandle){
467 return DSA_ERR_PARAM;
468 }
469
470 // Create helper reference pointers.
471 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
472
473 // Remove the sensor adapter from the Bus Manager callbacks.
474 bm_unregister_callback(pDeviceDescriptor->token);
475 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
476 return ISF_SUCCESS;
477
478 }
479
480 /*
481 ** ===================================================================
482 ** Method : fsl_fxls8471_i2cspi_3D_accel_PeriodicCallback (component ISFDSA)
483 ** @brief
484 **
485 ** Parameters :
486 ** NAME - DESCRIPTION
487 ** @param
488 ** void* pSensorHandle -
489 ** @return
490 ** void -
491 ** ===================================================================
492 */
493 void fsl_fxls8471_i2cspi_3D_accel_PeriodicCallback(void* pSensorHandle)
494 {
495 // Check pointers.
496 if(NULL == pSensorHandle){
497 return;
498 }
499
500 // Create helper reference pointers.
501 volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
502 isf_fifo_t *pFifo = pSensorHdl->controlData.sensorSettings.pSampleBufferInfo;
503 DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
504 isf_status_t st;
505 int32 numBytes;
506
507 // Check the device descriptor
508 if (NULL == pDeviceDescriptor){
509 return;
510 }
511
512 // Create a helper pointer to the current sample buffer.
513 fxls8471_DataBuffer_t *pCurrentSampleBuffer = (fxls8471_DataBuffer_t *)pDeviceDescriptor->pCurrentSample;
514
515 // Apply sample skip if necessary.
516 if (pDeviceDescriptor->skipFramecnt) {
517 // Not done skipping samples.
518 --pDeviceDescriptor->skipFramecnt;
519 return;
520 }
521
522 // Get the time stamp
523 pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
524
525 // Lock the device descriptor.
526 //if (MQX_OK !=_lwsem_wait_ticks(&pDeviceDescriptor->deviceSemaphore, 0))
527 if (kStatus_OSA_Success !=OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
528 {
529 goto unlockdescriptor;
530 }
531
532
533 // Check the driver state.
534 if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
535 {
536 goto unlockdescriptor;
537 }
538
539 // Get sensor data.
540 fxls8471_GetData(pSensorHandle, ((uint8*)&pCurrentSampleBuffer->accel[0])); // Returns samples in big endian.
541
542 // Lock the fifo for update.
543 if(kStatus_OSA_Success != isf_fifo_lock(pFifo)){
544 return;
545 }
546
547 fxls8471_DataBuffer_t *pFifoEntry = (fxls8471_DataBuffer_t *)isf_fifo_el_get_insert_pointer(pFifo);
548
549
550 // write the new data
551 if (pSensorHdl->controlData.sensorSettings.resultType == TYPE_NATIVE_SENSOR_DATA_TYPE )
552 {
553 *pFifoEntry = *pCurrentSampleBuffer;
554 }
555 else
556 {
557 fsl_fxls8471_i2cspi_3D_accel_Convert(
558 pSensorHdl,
559 pSensorHdl->controlData.sensorSettings.resultType,
560 pSensorHdl->controlData.sensorSettings.resultFormat,
561 pCurrentSampleBuffer,
562 pFifoEntry,
563 &numBytes);
564 }
565
566 // Increment the fifo to the next sample entry.
567 st = isf_fifo_el_increment(pFifo);
568
569 // Unlock the fifo.
570 isf_fifo_unlock(pFifo);
571
572 if (st == ISF_FIFO_FULL)
573 {
574 // Notify the user using their registered event information
575 //_lwevent_set(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
576 OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
577 }
578
579 unlockdescriptor:
580 // Unlock the device descriptor.
581 //_lwsem_post(&pDeviceDescriptor->deviceSemaphore);
582 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
583
584 }
585
586 /*!
587 * @brief This function coverts the raw sample data to the desired output type.
588 */
589 isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Convert
590 (
591 volatile isf_SensorHandle_t *pSensorHandle,
592 isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
593 void *pNativeSample,
594 void *pConvertedSample,
595 int32 *numBytes
596 )
597 {
598 isf_dsa_status_t retStat = DSA_ERR_BAD_SENSOR_DATA_TYPE;
599 isf_dsa_status_t (*pConverter)(fxls8471_Sensor_Specific_Settings_t *, fxls8471_DataBuffer_t *, void *);
600
601 pConverter = NULL;
602
603 switch (convertToType)
604 {
605 case TYPE_RAW_ACCELERATION_3D:
606 if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
607 pConverter = float_accel3d_converter;
608 else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
609 pConverter = fixed_accel3d_converter;
610 break;
611
612 default:
613 return DSA_ERR_BAD_SENSOR_DATA_TYPE;
614 }
615 if (pConverter == NULL)
616 return DSA_ERR_BAD_RESULT_TYPE;
617
618 retStat = pConverter(
619 (fxls8471_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings,
620 (fxls8471_DataBuffer_t *)pNativeSample,
621 pConvertedSample
622 );
623
624 return retStat;
625 }
626
627 static isf_dsa_status_t float_accel3d_converter(fxls8471_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8471_DataBuffer_t *nativeSample, void *vpConvertedSample )
628 {
629 isf_Acceleration3D_Float_t *convertedSample = (isf_Acceleration3D_Float_t *)vpConvertedSample;
630 convertedSample->timestamp = nativeSample->timeStamp;
631 // These factors and offsets really depends on the configured sensor Range in pSensorSpecificConfig
632 //convertedSample->accel[0] = nativeSample->accel[0] * FXLS8471_ACCEL_FLOAT_CONVERSION_FACTOR + FXLS8471_ACCEL_FLOAT_CONVERSION_OFFSET;
633 //convertedSample->accel[1] = nativeSample->accel[1] * FXLS8471_ACCEL_FLOAT_CONVERSION_FACTOR + FXLS8471_ACCEL_FLOAT_CONVERSION_OFFSET;
634 //convertedSample->accel[2] = nativeSample->accel[2] * FXLS8471_ACCEL_FLOAT_CONVERSION_FACTOR + FXLS8471_ACCEL_FLOAT_CONVERSION_OFFSET;
635
636 // Convert the sample based on the full-scale range.
637 convertedSample->accel[0] = nativeSample->accel[0] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
638 convertedSample->accel[1] = nativeSample->accel[1] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
639 convertedSample->accel[2] = nativeSample->accel[2] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].floatOffset;
640 return ISF_SUCCESS;
641 }
642
643 static isf_dsa_status_t fixed_accel3d_converter(fxls8471_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxls8471_DataBuffer_t *nativeSample, void *vpConvertedSample )
644 {
645 isf_Acceleration3D_EngFixed_t *convertedSample = (isf_Acceleration3D_EngFixed_t *)vpConvertedSample;
646 convertedSample->timestamp = nativeSample->timeStamp;
647 // These factors and offsets really depend on the configured sensor Range in pSensorSpecificConfig
648 //convertedSample->accel[0] = nativeSample->accel[0] * FXLS8471_ACCEL_FIXED_CONVERSION_FACTOR + FXLS8471_ACCEL_FIXED_CONVERSION_OFFSET;
649 //convertedSample->accel[1] = nativeSample->accel[1] * FXLS8471_ACCEL_FIXED_CONVERSION_FACTOR + FXLS8471_ACCEL_FIXED_CONVERSION_OFFSET;
650 //convertedSample->accel[2] = nativeSample->accel[2] * FXLS8471_ACCEL_FIXED_CONVERSION_FACTOR + FXLS8471_ACCEL_FIXED_CONVERSION_OFFSET;
651
652 // Convert the sample based on the full-scale range.
653 convertedSample->accel[0] = (nativeSample->accel[0] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset)/4;
654 convertedSample->accel[1] = (nativeSample->accel[1] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset)/4;
655 convertedSample->accel[2] = (nativeSample->accel[2] * fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedFactor + fxls8471AccelConvTable[pSensorSpecificConfig->accelFullScaleRange].fixedOffset)/4;
656 return ISF_SUCCESS;
657 }
658
659 /*!
660 * @brief This function resets the FXLS8471 sensor resulting in a default configuration for
661 * all registers.
662 */
663 void fxls8471_Reset(int32_t* status, void* pSensorHandle)
664 {
665 uint8 buffer[1] = {0};
666
667 // Create and validate helper reference pointers.
668 isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
669 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
670 dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
671
672 // Reset the device.
673 // Put the device the STANDBY state which is required before any configuration registers are set.
674 buffer[0]= FXLS8471_RST_MASK; // no shift
675 if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXLS8471_CTRL_REG2, buffer, 1, 1)){
676 *status = DSA_ERR_INITIALIZE;
677 return;
678 }
679
680 // Burn a write and ignore the return.
681 buffer[0] = 0;
682 ( void ) dm_device_write(pDeviceHandle, FXLS8471_ASLP_COUNT, buffer, 1, 1);
683
684 // Turn-on time = 1 second (FXLS8471 Data Sheet) for OSR = 2^7 (128).
685 OSA_TimeDelay(1000/5);
686
687 *status = ISF_SUCCESS;
688 }
689
690 /*!
691 * @brief This function validates the FXLS8471 sensor is connected via the I2C bus.
692 */
693 void fxls8471_CheckId(int32_t *status, void* pSensorHandle)
694 {
695 uint8 buffer[1] = {0};
696 int32 retStat = SENSOR_ERROR_CHECKID;
697
698 // Create and validate helper reference pointers.
699 isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
700 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
701 dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
702
703 if (ISF_SUCCESS != dm_device_read(pDeviceHandle, FXLS8471_WHO_AM_I, &buffer[0], 1, 1)){
704 *status = retStat;
705 return;
706 }
707 if (FXLS8471_WHOAMI_VALUE != buffer[0]) {
708 *status = retStat;
709 return;
710 }
711
712 *status = ISF_SUCCESS;
713 }
714
715 /*!
716 * @brief This function validates the configuration for the FXLS8471 sensor.
717 */
718 void fxls8471_ValidateConfig(int32_t* status, void* pSensorHandle, void* pSettings)
719 {
720 isf_dsa_status_t st; // The status variable.
721 isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
722 DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) pSensorHdl->pDeviceDescriptor;
723 isf_dsa_SensorSettings_t *pConfig = (isf_dsa_SensorSettings_t*)pSettings;
724
725 // Validate the configuration data using the global data
726 st = fxls8471_GetConfig( pConfig, pDeviceDescriptor );
727
728 // If the configuration data has been modified. convey this information to user Application.
729 if (st) {
730 *status = DSA_RET_SETTINGS_CHANGED;
731 return;
732 }
733
734 *status = ISF_SUCCESS;
735 }
736
737 /*!
738 * @brief This function sets the FXLS8471 part to the requested mode.
739 */
740 void fxls8471_SetMode(int32_t* status, void* pSensorHandle, int32_t Mode)
741 {
742 isf_SensorHandle_t* pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
743 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
744 dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
745
746 uint8 buffer[1] = {0x00};
747
748 switch(Mode)
749 {
750 // This will put the sensor into the standby mode
751 case SENSOR_STANDBY:
752 case SENSOR_BOOT:
753 case SENSOR_READY:
754 {
755 // this sensor requires read-modify-write
756 if (ISF_SUCCESS != dm_device_read(pDeviceHandle, FXLS8471_CTRL_REG1, buffer, 1, 1) ){
757 *status = SENSOR_ERROR_SETMODE;
758 return;
759 }
760 buffer[0] = (buffer[0] & ~FXLS8471_ACTIVE_MASK);
761 if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXLS8471_CTRL_REG1, buffer, 1, 1) ){
762 *status = SENSOR_ERROR_SETMODE;
763 return;
764 }
765 }
766 break;
767
768 // This will put the sensor into the active state
769 case SENSOR_ACTIVE:
770 {
771 // this sensor requires read-modify-write
772 if (ISF_SUCCESS != dm_device_read(pDeviceHandle, FXLS8471_CTRL_REG1, buffer, 1, 1) ){
773 *status = SENSOR_ERROR_SETMODE;
774 return;
775 }
776 buffer[0] = (buffer[0] | FXLS8471_ACTIVE_MASK);
777 if (ISF_SUCCESS != dm_device_write(pDeviceHandle, FXLS8471_CTRL_REG1, buffer, 1, 1) ){
778 *status = SENSOR_ERROR_SETMODE;
779 return;
780 }
781 // Read the value of the status register to wait for valid data
782 buffer[0] = 0;
783 do {
784 if (ISF_SUCCESS != dm_device_read(pDeviceHandle, FXLS8471_STATUS, buffer, 1, 1) ){
785 *status = SENSOR_ERROR_SETMODE;
786 return;
787 }
788 OSA_TimeDelay(1); // short delay to yield CPU/RTOS.
789 } while (0 == FXLS8471_GET_FIELD(ZYXDR,buffer[0]) ); // Wait for Data Ready.
790 }
791 break;
792
793 default:
794 *status = SENSOR_ERROR_SETMODE;
795 return;
796 }
797 // return success
798 *status = ISF_SUCCESS;
799 }
800
801 /*!
802 * @brief This function retrieves the raw data from the FXLS8471 sensor.
803 */
804 #define BYTES_FOR_FULL_READ 7
805
806 isf_dsa_status_t fxls8471_GetData(isf_SensorHandle_t *pSensorHandle, void* pBuffer)
807 {
808 fxls8471_status_t retStat = SENSOR_ERROR_GETDATA;
809
810 DeviceDescriptor_t* pDeviceDescriptor = (DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
811 dm_DeviceDescriptor_t* pDeviceHandle = &pDeviceDescriptor->deviceHandle;
812
813 uint16* pSensorData = (uint16*)pBuffer;
814 uint8 registerData[BYTES_FOR_FULL_READ];
815
816 // read the full width of the data for both full or short reads
817 if (ISF_SUCCESS != dm_device_read(pDeviceHandle, FXLS8471_STATUS, registerData, BYTES_FOR_FULL_READ, BYTES_FOR_FULL_READ) )
818 { // return error SENSOR_ERROR_GETDATA
819 return retStat;
820 }
821
822 // If there is any data, then format and copy it to the output buffer.
823 if ( FXLS8471_GET_FIELD(ZYXDR, registerData[0] ) > 0 )
824 {
825 // collect the full 16-bit data for each of x,y,z
826 pSensorData[0] = ((int16)registerData[1])<<8 | registerData[2];
827 pSensorData[1] = ((int16)registerData[3])<<8 | registerData[4];
828 pSensorData[2] = ((int16)registerData[5])<<8 | registerData[6];
829 }
830 // return success
831 return ISF_SUCCESS;
832 }
833
834
835 /*!
836 * @brief This function sets the FXLS8471 sensor configuration.
837 */
838 isf_dsa_status_t fxls8471_SetConfig(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pConfigSettings)
839 {
840 int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
841 uint8 address, value;
842
843 // Create helper reference pointers.
844 DeviceDescriptor_t *pDeviceDescriptor = (DeviceDescriptor_t*) pSensorHandle->pDeviceDescriptor;
845 fxls8471_Sensor_Specific_Settings_t *pConfigSpecific = (fxls8471_Sensor_Specific_Settings_t*) pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
846 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
847
848 /* Write the sensor specific data based on the pre-computed register level pairs (Addr, Value) */
849 uint8 buffer[1];
850 for (uint32 reg=0; reg < pConfigSpecific->regCount; reg++)
851 {
852 address = pConfigSpecific->regPairs[reg].regAddr;
853 value = pConfigSpecific->regPairs[reg].regValue;
854 buffer[0] = pConfigSpecific->regPairs[reg].regValue;
855 if (ISF_SUCCESS != dm_device_write(pDeviceHandle, pConfigSpecific->regPairs[reg].regAddr,&buffer[0],1,1))
856 {
857 return retStat;
858 }
859 }
860
861 // Set up the Control register #1 functions: ODR override for SLEEP mode and the WAKE mode ODR.
862 buffer[0] = FXLS8471_SET_FIELD(DR,fxls8471_settings.sampleRateIndex);
863 if (ISF_SUCCESS != dm_device_write(&pDeviceDescriptor->deviceHandle, FXLS8471_CTRL_REG1, buffer, 1, 1) ) return FXLS8471_ERROR;
864
865 return ISF_SUCCESS;
866 }
867
868 /*
869 * Local Subroutines
870 */
871
872 /*! @brief This function obtains the configuration register values for a given user configuration of the FXLS8471.
873 * If the configuration has changed then it returns true and saves the new configuration.
874 *
875 * @param[out] pRequiredSettings update the data period in settings
876 * @param[out] pDeviceDes update the data rate in the generic sensor structure for this device
877 * @return ::fxls8471_GetConfig() returns a value of type ::isf_dsa_status_t indicating the success or failure of the function
878 * call.
879 * @retval 0 is returned when the configuration is valid.
880 * @retval 1 is returned when the configuration is modified.
881 *
882 * @Constraints None
883 *
884 * @Reentrant Yes
885 * @Libs lib_fsl_fxls8471_i2cspi_3D_accel.lib
886 */
887 isf_dsa_status_t fxls8471_GetConfig(isf_dsa_SensorSettings_t* pRequiredSettings, DeviceDescriptor_t* pDeviceDes)
888 {
889 // Validate the reporting rate.
890 uint8 retStat = 0; // no changes
891 uint8 periodFound = FALSE; // not found
892 uint8 dataRate;
893
894 // get the number of array entries, which is not the max data rate by rather the size
895 // of the array (number or elements in the array), max index = size - 1
896 uint8 maxDataRateIndex = sizeof fsl_fxls8471_period / sizeof fsl_fxls8471_period[0];
897
898 for (dataRate = 0; dataRate < maxDataRateIndex; dataRate++)
899 {
900 if (fsl_fxls8471_period[dataRate] == pRequiredSettings->nSamplePeriod)
901 {
902 periodFound = TRUE;
903 break;
904 }
905 }
906
907 // If a valid reporting rate has not been set, then default to the FXLS8471 hardware default of 800Hz.
908 if ( !periodFound )
909 {
910 retStat = (isf_dsa_status_t)DSA_RET_SETTINGS_CHANGED;
911 pRequiredSettings->nSamplePeriod = FSL_FXLS8471_ACCEL_800HZ;
912 fxls8471_settings.sampleRateIndex = maxDataRateIndex - 1; // max range index
913 }
914 else
915 { // copy the rate index to local storage as needed
916 fxls8471_settings.sampleRateIndex = dataRate;
917 }
918
919 return retStat;
920 }
921
922 /*!
923 ** @}
924 */
925 /* END fsl_fxls8471_i2cspi_3D_accel.c */
926
927
isf_SensorHandle_st::pDeviceDescriptor
void * pDeviceDescriptor
Definition: isf_dsa_adapter.h:109
dm_channel_start
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Definition: isf_device_messaging.c:137
FXLS8471_RST_MASK
#define FXLS8471_RST_MASK
Definition: fxls8471.h:369
floatFactor
float floatFactor
Definition: fsl_fxls8471_i2cspi_3D_accel.c:57
SensorConfig_st::pSensorSpecificSettings
void * pSensorSpecificSettings
Definition: isf_dsa_adapter.h:157
uint8
unsigned char uint8
Definition: isf_types.h:76
TRUE
#define TRUE
Definition: isf_types.h:82
isf_dsa_adapter.h
DSA_ERR_BAD_RESULT_TYPE
Definition: isf_dsa_adapter.h:39
SENSOR_STANDBY
Definition: isf_sensors.h:22
isf_Acceleration3D_EngFixed_t
Standard fixed type for three axis accelerometers.
Definition: isf_accelerometer_types.h:39
fxls8471_Specific_Settings_t
This structure defines important settings.
Definition: fsl_fxls8471_i2cspi_3D_accel.h:42
isf_Acceleration3D_Float_t::timestamp
isf_timestamp_t timestamp
Definition: isf_accelerometer_types.h:81
SENSOR_ERROR_SETMODE
Definition: isf_sensors.h:42
ISF_SUCCESS
Definition: isf.h:31
isf_time_util_get_usec
uint32 isf_time_util_get_usec(void)
This API returns the time in microseconds.
Definition: isf_util.c:55
dm_device_open
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.
Definition: isf_device_messaging.c:227
DSA_ERR_BAD_SENSOR_DATA_TYPE
Definition: isf_dsa_adapter.h:38
SensorConfig_st::commInfo
const void * commInfo
Definition: isf_dsa_adapter.h:159
isf_SensorHandle_st::controlData
isf_dsa_ControlData_t controlData
Definition: isf_dsa_adapter.h:111
isf_fifo_lock
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
Definition: isf_fifo.c:170
dm_channel_get_state
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
Definition: isf_device_messaging.c:100
isf_fifo_unlock
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
DSA_STATE_CONFIGURED_STARTED
Definition: isf_dsa_adapter.h:60
isf_fifo_el_increment
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
fsl_fxls8471_i2cspi_3D_accel_EndData
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_EndData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:377
fsl_fxls8471_i2cspi_3D_accel_Shutdown
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Shutdown(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:464
isf_sensors.h
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
SENSOR_ACTIVE
Definition: isf_sensors.h:24
FALSE
#define FALSE
Definition: isf_types.h:86
fxls8471_Sensor_Specific_Settings_t
Definition: fxls8471.h:477
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
DeviceDescriptor_struct::deviceHandle
dm_DeviceDescriptor_t deviceHandle
Definition: isf_sensors.h:52
isf_SensorHandle_st
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
Definition: isf_dsa_adapter.h:107
DeviceDescriptor_struct::skipFramecnt
uint8 skipFramecnt
Definition: isf_sensors.h:59
FXLS8471_CTRL_REG2
Definition: fxls8471.h:60
isf_dsa_SensorSettings_st::nSamplePeriod
uint32 nSamplePeriod
Definition: isf_dsa_adapter.h:82
fxls8471AccelConvTable
const struct @16 fxls8471AccelConvTable[]
BYTES_FOR_FULL_READ
#define BYTES_FOR_FULL_READ
This function retrieves the raw data from the FXLS8471 sensor.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:804
DeviceDescriptor_struct
Define the sensor device descriptor.
Definition: isf_sensors.h:49
fxls8471_GetData
isf_dsa_status_t fxls8471_GetData(isf_SensorHandle_t *pSensorHandle, void *pBuffer)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:806
fxls8471_Specific_Settings_t::sampleRateIndex
uint8 sampleRateIndex
Holds the ODR index into the rate array fsl_fxls8471_period */.
Definition: fsl_fxls8471_i2cspi_3D_accel.h:44
pSensorData
void * pSensorData[]
Definition: BasicApp1.c:408
SENSOR_BOOT
Definition: isf_sensors.h:21
fxls8471_GetConfig
isf_dsa_status_t fxls8471_GetConfig(isf_dsa_SensorSettings_t *pRequiredSettings, DeviceDescriptor_t *pDeviceDes)
This function obtains the configuration register values for a given user configuration of the FXLS847...
Definition: fsl_fxls8471_i2cspi_3D_accel.c:887
isf_SensorTypes_t
isf_SensorTypes_t
Definition: isf_sensor_types.h:14
DeviceDescriptor_struct::cDescriptor
dm_ChannelDescriptor_t cDescriptor
Definition: isf_sensors.h:51
dm_device_write
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
Definition: isf_device_messaging.c:309
bm_unregister_callback
isf_status_t bm_unregister_callback(bm_callback_token_t aToken)
This API unregisters one or more callbacks.
Definition: bus_management.c:178
floatOffset
float floatOffset
Definition: fsl_fxls8471_i2cspi_3D_accel.c:58
isf_dsa_ControlData_st::pEventGroup
event_t * pEventGroup
Definition: isf_dsa_adapter.h:92
fxls8471_status_t
int32 fxls8471_status_t
Definition: fsl_fxls8471_i2cspi_3D_accel.c:71
fxls8471.h
The fxls8471.h contains the FXLS8471 Accelerometer register definitions, access macros, and device access functions.
FXLS8471_SET_FIELD
#define FXLS8471_SET_FIELD(name, val)
Definition: fxls8471.h:96
fsl_fxls8471_i2cspi_3D_accel.h
The fsl_fxls8471_i2cspi_3D_accel.h file contains the definitions and functions supporting the MMA8652...
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
DSA_ERR_INITIALIZE
Definition: isf_dsa_adapter.h:29
fxls8471_ValidateConfig
void fxls8471_ValidateConfig(int32_t *status, void *pSensorHandle, void *pSettings)
This function validates the configuration for the FXLS8471 sensor.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:718
fsl_fxls8471_i2cspi_3D_accel_Convert
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Convert(volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
This function coverts the raw sample data to the desired output type.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:590
isf_Acceleration3D_EngFixed_t::accel
isf_acceleration_g_fixed_32s1i16_t accel[3]
Definition: isf_accelerometer_types.h:41
fsl_fxls8471_i2cspi_3D_accel_Configure
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:224
SENSOR_ERROR_CHECKID
Definition: isf_sensors.h:41
DSA_ERR_END_DATA
Definition: isf_dsa_adapter.h:33
DSA_RESULT_TYPE_ENG_FIXED
Definition: isf_dsa_adapter.h:48
DSA_STATE_INITIALIZED
Definition: isf_dsa_adapter.h:58
isf_dsa_status_t
int32 isf_dsa_status_t
This is the Sensor Manager API return type definition.
Definition: isf_dsa_adapter.h:21
TYPE_NATIVE_SENSOR_TYPE
Definition: isf_sensor_types.h:15
isf_Acceleration3D_Float_t::accel
isf_acceleration_g_float_t accel[3]
Definition: isf_accelerometer_types.h:82
int16
signed short int int16
Definition: isf_types.h:73
fxls8471_SetMode
void fxls8471_SetMode(int32_t *status, void *pSensorHandle, int32_t Mode)
This function sets the FXLS8471 part to the requested mode.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:740
fxls8471_SupportedSensorTypes
isf_SensorTypes_t fxls8471_SupportedSensorTypes[]
Supported sensor and data types for FXLS8471.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:67
FXLS8471_GET_FIELD
#define FXLS8471_GET_FIELD(name, val)
Definition: fxls8471.h:97
dm_channel_acquire_lock
isf_status_t dm_channel_acquire_lock(dm_ChannelDescriptor_t *apChannelDescriptor, isf_duration_t aTimeout)
This function locks the channel for exclusive access.
Definition: isf_device_messaging.c:174
isf_sensor_types.h
The isf_sensor_types.h contains the enumerated list of sensor types used by ISF.
isf_util.h
The isf_util.h file contains the utility method declarations and macros.
isf_dsa_result_types_t
enum isf_dsa_result_enums isf_dsa_result_types_t
fsl_fxls8471_i2cspi_3D_accel_Calibrate
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:444
bm_register_periodic_callback
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.
Definition: bus_management.c:94
FXLS8471_ACTIVE_MASK
#define FXLS8471_ACTIVE_MASK
Definition: fxls8471.h:358
FXLS8471_WHOAMI_VALUE
#define FXLS8471_WHOAMI_VALUE
Definition: fxls8471.h:88
fixedOffset
int32 fixedOffset
Definition: fsl_fxls8471_i2cspi_3D_accel.c:60
FXLS8471_ERROR
Definition: fxls8471.h:468
COMM_STATE_OK
Definition: isf_comm.h:28
isf_dsa_SensorSettings_st::resultFormat
isf_dsa_result_types_t resultFormat
Definition: isf_dsa_adapter.h:84
fxls8471_SetConfig
isf_dsa_status_t fxls8471_SetConfig(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pConfigSettings)
This function sets the FXLS8471 sensor configuration.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:838
fxls8471_Reset
void fxls8471_Reset(int32_t *status, void *pSensorHandle)
This function resets the FXLS8471 sensor resulting in a default configuration for all registers...
Definition: fsl_fxls8471_i2cspi_3D_accel.c:663
fxls8471_SupportedDataTypes
isf_SensorDataTypes_t fxls8471_SupportedDataTypes[]
Definition: fsl_fxls8471_i2cspi_3D_accel.c:68
isf_SensorDataTypes_t
isf_SensorDataTypes_t
Definition: isf_sensor_types.h:61
dm_channel_init
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
Definition: isf_device_messaging.c:48
bm_stop
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.
Definition: bus_management.c:349
isf_fifo_t
Definition: isf_fifo.h:19
isf_SensorHandle_st::pSensorStaticConfig
const isf_SensorConfig_t * pSensorStaticConfig
Definition: isf_dsa_adapter.h:110
bm_start
isf_status_t bm_start(boolean aSync, bm_callback_token_t aTokens)
This API sets one or more callback(s) to the active state.
Definition: bus_management.c:278
isf_duration_t
uint32 isf_duration_t
ISF time duration in microseconds.
Definition: isf.h:84
isf_dsa_SensorSettings_st::resultType
isf_SensorDataTypes_t resultType
Definition: isf_dsa_adapter.h:83
isf.h
Main ISF header file. Contains code common to all ISF components.
isf_sm_api.h
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
TYPE_ACCELEROMETER_3D
Definition: isf_sensor_types.h:20
isf_SensorHandle_st::adapterStatus
isf_dsa_AdapterStatus_t adapterStatus
Definition: isf_dsa_adapter.h:112
int32
signed long int int32
Definition: isf_types.h:74
SensorConfig_st::channelId
sys_channelId_t channelId
Definition: isf_dsa_adapter.h:158
uint16
unsigned short int uint16
Definition: isf_types.h:77
DSA_STATE_CONFIGURED_STOPPED
Definition: isf_dsa_adapter.h:59
DSA_ERR_PARAM
Definition: isf_dsa_adapter.h:36
fixedFactor
int32 fixedFactor
Definition: fsl_fxls8471_i2cspi_3D_accel.c:59
fsl_fxls8471_i2cspi_3D_accel_ValidateSettings
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:195
isf_Acceleration3D_Float_t
Standard float type for three axis accelerometers.
Definition: isf_accelerometer_types.h:80
DSA_RESULT_TYPE_ENG_FLOAT
Definition: isf_dsa_adapter.h:49
fxls8471_DataBuffer_t::timeStamp
uint32 timeStamp
Definition: fsl_fxls8471_i2cspi_3D_accel.h:49
DSA_RET_SETTINGS_CHANGED
Definition: isf_dsa_adapter.h:40
isf_dsa_ControlData_st::nEventFieldIndex
uint32 nEventFieldIndex
Definition: isf_dsa_adapter.h:93
isf_dsa_SensorSettings_st::pSampleBufferInfo
isf_fifo_t * pSampleBufferInfo
Definition: isf_dsa_adapter.h:81
dm_device_read
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
Definition: isf_device_messaging.c:271
BM_ERROR
#define BM_ERROR
This value specifies a general Bus Manager error. If an error occurs in registering a callback...
Definition: isf_bm.h:57
FSL_FXLS8471_ACCEL_800HZ
800 Hz
Definition: fsl_fxls8471_i2cspi_3D_accel.h:24
fsl_fxls8471_i2cspi_3D_accel_StartData
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_StartData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:315
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
isf_fifo.h
fxls8471_DataBuffer_t
This structure defines the dummy DSA data buffer format.
Definition: fsl_fxls8471_i2cspi_3D_accel.h:48
DSA_STATE_NOT_INITIALIZED
Definition: isf_dsa_adapter.h:57
isf_dsa_SensorSettings_st
This defines the DSA sensor configuration parameter structure configuring the sensor settings by a su...
Definition: isf_dsa_adapter.h:79
fxls8471_Sensor_Specific_Settings_t::accelFullScaleRange
uint8 accelFullScaleRange
Definition: fxls8471.h:479
DeviceDescriptor_struct::pCurrentSample
void * pCurrentSample
Definition: isf_sensors.h:56
isf_comm.h
isf_comm.h defines the common types for the Communications Service Family of the Intelligent Sensing ...
isf_dsa_ControlData_st::sensorSettings
isf_dsa_SensorSettings_t sensorSettings
Definition: isf_dsa_adapter.h:94
isf_Acceleration3D_EngFixed_t::timestamp
isf_timestamp_t timestamp
Definition: isf_accelerometer_types.h:40
FXLS8471_STATUS
Definition: fxls8471.h:21
isf_fifo_el_get_insert_pointer
void * isf_fifo_el_get_insert_pointer(isf_fifo_t *pFifo)
Routine returns the insert pointer for direct access.
Definition: isf_fifo.c:229
dm_channel_release_lock
isf_status_t dm_channel_release_lock(dm_ChannelDescriptor_t *apChannelDescriptor)
This function releases exclusive channel access.
Definition: isf_device_messaging.c:191
FXLS8471_CTRL_REG1
Definition: fxls8471.h:59
DSA_ERR_START_DATA
Definition: isf_dsa_adapter.h:32
FXLS8471_WHO_AM_I
Definition: fxls8471.h:33
uint32
unsigned long int uint32
Definition: isf_types.h:78
SENSOR_ERROR_GETDATA
Definition: isf_sensors.h:43
dm_DeviceDescriptor_struct
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
fsl_fxls8471_i2cspi_3D_accel_PeriodicCallback
void fsl_fxls8471_i2cspi_3D_accel_PeriodicCallback(void *pSensorHandle)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:493
TYPE_RAW_ACCELERATION_3D
Definition: isf_sensor_types.h:71
isf_accelerometer_types.h
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
SENSOR_READY
Definition: isf_sensors.h:23
fxls8471_CheckId
void fxls8471_CheckId(int32_t *status, void *pSensorHandle)
This function validates the FXLS8471 sensor is connected via the I2C bus.
Definition: fsl_fxls8471_i2cspi_3D_accel.c:693
TYPE_NATIVE_SENSOR_DATA_TYPE
Definition: isf_sensor_types.h:63
DeviceDescriptor_struct::deviceSemaphore
semaphore_t deviceSemaphore
Definition: isf_sensors.h:54
dm_ChannelDescriptor_struct
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
ISF_FIFO_FULL
#define ISF_FIFO_FULL
Definition: isf_fifo.h:33
fxls8471_DataBuffer_t::accel
int16 accel[3]
Definition: fsl_fxls8471_i2cspi_3D_accel.h:50
DSA_ERR_CONFIGURE
Definition: isf_dsa_adapter.h:31
DeviceDescriptor_struct::token
bm_callback_token_t token
Definition: isf_sensors.h:53
FXLS8471_ASLP_COUNT
Definition: fxls8471.h:58
fsl_fxls8471_i2cspi_3D_accel_Initialize
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Initialize(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxls8471_i2cspi_3D_accel.c:101
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.