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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

fsl_mma955x_i2cspi_pedo.c
Go to the documentation of this file.
1 /**
2 ** @file fsl_mma955x.c
3 ** @brief mma955x Sensor Adapter source file
4 ** @copyright Copyright (c) 2015, Freescale Semiconductor, Inc.
5 ** @version 01.00
6 ** @brief
7 **
8 */
9
10 #include <isf.h>
11 #include <isf_types.h>
12 #include <isf_sm_api.h>
13 #include <isf_dsa_adapter.h>
14 #include <isf_bm.h>
15 #include <isf_sensor_types.h>
16 #include <isf_fifo.h>
17 #include <isf_pedometer_types.h>
18 #include <isf_comm.h>
19 #include <isf_util.h>
20 #include <isf_sensors.h>
21 #include "mma955x.h"
22 #include "fsl_mma955x_i2cspi_pedo.h"
23 #include "Ac_Fixed_utils.h"
24
25 extern void mma955xSetSamplingRate(uint32 index);
26
27 /*! @brief Supported sensor and data types */
28 isf_SensorTypes_t mma955x_SupportedSensorTypes[] = { TYPE_ACCELEROMETER_3D, TYPE_NATIVE_SENSOR_TYPE };
29 isf_SensorDataTypes_t mma955x_SupportedDataTypes[] = { TYPE_RAW_ACCELERATION_3D, TYPE_NATIVE_SENSOR_DATA_TYPE };
30
31 /* Declare the local helper functions for mma955x */
32 void mma955x_ValidateConfig(int32_t *status, isf_SensorHandle_t* pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings);
33 int32 mma955x_GetData(int32_t *status, isf_SensorHandle_t* pSensorHandle, void* pBuffer);
34 int32 mma955x_GetPedometerData(isf_SensorHandle_t* pSensorHandle, mma955x_PedometerData_t* pData);
35 int32 mma955x_GetConfig(isf_SensorHandle_t* pSensorHandle, mma955x_appConfigRegister_t* pConfig);
36 int32 mma955x_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer);
37 int32 mma955x_send(dm_DeviceDescriptor_t* pDeviceHandle, const mma955x_CommandList_t *aCommandList);
38 uint8 mma955x_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle);
39
40 static isf_dsa_status_t float_mma955x_converter(mma955x_Sensor_Specific_Settings_t *pSensorSpecificConfig, mma955x_DataBuffer_t *nativeSample, void *vpConvertedSample );
41 static isf_dsa_status_t fixed_mma955x_converter(mma955x_Sensor_Specific_Settings_t *pSensorSpecificConfig, mma955x_DataBuffer_t *nativeSample, void *vpConvertedSample );
42
43
44 /*
45 ** ===================================================================
46 ** Method : fsl_mma955x_Initialize (component ISFDSA)
47 ** @brief
48 **
49 ** Parameters :
50 ** NAME - DESCRIPTION
51 ** @param
52 ** void* pSensorHandle -
53 ** @return
54 ** int32_t -
55 ** ===================================================================
56 */
57 isf_dsa_status_t fsl_mma955x_Initialize( isf_SensorHandle_t *pSensorHandle)
58 {
59 int32 st = ISF_SUCCESS;
60
61 if ( NULL == pSensorHandle){
62 return DSA_ERR_PARAM;
63 }
64
65
66 // Check if the sensor is available, and that it has already been initialized.
67 if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
68 return ISF_SUCCESS;
69 }
70
71 // Allocate the adapter specific memory for the descriptor
72 pSensorHandle->pDeviceDescriptor = (mma955x_DeviceDescriptor_t *)OSA_MemAllocZero(sizeof(mma955x_DeviceDescriptor_t));
73
74 // Create and validate helper reference pointers.
75 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
76
77 if (NULL == pDeviceDescriptor) {
78 return DSA_ERR_INITIALIZE;
79 }
80
81 // Allocate the current sample data buffer and initialize it.
82 pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(mma955x_DataBuffer_t));
83
84 dm_ChannelDescriptor_t *pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
85
86 // Initialize the channel
87 if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
88 return DSA_ERR_INITIALIZE;
89 }
90 // Start the Bus
91 if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
92 return DSA_ERR_INITIALIZE;
93 }
94
95 // Get the Channel state to check if it is ready to use
96 if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
97 return DSA_ERR_INITIALIZE;
98 }
99
100 // Open the device and get the device handler
101 if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
102 return DSA_ERR_INITIALIZE;
103 }
104
105 // A very short delay is needed for device startup.
106 OSA_TimeDelay(100);
107 {
108 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
109
110 if ( pConfigSpecific->initializeCommands.numCommands > 0)
111 {
112 st = mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->initializeCommands);
113 if (ISF_SUCCESS != st)
114 { // At times when the system comes up slow, this command fails and we need to try once again.
115 OSA_TimeDelay(100);
116 st = mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->initializeCommands);
117 }
118 }
119 /* Read and save the current configuration state for future use */
120 st = mma955x_GetConfig(pSensorHandle, &pDeviceDescriptor->localCfgBuffer);
121 }
122 // Set the adapter state to be initialized.
123 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
124
125 // Create a semaphore to synchronize the device descriptor across tasks
126 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
127 return DSA_ERR_INITIALIZE;
128 }
129
130 return st;
131 }
132
133 /*
134 ** ===================================================================
135 ** Method : fsl_mma955x_ValidateSettings (component ISFDSA)
136 ** @brief
137 **
138 ** Parameters :
139 ** NAME - DESCRIPTION
140 ** @param
141 ** void* pSensorHandle -
142 ** @param
143 ** void* pSettings -
144 ** @return
145 ** int32_t -
146 ** ===================================================================
147 */
148 isf_dsa_status_t fsl_mma955x_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
149 {
150 // Check the input arguments.
151 if ((NULL == pSensorHandle) || (NULL == pSubSettings)) {
152 return DSA_ERR_PARAM;
153 }
154
155 int32_t status;
156 mma955x_ValidateConfig(&status,pSensorHandle,pSubSettings);
157
158 return status;
159 }
160
161 /*
162 ** ===================================================================
163 ** Method : fsl_mma955x_Configure (component ISFDSA)
164 ** @brief
165 **
166 ** Parameters :
167 ** NAME - DESCRIPTION
168 ** @param
169 ** void* pSensorHandle -
170 ** @param
171 ** void* pConfigSettings -
172 ** @return
173 ** int32_t -
174 ** ===================================================================
175 */
176 //#define DEBUG_READ_ALL_REGS
177 #ifdef DEBUG_READ_ALL_REGS
178 static uint8 debugRegs[18];
179 #endif
180 isf_dsa_status_t fsl_mma955x_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
181 {
182 // Check pointers.
183 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
184 return DSA_ERR_PARAM;
185 }
186
187 int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
188
189 // Create helper reference pointers.
190 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
191 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
192
193 // Check the device descriptor pointer.
194 if (NULL == pDeviceDescriptor)
195 {
196 return retStat;
197 }
198
199 // Lock the device descriptor.
200 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
201
202 // Check the driver state and if it has already been configured.
203 if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
204 retStat = ISF_SUCCESS;
205 goto unlockdescriptor;
206 }
207
208 mma955xSetSamplingRate(pSensorSettings->nSamplePeriod);
209
210 if ( pConfigSpecific->configureCommands.numCommands > 0)
211 {
212 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->configureCommands);
213 }
214
215 if (pDeviceDescriptor->token)
216 {
217 bm_unregister_callback(pDeviceDescriptor->token);
218 }
219 // Register the periodic callback function with the Bus Manager.
220 pDeviceDescriptor->token = bm_register_periodic_callback( pSensorSettings->nSamplePeriod, fsl_mma955x_PeriodicCallback , (void *)pSensorHandle);
221 if(BM_ERROR & pDeviceDescriptor->token){
222 goto unlockdescriptor;
223 }
224
225 //Store the configured settings
226 pSensorHandle->controlData.sensorSettings = *pSensorSettings;
227
228 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
229 retStat = ISF_SUCCESS;
230
231 unlockdescriptor:
232
233 // Unlock the device descriptor.
234 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
235
236 return retStat;
237 }
238
239 /*
240 ** ===================================================================
241 ** Method : fsl_mma955x_StartData (component ISFDSA)
242 ** @brief
243 **
244 ** Parameters :
245 ** NAME - DESCRIPTION
246 ** @param
247 ** void* pSensorHandle -
248 ** @return
249 ** int32_t -
250 ** ===================================================================
251 */
252 isf_dsa_status_t fsl_mma955x_StartData(isf_SensorHandle_t *pSensorHandle )
253 {
254 // Check pointers.
255 if(NULL == pSensorHandle){
256 return DSA_ERR_PARAM;
257 }
258
259 int32_t retStat = DSA_ERR_START_DATA;
260
261 // Create helper reference pointers.
262 mma955x_DeviceDescriptor_t *pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
263 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
264
265 // Check the device descriptor.
266 if (NULL == pDeviceDescriptor)
267 return DSA_ERR_PARAM;
268
269 // Lock the device descriptor.
270 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
271
272 // Check the driver state and if it data is already started.
273 if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
274 {
275 retStat = ISF_SUCCESS;
276 goto unlockdescriptor;
277 }
278
279 if ( pConfigSpecific->startDataCommands.numCommands > 0)
280 {
281 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->startDataCommands);
282 }
283
284 // Start the Bus Manager sampling timer.
285 if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) // Check for Bus Manager error and return on failure.
286 goto unlockdescriptor;
287
288 // Set device to active state.
289 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STARTED;
290 retStat = ISF_SUCCESS;
291
292 unlockdescriptor:
293 // Unlock the device descriptor.
294 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
295
296
297 return retStat;
298 }
299
300 /*
301 ** ===================================================================
302 ** Method : fsl_mma955x_EndData (component ISFDSA)
303 ** @brief
304 **
305 ** Parameters :
306 ** NAME - DESCRIPTION
307 ** @param
308 ** void* pSensorHandle -
309 ** @return
310 ** int32_t -
311 ** ===================================================================
312 */
313 isf_dsa_status_t fsl_mma955x_EndData(isf_SensorHandle_t *pSensorHandle )
314 {
315 // Check pointers.
316 if(NULL == pSensorHandle){
317 return DSA_ERR_PARAM;
318 }
319
320 // Create helper reference pointers.
321 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
322 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
323
324 // Set the default return status.
325 int32_t retStat = DSA_ERR_END_DATA;
326
327 // Check the device descriptor.
328 if (NULL == pDeviceDescriptor)
329 return retStat;
330
331 // Lock the device descriptor.
332 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
333
334 // Check the driver state if it has already been stopped.
335 if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
336 {
337 retStat = ISF_SUCCESS;
338 goto unlockdescriptor;
339 }
340
341 // Check that the adapter is not already started.
342 if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus) {
343 // If it is, then stop the Bus Manager (BM) sample timer.
344 isf_status_t bmStopStatus = bm_stop(pDeviceDescriptor->token);
345 if (BM_ERROR & bmStopStatus)
346 {
347 retStat = ISF_SUCCESS;
348 goto unlockdescriptor;
349 }
350 }
351
352 if ( pConfigSpecific->endDataCommands.numCommands > 0)
353 {
354 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->endDataCommands);
355 }
356 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
357 retStat = ISF_SUCCESS;
358
359
360 unlockdescriptor:
361 // Unlock the device descriptor.
362 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
363
364 return retStat;
365 }
366
367 /*
368 ** ===================================================================
369 ** Method : fsl_mma955x_Calibrate (component ISFDSA)
370 ** @brief
371 **
372 ** Parameters :
373 ** NAME - DESCRIPTION
374 ** @param
375 ** void* pSensorHandle -
376 ** @return
377 ** int32_t -
378 ** ===================================================================
379 */
380 isf_dsa_status_t fsl_mma955x_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData )
381 {
382 int32_t retStat = ISF_SUCCESS;
383
384 return retStat;
385 }
386
387 /*
388 ** ===================================================================
389 ** Method : fsl_mma955x_Shutdown (component ISFDSA)
390 ** @brief
391 **
392 ** Parameters :
393 ** NAME - DESCRIPTION
394 ** @param
395 ** void* pSensorHandle -
396 ** @return
397 ** int32_t -
398 ** ===================================================================
399 */
400 isf_dsa_status_t fsl_mma955x_Shutdown(isf_SensorHandle_t *pSensorHandle )
401 {
402 if(NULL == pSensorHandle){
403 return DSA_ERR_PARAM;
404 }
405
406 // Create helper reference pointers.
407 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
408 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
409
410 // Check the driver state if it has already been shutdown.
411 if (DSA_STATE_INITIALIZED == pSensorHandle->adapterStatus)
412 {
413 return ISF_SUCCESS;
414 }
415
416 if ( pConfigSpecific->shutdownCommands.numCommands > 0)
417 {
418 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->shutdownCommands);
419 }
420
421 // Remove the sensor adapter from the Bus Manager callbacks.
422 bm_unregister_callback(pDeviceDescriptor->token);
423 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
424 return ISF_SUCCESS;
425 }
426
427 /*
428 ** ===================================================================
429 ** Method : fsl_mma955x_PeriodicCallback (component ISFDSA)
430 ** @brief
431 **
432 ** Parameters :
433 ** NAME - DESCRIPTION
434 ** @param
435 ** void* pSensorHandle -
436 ** @return
437 ** void -
438 ** ===================================================================
439 */
440 void fsl_mma955x_PeriodicCallback(void *pSensorHandle)
441 {
442 // Check pointers.
443 if(NULL == pSensorHandle){
444 return;
445 }
446
447 int32_t status;
448 int32 numBytes;
449
450 // Create helper reference pointers.
451 volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
452 isf_fifo_t *pFifo = pSensorHdl->controlData.sensorSettings.pSampleBufferInfo;
453 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
454 isf_status_t st;
455
456 // Check the device descriptor
457 if (NULL == pDeviceDescriptor){
458 return;
459 }
460
461 // Create a helper pointer to the current sample buffer.
462 mma955x_DataBuffer_t *pCurrentSampleBuffer = pDeviceDescriptor->pCurrentSample;
463
464 // Lock the device descriptor.
465 if (kStatus_OSA_Success != OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
466 {
467 goto unlockdescriptor;
468 }
469
470
471 // Check the driver state.
472 if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
473 {
474 goto unlockdescriptor;
475 }
476
477 // Get the time stamp
478 pCurrentSampleBuffer->timeStamp = isf_time_util_get_usec();
479 // Get sensor data.
480 mma955x_GetData(&status, pSensorHandle, ((uint8*)&pCurrentSampleBuffer->accel));
481 if(pSensorHdl->controlData.sensorSettings.resultType == TYPE_NATIVE_SENSOR_DATA_TYPE)
482 mma955x_GetPedometerData(pSensorHandle, &pCurrentSampleBuffer->pedometerData);
483
484 // Lock the fifo for update.
485 if(kStatus_OSA_Success != isf_fifo_lock(pFifo)){
486 return;
487 }
488 void *pFifoEntry = isf_fifo_el_get_insert_pointer(pFifo);
489
490 // write the new data
491 if (pSensorHdl->controlData.sensorSettings.resultType == TYPE_NATIVE_SENSOR_DATA_TYPE )
492 {
493 ((mma955x_PedometerNativeData_t*)pFifoEntry)->timeStamp = pCurrentSampleBuffer->timeStamp;
494 ((mma955x_PedometerNativeData_t*)pFifoEntry)->pedometerData = pCurrentSampleBuffer->pedometerData;
495 }
496 else
497 {
498 fsl_mma955x_Convert(
499 pSensorHdl,
500 pSensorHdl->controlData.sensorSettings.resultType,
501 pSensorHdl->controlData.sensorSettings.resultFormat,
502 pCurrentSampleBuffer,
503 pFifoEntry,
504 &numBytes);
505 }
506
507 // Increment the fifo to the next sample entry.
508 st = isf_fifo_el_increment(pFifo);
509
510 // Unlock the fifo.
511 isf_fifo_unlock(pFifo);
512
513 if (st == ISF_FIFO_FULL)
514 {
515 // Notify the user using their registered event information
516 OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
517 }
518
519 unlockdescriptor:
520 // Unlock the device descriptor.
521 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
522
523 }
524
525 /*!
526 * @brief This function converts the raw sample data to the desired output type.
527 */
528 isf_dsa_status_t fsl_mma955x_Convert
529 (
530 volatile isf_SensorHandle_t *pSensorHandle,
531 isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
532 void *pNativeSample,
533 void *pConvertedSample,
534 int32 *numBytes
535 )
536 {
537 isf_dsa_status_t retStat = DSA_ERR_BAD_SENSOR_DATA_TYPE;
538 isf_dsa_status_t (*pConverter)(mma955x_Sensor_Specific_Settings_t *, mma955x_DataBuffer_t *, void *);
539
540 pConverter = NULL;
541
542 switch (convertToType)
543 {
544 case TYPE_RAW_ACCELERATION_3D:
545 if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
546 pConverter = float_mma955x_converter;
547 else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
548 pConverter = fixed_mma955x_converter;
549 break;
550
551 default:
552 return DSA_ERR_BAD_SENSOR_DATA_TYPE;
553 }
554 if (pConverter == NULL)
555 return DSA_ERR_BAD_RESULT_TYPE;
556
557 retStat = pConverter(
558 (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings,
559 (mma955x_DataBuffer_t *)pNativeSample,
560 pConvertedSample
561 );
562
563 return retStat;
564 }
565
566 static isf_dsa_status_t float_mma955x_converter(mma955x_Sensor_Specific_Settings_t *pSensorSpecificConfig, mma955x_DataBuffer_t *nativeSample, void *vpConvertedSample )
567 {
568 isf_Acceleration3D_Float_t *convertedSample = (isf_Acceleration3D_Float_t *)vpConvertedSample;
569 convertedSample->timestamp = nativeSample->timeStamp;
570 // These factors and offsets really depend on the configured sensor Range in pSensorSpecificConfig
571 convertedSample->accel[0] = nativeSample->accel[0] * pSensorSpecificConfig->engFloatConversionFactor;
572 convertedSample->accel[1] = nativeSample->accel[1] * pSensorSpecificConfig->engFloatConversionFactor;
573 convertedSample->accel[2] = nativeSample->accel[2] * pSensorSpecificConfig->engFloatConversionFactor;
574
575 return ISF_SUCCESS;
576 }
577
578 static isf_dsa_status_t fixed_mma955x_converter(mma955x_Sensor_Specific_Settings_t *pSensorSpecificConfig, mma955x_DataBuffer_t *nativeSample, void *vpConvertedSample )
579 {
580 isf_Acceleration3D_EngFixed_t *convertedSample = (isf_Acceleration3D_EngFixed_t *)vpConvertedSample;
581 isf_Acceleration3D_Float_t floatSample;
582 mma955x_Sensor_Specific_Settings_t *pSC = pSensorSpecificConfig; /* just a shorter name - shoud get optimized away */
583 isf_dsa_status_t st;
584
585 st = float_mma955x_converter(pSC, nativeSample, &floatSample);
586
587 convertedSample->timestamp = floatSample.timestamp;
588 // These factors and offsets really depend on the configured sensor Range in pSensorSpecificConfig
589 convertedSample->accel[0] = float32_To_AcFixed(floatSample.accel[0], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
590 convertedSample->accel[1] = float32_To_AcFixed(floatSample.accel[1], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
591 convertedSample->accel[2] = float32_To_AcFixed(floatSample.accel[2], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
592
593 return ISF_SUCCESS;
594 }
595
596 /*!
597 * @brief This function validates the configuration for the MAG3110 sensor.
598 */
599 void mma955x_ValidateConfig(int32_t *status, isf_SensorHandle_t* pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
600 {
601 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
602 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
603 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
604
605 if ( pConfigSpecific->validateSettingsCommands.numCommands > 0)
606 {
607 *status = mma955x_send(pDeviceHandle, &pConfigSpecific->validateSettingsCommands);
608 }
609 else
610 {
611 *status = ISF_SUCCESS;
612 }
613 }
614
615 /*!
616 * @brief This function retrieves the raw data from the MAG3110 sensor.
617 */
618 int32 mma955x_GetData(int32_t *status, isf_SensorHandle_t* pSensorHandle, void* pBuffer)
619 {
620 mma955x_status_t retStat = SENSOR_ERROR_GETDATA;
621 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
622 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
623 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
624
625 // Get fsl_mma955x data.
626 retStat = mma955x_read
627 (
628 pDeviceHandle,
629 pConfigSpecific->sampleDataOffset,
630 pConfigSpecific->sampleDataSize,
631 pBuffer
632 );
633
634 return retStat;
635 }
636
637 int32 mma955x_GetPedometerData(isf_SensorHandle_t* pSensorHandle, mma955x_PedometerData_t* pData)
638 {
639 mma955x_status_t retStat = SENSOR_ERROR_GETDATA;
640 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
641 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
642 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
643 readPedometerResponseBuffer_t buffer;
644
645 // Get Pedometer data.
646 if ( pConfigSpecific->getPedometerDataCommands.numCommands > 0)
647 {
648 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->getPedometerDataCommands);
649 }
650
651 retStat = mma955x_read
652 (
653 pDeviceHandle,
654 pConfigSpecific->commandReadOffset,
655 pConfigSpecific->commandReadSize,
656 (uint8*)&buffer
657 );
658
659 //Swap bytes for 2 byte fields.
660 buffer.pedometerData.pedometer_status_register = (buffer.pedometerData.pedometer_status_register>>8) | (buffer.pedometerData.pedometer_status_register<<8);
661 buffer.pedometerData.step_count = (buffer.pedometerData.step_count>>8) | (buffer.pedometerData.step_count<<8);
662 buffer.pedometerData.distance = (buffer.pedometerData.distance>>8) | (buffer.pedometerData.distance<<8);
663 buffer.pedometerData.speed = (buffer.pedometerData.speed>>8) | (buffer.pedometerData.speed<<8);
664 buffer.pedometerData.calories = (buffer.pedometerData.calories>>8) | (buffer.pedometerData.calories<<8);
665 buffer.pedometerData.sleep_count = (buffer.pedometerData.sleep_count>>8) | (buffer.pedometerData.sleep_count<<8);
666
667 *pData = buffer.pedometerData;
668
669 return retStat;
670 }
671
672 int32 mma955x_GetConfig(isf_SensorHandle_t* pSensorHandle, mma955x_appConfigRegister_t* pConfig)
673 {
674 mma955x_status_t retStat = SENSOR_ERROR_GETDATA;
675 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
676 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
677 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
678 mma955x_readConfigResponseBuffer_t buffer;
679
680 // Get fsl_mma955x data.
681 if ( pConfigSpecific->readConfigCommands.numCommands > 0)
682 {
683 mma955x_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->readConfigCommands);
684 }
685
686 retStat = mma955x_read
687 (
688 pDeviceHandle,
689 pConfigSpecific->commandReadOffset,
690 pConfigSpecific->commandReadSize,
691 (uint8*)&buffer
692 );
693
694 //Swap bytes for 2 byte fields.
695 buffer.configData.sleep_minimum = (buffer.configData.sleep_minimum>>8) | (buffer.configData.sleep_minimum<<8);
696 buffer.configData.sleep_maximum = (buffer.configData.sleep_maximum>>8) | (buffer.configData.sleep_maximum<<8);
697 buffer.configData.sleep_count_threshold = (buffer.configData.sleep_count_threshold>>8) | (buffer.configData.sleep_count_threshold<<8);
698 buffer.configData.activity_count_threshold = (buffer.configData.activity_count_threshold>>8) | (buffer.configData.activity_count_threshold<<8);
699
700 *pConfig = buffer.configData;
701
702 return retStat;
703 }
704
705 int32 mma955x_WriteConfig(isf_SensorHandle_t* pSensorHandle, mma955x_appConfigRegister_t* pConfig)
706 {
707 mma955x_status_t retStat = SENSOR_ERROR_GETDATA;
708 mma955x_DeviceDescriptor_t *pDeviceDescriptor = (mma955x_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
709 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
710 mma955x_Sensor_Specific_Settings_t *pConfigSpecific = (mma955x_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
711 uint8 buffer[32];
712 int i,j;
713
714 //Swap bytes for 2 byte fields.
715 pConfig->sleep_minimum = (pConfig->sleep_minimum>>8) | (pConfig->sleep_minimum<<8);
716 pConfig->sleep_maximum = (pConfig->sleep_maximum>>8) | (pConfig->sleep_maximum<<8);
717 pConfig->sleep_count_threshold = (pConfig->sleep_count_threshold>>8) | (pConfig->sleep_count_threshold<<8);
718 pConfig->activity_count_threshold = (pConfig->activity_count_threshold>>8) | (pConfig->activity_count_threshold<<8);
719
720 for(i=0; i<pConfigSpecific->writeConfigCommands.commands->nByteWrite; i++)
721 {
722 buffer[i] = pConfigSpecific->writeConfigCommands.commands->pWriteBuffer[i];
723 }
724
725 for(j=0; j<pConfigSpecific->commandReadSize; i++,j++)
726 {
727 buffer[i] = ((uint8*)pConfig)[j];
728 }
729
730 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
731 return -1;
732 }
733
734 retStat = dm_device_write
735 (
736 pDeviceHandle,
737 pConfigSpecific->writeConfigCommands.commands->offset,
738 buffer,
739 i,
740 i
741 );
742
743 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
744
745 return retStat;
746 }
747 int32 mma955x_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
748 {
749 int32_t retStat;
750
751 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
752 return -1;
753 }
754 retStat = dm_device_read(pDeviceHandle, offset, pBuffer, numBytes, numBytes);
755
756 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
757
758 return retStat;
759 }
760
761 int32 mma955x_send(dm_DeviceDescriptor_t* pDeviceHandle, const mma955x_CommandList_t *aCommandList)
762 {
763 int32_t retStat = 0;
764
765 // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
766 // or any number of undesirable things may occur.
767 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
768 return -1;
769 }
770
771 for (uint32 c=0; c < aCommandList->numCommands; c++)
772 {
773 retStat = dm_device_write
774 (
775 pDeviceHandle,
776 aCommandList->commands[c].offset,
777 aCommandList->commands[c].pWriteBuffer,
778 aCommandList->commands[c].nByteWrite,
779 aCommandList->commands[c].nByteWrite
780 );
781 if (retStat != ISF_SUCCESS)
782 {
783 return retStat;
784 }
785 retStat = mma955x_waitForCoCo(pDeviceHandle);
786 }
787
788 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
789 return retStat;
790 }
791
792 uint8 mma955x_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
793 {
794 uint8 cmdComplete = 0;
795 int32_t retStat;
796 uint8 buffer[2] = { 0x00, 0xFF };
797
798 // This call expects that the dm channel lock is already held
799
800 while (!cmdComplete)
801 {
802 retStat = dm_device_read(pDeviceHandle, 0, buffer, 2, 2);
803 if (retStat != ISF_SUCCESS)
804 {
805 return retStat;
806 }
807 cmdComplete = buffer[1] & 0x80;
808
809 if (!cmdComplete) OSA_TimeDelay(1);
810 }
811
812 return buffer[1] & 0x7F;
813 }
814
815 /*!
816 ** @}
817 */
818
819 /* END fsl_mma955x. */
820
isf_SensorHandle_st::pDeviceDescriptor
void * pDeviceDescriptor
Definition: isf_dsa_adapter.h:109
fsl_mma955x_EndData
isf_dsa_status_t fsl_mma955x_EndData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:313
dm_channel_start
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Definition: isf_device_messaging.c:137
mma955x_Sensor_Specific_Settings_t
Definition: mma955x.h:70
mma955x_GetPedometerData
int32 mma955x_GetPedometerData(isf_SensorHandle_t *pSensorHandle, mma955x_PedometerData_t *pData)
Definition: fsl_mma955x_i2cspi_pedo.c:637
SensorConfig_st::pSensorSpecificSettings
void * pSensorSpecificSettings
Definition: isf_dsa_adapter.h:157
uint8
unsigned char uint8
Definition: isf_types.h:76
fsl_mma955x_i2cspi_pedo.h
mma955x_PedometerData_t::sleep_count
uint16 sleep_count
Definition: mma955x.h:24
isf_dsa_adapter.h
DSA_ERR_BAD_RESULT_TYPE
Definition: isf_dsa_adapter.h:39
mma955x_appConfigRegister_t::sleep_count_threshold
uint16 sleep_count_threshold
Definition: mma955x.h:31
isf_Acceleration3D_EngFixed_t
Standard fixed type for three axis accelerometers.
Definition: isf_accelerometer_types.h:39
fsl_mma955x_Configure
isf_dsa_status_t fsl_mma955x_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
Definition: fsl_mma955x_i2cspi_pedo.c:180
isf_Acceleration3D_Float_t::timestamp
isf_timestamp_t timestamp
Definition: isf_accelerometer_types.h:81
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
mma955x_appConfigRegister_t::sleep_minimum
uint16 sleep_minimum
Definition: mma955x.h:29
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
fsl_mma955x_Calibrate
isf_dsa_status_t fsl_mma955x_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
Definition: fsl_mma955x_i2cspi_pedo.c:380
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
mma955x_CommandList_t::numCommands
uint32 numCommands
Definition: mma955x.h:66
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
mma955x_DeviceDescriptor_t::deviceSemaphore
LWSEM_STRUCT deviceSemaphore
Definition: fsl_mma955x_i2cspi_pedo.h:44
DSA_STATE_CONFIGURED_STARTED
Definition: isf_dsa_adapter.h:60
mma955x_Command_t::offset
int32 offset
Definition: mma955x.h:59
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
isf_sensors.h
isf_sensors.h contains the ISF Generic Sensor definitions and data structures required when a client ...
FALSE
#define FALSE
Definition: isf_types.h:86
isf_pedometer_types.h
dm_DeviceDescriptor_struct::pChannelDescriptor
dm_ChannelDescriptor_t * pChannelDescriptor
Definition: isf_devmsg.h:62
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
mma955x_PedometerData_t::step_count
uint16 step_count
Definition: mma955x.h:20
isf_SensorHandle_st
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
Definition: isf_dsa_adapter.h:107
mma955x_send
int32 mma955x_send(dm_DeviceDescriptor_t *pDeviceHandle, const mma955x_CommandList_t *aCommandList)
Definition: fsl_mma955x_i2cspi_pedo.c:761
isf_dsa_SensorSettings_st::nSamplePeriod
uint32 nSamplePeriod
Definition: isf_dsa_adapter.h:82
mma955x_Sensor_Specific_Settings_t::engFixedIntegerWidth
const uint8 engFixedIntegerWidth
Definition: mma955x.h:78
fsl_mma955x_Convert
isf_dsa_status_t fsl_mma955x_Convert(volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
This function converts the raw sample data to the desired output type.
Definition: fsl_mma955x_i2cspi_pedo.c:529
mma955x_GetData
int32 mma955x_GetData(int32_t *status, isf_SensorHandle_t *pSensorHandle, void *pBuffer)
This function retrieves the raw data from the MAG3110 sensor.
Definition: fsl_mma955x_i2cspi_pedo.c:618
mma955x_DeviceDescriptor_t::token
bm_callback_token_t token
Definition: fsl_mma955x_i2cspi_pedo.h:45
mma955x_CommandList_t
Definition: mma955x.h:64
mma955x_read
int32 mma955x_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
Definition: fsl_mma955x_i2cspi_pedo.c:747
mma955x_readConfigResponseBuffer_t
Definition: mma955x.h:51
fsl_mma955x_PeriodicCallback
void fsl_mma955x_PeriodicCallback(void *pSensorHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:440
isf_SensorTypes_t
isf_SensorTypes_t
Definition: isf_sensor_types.h:14
mma955x_PedometerData_t::distance
uint16 distance
Definition: mma955x.h:21
mma955xSetSamplingRate
void mma955xSetSamplingRate(uint32 index)
Definition: MMA955x_1.c:221
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
isf_dsa_ControlData_st::pEventGroup
event_t * pEventGroup
Definition: isf_dsa_adapter.h:92
mma955x_WriteConfig
int32 mma955x_WriteConfig(isf_SensorHandle_t *pSensorHandle, mma955x_appConfigRegister_t *pConfig)
Definition: fsl_mma955x_i2cspi_pedo.c:705
fsl_mma955x_Initialize
isf_dsa_status_t fsl_mma955x_Initialize(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:57
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
fsl_mma955x_ValidateSettings
isf_dsa_status_t fsl_mma955x_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
Definition: fsl_mma955x_i2cspi_pedo.c:148
isf_Acceleration3D_EngFixed_t::accel
isf_acceleration_g_fixed_32s1i16_t accel[3]
Definition: isf_accelerometer_types.h:41
DSA_ERR_END_DATA
Definition: isf_dsa_adapter.h:33
DSA_RESULT_TYPE_ENG_FIXED
Definition: isf_dsa_adapter.h:48
fsl_mma955x_Shutdown
isf_dsa_status_t fsl_mma955x_Shutdown(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:400
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
mma955x_DataBuffer_t::pedometerData
mma955x_PedometerData_t pedometerData
Definition: fsl_mma955x_i2cspi_pedo.h:32
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
mma955x_DataBuffer_t
This structure defines the Pedometer sample data buffer format.
Definition: fsl_mma955x_i2cspi_pedo.h:28
mma955x_Command_t::pWriteBuffer
uint8 *const pWriteBuffer
Definition: mma955x.h:61
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
mma955x_Command_t::nByteWrite
uint32 nByteWrite
Definition: mma955x.h:60
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
mma955x_PedometerData_t::pedometer_status_register
uint16 pedometer_status_register
Definition: mma955x.h:19
mma955x_appConfigRegister_t::sleep_maximum
uint16 sleep_maximum
Definition: mma955x.h:30
mma955x_DeviceDescriptor_t::localCfgBuffer
mma955x_appConfigRegister_t localCfgBuffer
Definition: fsl_mma955x_i2cspi_pedo.h:47
mma955x_status_t
int32 mma955x_status_t
Definition: mma955x.h:15
COMM_STATE_OK
Definition: isf_comm.h:28
mma955x_DeviceDescriptor_t::deviceHandle
dm_DeviceDescriptor_t deviceHandle
Definition: fsl_mma955x_i2cspi_pedo.h:43
isf_dsa_SensorSettings_st::resultFormat
isf_dsa_result_types_t resultFormat
Definition: isf_dsa_adapter.h:84
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
float32_To_AcFixed
uint32 float32_To_AcFixed(float fN, uint8 W, uint8 I, uint8 S, int32 *status)
This function converts an IEEE-754 32-bit floating point number into a fixed point integer format...
Definition: Ac_Fixed_utils.c:22
mma955x_Sensor_Specific_Settings_t::startDataCommands
const mma955x_CommandList_t startDataCommands
Definition: mma955x.h:85
mma955x_PedometerNativeData_t
This structure defines the Pedometer Native data buffer format.
Definition: fsl_mma955x_i2cspi_pedo.h:36
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
mma955x_waitForCoCo
uint8 mma955x_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:792
isf_fifo_t
Definition: isf_fifo.h:19
mma955x_readConfigResponseBuffer_t::configData
mma955x_appConfigRegister_t configData
Definition: mma955x.h:54
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
mma955x_PedometerData_t::calories
uint16 calories
Definition: mma955x.h:23
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.
mma955x_DataBuffer_t::timeStamp
uint32 timeStamp
Definition: fsl_mma955x_i2cspi_pedo.h:29
isf_sm_api.h
The isf_sm_api.h contains the collection of APIs for the Sensor Manager as well as related defines an...
mma955x_DataBuffer_t::accel
int16 accel[3]
Definition: fsl_mma955x_i2cspi_pedo.h:30
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
DSA_STATE_CONFIGURED_STOPPED
Definition: isf_dsa_adapter.h:59
DSA_ERR_PARAM
Definition: isf_dsa_adapter.h:36
mma955x_appConfigRegister_t::activity_count_threshold
uint16 activity_count_threshold
Definition: mma955x.h:40
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
mma955x_PedometerData_t::speed
uint16 speed
Definition: mma955x.h:22
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
mma955x_SupportedDataTypes
isf_SensorDataTypes_t mma955x_SupportedDataTypes[]
Definition: fsl_mma955x_i2cspi_pedo.c:29
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
isf_fifo.h
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
mma955x_CommandList_t::commands
const mma955x_Command_t * commands
Definition: mma955x.h:67
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
mma955x_appConfigRegister_t
Definition: mma955x.h:27
mma955x_GetConfig
int32 mma955x_GetConfig(isf_SensorHandle_t *pSensorHandle, mma955x_appConfigRegister_t *pConfig)
Definition: fsl_mma955x_i2cspi_pedo.c:672
mma955x.h
The mma955x.h contains the mma955x Intelligent Sensor register definitions, access macros...
mma955x_Sensor_Specific_Settings_t::engFixedSignBit
const uint8 engFixedSignBit
Definition: mma955x.h:79
fsl_mma955x_StartData
isf_dsa_status_t fsl_mma955x_StartData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_mma955x_i2cspi_pedo.c:252
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
mma955x_DeviceDescriptor_t::pCurrentSample
mma955x_DataBuffer_t * pCurrentSample
Definition: fsl_mma955x_i2cspi_pedo.h:46
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
DSA_ERR_START_DATA
Definition: isf_dsa_adapter.h:32
mma955x_SupportedSensorTypes
isf_SensorTypes_t mma955x_SupportedSensorTypes[]
Supported sensor and data types.
Definition: fsl_mma955x_i2cspi_pedo.c:28
uint32
unsigned long int uint32
Definition: isf_types.h:78
SENSOR_ERROR_GETDATA
Definition: isf_sensors.h:43
mma955x_Sensor_Specific_Settings_t::engFloatConversionFactor
const float engFloatConversionFactor
Definition: mma955x.h:76
readPedometerResponseBuffer_t::pedometerData
mma955x_PedometerData_t pedometerData
Definition: mma955x.h:48
dm_DeviceDescriptor_struct
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
mma955x_ValidateConfig
void mma955x_ValidateConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function validates the configuration for the MAG3110 sensor.
Definition: fsl_mma955x_i2cspi_pedo.c:599
TYPE_RAW_ACCELERATION_3D
Definition: isf_sensor_types.h:71
mma955x_DeviceDescriptor_t
Definition: fsl_mma955x_i2cspi_pedo.h:41
mma955x_Sensor_Specific_Settings_t::initializeCommands
const mma955x_CommandList_t initializeCommands
Definition: mma955x.h:83
mma955x_Sensor_Specific_Settings_t::engFixedTotalWidth
const uint8 engFixedTotalWidth
Definition: mma955x.h:77
TYPE_NATIVE_SENSOR_DATA_TYPE
Definition: isf_sensor_types.h:63
dm_ChannelDescriptor_struct
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
mma955x_DeviceDescriptor_t::cDescriptor
dm_ChannelDescriptor_t cDescriptor
Definition: fsl_mma955x_i2cspi_pedo.h:42
ISF_FIFO_FULL
#define ISF_FIFO_FULL
Definition: isf_fifo.h:33
readPedometerResponseBuffer_t
Definition: mma955x.h:45
DSA_ERR_CONFIGURE
Definition: isf_dsa_adapter.h:31
mma955x_PedometerData_t
Definition: mma955x.h:17
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.