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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

fsl_fxlc95000_i2cspi_pedo.c
Go to the documentation of this file.
1 /**
2 ** @file fsl_fxlc95000.c
3 ** @brief FXLC95000 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 "fxlc95000.h"
22 #include "fsl_fxlc95000_i2cspi_pedo.h"
23 #include "Ac_Fixed_utils.h"
24
25
26 /*! @brief Supported sensor and data types */
27 isf_SensorTypes_t fxlc95000_SupportedSensorTypes[] = { TYPE_ACCELEROMETER_3D, TYPE_NATIVE_SENSOR_TYPE };
28 isf_SensorDataTypes_t fxlc95000_SupportedDataTypes[] = { TYPE_RAW_ACCELERATION_3D, TYPE_NATIVE_SENSOR_DATA_TYPE };
29
30 /* Declare the local helper functions for FXLC95000 */
31 void fxlc95000_ValidateConfig(int32_t *status, isf_SensorHandle_t* pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings);
32 int32 fxlc95000_GetData(int32_t *status, isf_SensorHandle_t* pSensorHandle, void* pBuffer);
33 int32 fxlc95000_GetConfig(isf_SensorHandle_t* pSensorHandle, fxlc95000_appConfigRegister_t* pConfig);
34 int32 fxlc95000_WriteConfig(isf_SensorHandle_t* pSensorHandle, fxlc95000_appConfigRegister_t* pConfig);
35 int32 fxlc95000_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer);
36 int32 fxlc95000_send(dm_DeviceDescriptor_t* pDeviceHandle, const fxlc95000_CommandList_t *aCommandList);
37 uint8 fxlc95000_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle);
38
39 static isf_dsa_status_t float_fxlc95000_converter(fxlc95000_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxlc95000_DataBuffer_t *nativeSample, void *vpConvertedSample );
40 static isf_dsa_status_t fixed_fxlc95000_converter(fxlc95000_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxlc95000_DataBuffer_t *nativeSample, void *vpConvertedSample );
41
42
43 /*
44 ** ===================================================================
45 ** Method : fsl_fxlc95000_Initialize (component ISFDSA)
46 ** @brief
47 **
48 ** Parameters :
49 ** NAME - DESCRIPTION
50 ** @param
51 ** void* pSensorHandle -
52 ** @return
53 ** int32_t -
54 ** ===================================================================
55 */
56 isf_dsa_status_t fsl_fxlc95000_Initialize( isf_SensorHandle_t *pSensorHandle)
57 {
58 int32 st = ISF_SUCCESS;
59
60 if ( NULL == pSensorHandle){
61 return DSA_ERR_PARAM;
62 }
63
64
65 // Check if the sensor is available, and that it has already been initialized.
66 if (pSensorHandle->adapterStatus > DSA_STATE_NOT_INITIALIZED) {
67 return DSA_ERR_INITIALIZE;
68 }
69
70 // Allocate the adapter specific memory for the descriptor
71 pSensorHandle->pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t *)OSA_MemAllocZero(sizeof(fxlc95000_DeviceDescriptor_t));
72
73 // Create and validate helper reference pointers.
74 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
75
76 if (NULL == pDeviceDescriptor) {
77 return DSA_ERR_INITIALIZE;
78 }
79
80 // Allocate the current sample data buffer and initialize it.
81 pDeviceDescriptor->pCurrentSample = OSA_MemAllocZero(sizeof(fxlc95000_DataBuffer_t));
82
83 dm_ChannelDescriptor_t *pChannelDescriptor = &pDeviceDescriptor->cDescriptor;
84
85 // Initialize the channel
86 if(ISF_SUCCESS != dm_channel_init(pSensorHandle->pSensorStaticConfig->channelId, pChannelDescriptor)){
87 return DSA_ERR_INITIALIZE;
88 }
89 // Start the Bus
90 if(ISF_SUCCESS != dm_channel_start(pChannelDescriptor)){
91 return DSA_ERR_INITIALIZE;
92 }
93
94 // Get the Channel state to check if it is ready to use
95 if (COMM_STATE_OK != dm_channel_get_state(pChannelDescriptor)) {
96 return DSA_ERR_INITIALIZE;
97 }
98
99 // Open the device and get the device handler
100 if(ISF_SUCCESS != dm_device_open(pChannelDescriptor, (void *)pSensorHandle->pSensorStaticConfig->commInfo, &pDeviceDescriptor->deviceHandle)){
101 return DSA_ERR_INITIALIZE;
102 }
103
104 /* To enable Flash programming we skip initialization commands.
105 * Initialization will be done in Configure after flashing. */
106
107 // Set the adapter state to be initialized.
108 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
109
110 // Create a semaphore to synchronize the device descriptor across tasks
111 if (kStatus_OSA_Success != OSA_SemaCreate(&pDeviceDescriptor->deviceSemaphore, 1)){
112 return DSA_ERR_INITIALIZE;
113 }
114
115 return st;
116 }
117
118 /*
119 ** ===================================================================
120 ** Method : fsl_fxlc95000_ValidateSettings (component ISFDSA)
121 ** @brief
122 **
123 ** Parameters :
124 ** NAME - DESCRIPTION
125 ** @param
126 ** void* pSensorHandle -
127 ** @param
128 ** void* pSettings -
129 ** @return
130 ** int32_t -
131 ** ===================================================================
132 */
133 isf_dsa_status_t fsl_fxlc95000_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
134 {
135 // Check the input arguments.
136 if ((NULL == pSensorHandle) || (NULL == pSubSettings)) {
137 return DSA_ERR_PARAM;
138 }
139
140 int32_t status;
141
142 fxlc95000_ValidateConfig(&status,pSensorHandle,pSubSettings);
143
144 return status;
145 }
146
147 /*
148 ** ===================================================================
149 ** Method : fsl_fxlc95000_Configure (component ISFDSA)
150 ** @brief
151 **
152 ** Parameters :
153 ** NAME - DESCRIPTION
154 ** @param
155 ** void* pSensorHandle -
156 ** @param
157 ** void* pConfigSettings -
158 ** @return
159 ** int32_t -
160 ** ===================================================================
161 */
162 //#define DEBUG_READ_ALL_REGS
163 #ifdef DEBUG_READ_ALL_REGS
164 static uint8 debugRegs[18];
165 #endif
166 isf_dsa_status_t fsl_fxlc95000_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
167 {
168 // Check pointers.
169 if((NULL == pSensorHandle) || (NULL == pSensorSettings) ){
170 return DSA_ERR_PARAM;
171 }
172
173 int32_t retStat = DSA_ERR_CONFIGURE; // Return Status
174
175 // Create helper reference pointers.
176 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
177 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
178
179 // Check the device descriptor pointer.
180 if (NULL == pDeviceDescriptor)
181 {
182 return retStat;
183 }
184
185 // Lock the device descriptor.
186 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
187
188 // Check the driver state.
189 if (DSA_STATE_INITIALIZED > pSensorHandle->adapterStatus){
190 goto unlockdescriptor;
191 }
192
193 // A very short delay is needed for device startup.
194 OSA_TimeDelay(100);
195 if ( pConfigSpecific->initializeCommands.numCommands > 0)
196 {
197 if (ISF_SUCCESS != fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->initializeCommands))
198 { // At times when the system comes up slow, this command fails and we need to try once again.
199 OSA_TimeDelay(100);
200 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->initializeCommands);
201 }
202 }
203
204 /* Read and save the current configuration state for future use */
205 fxlc95000_GetConfig(pSensorHandle, &pDeviceDescriptor->localCfgBuffer);
206 pDeviceDescriptor->localCfgBuffer.settings.nCurrentReportRate = isf_swap4byte(pSensorSettings->nSamplePeriod);
207 pDeviceDescriptor->localCfgBuffer.settings.nCurrentResolution = pConfigSpecific->resolution;
208 pDeviceDescriptor->localCfgBuffer.settings.nRange = pConfigSpecific->range;
209 pDeviceDescriptor->localCfgBuffer.settings.nMode = pConfigSpecific->mode;
210 fxlc95000_WriteConfig(pSensorHandle, &pDeviceDescriptor->localCfgBuffer);
211 OSA_TimeDelay(1);
212
213 if ( pConfigSpecific->configureCommands.numCommands > 0)
214 {
215 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->configureCommands);
216 }
217
218 if (pDeviceDescriptor->token)
219 {
220 bm_unregister_callback(pDeviceDescriptor->token);
221 }
222 // Register the periodic callback function with the Bus Manager.
223 pDeviceDescriptor->token = bm_register_periodic_callback( pSensorSettings->nSamplePeriod, fsl_fxlc95000_PeriodicCallback , (void *)pSensorHandle);
224 if(BM_ERROR & pDeviceDescriptor->token)
225 {
226 goto unlockdescriptor;
227 }
228
229 //Store the configured settings
230 pSensorHandle->controlData.sensorSettings = *pSensorSettings;
231
232 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
233 retStat = ISF_SUCCESS;
234
235 unlockdescriptor:
236
237 // Unlock the device descriptor.
238 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
239
240 return retStat;
241 }
242
243 /*
244 ** ===================================================================
245 ** Method : fsl_fxlc95000_StartData (component ISFDSA)
246 ** @brief
247 **
248 ** Parameters :
249 ** NAME - DESCRIPTION
250 ** @param
251 ** void* pSensorHandle -
252 ** @return
253 ** int32_t -
254 ** ===================================================================
255 */
256 isf_dsa_status_t fsl_fxlc95000_StartData(isf_SensorHandle_t *pSensorHandle )
257 {
258 // Check pointers.
259 if(NULL == pSensorHandle){
260 return DSA_ERR_PARAM;
261 }
262
263 int32_t retStat = DSA_ERR_START_DATA;
264
265 // Create helper reference pointers.
266 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = pSensorHandle->pDeviceDescriptor;
267 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
268
269 // Check the device descriptor.
270 if (NULL == pDeviceDescriptor)
271 return DSA_ERR_PARAM;
272
273 // Lock the device descriptor.
274 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
275
276 // Check the driver state.
277 if (DSA_STATE_CONFIGURED_STOPPED > pSensorHandle->adapterStatus)
278 {
279 goto unlockdescriptor;
280 }
281
282 if ( pConfigSpecific->startDataCommands.numCommands > 0)
283 {
284 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->startDataCommands);
285 }
286
287 // Start the Bus Manager sampling timer.
288 if (BM_ERROR & bm_start(FALSE, pDeviceDescriptor->token)) // Check for Bus Manager error and return on failure.
289 goto unlockdescriptor;
290
291 // Set device to active state.
292 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STARTED;
293 retStat = ISF_SUCCESS;
294
295 unlockdescriptor:
296 // Unlock the device descriptor.
297 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
298
299 return retStat;
300 }
301
302 /*
303 ** ===================================================================
304 ** Method : fsl_fxlc95000_EndData (component ISFDSA)
305 ** @brief
306 **
307 ** Parameters :
308 ** NAME - DESCRIPTION
309 ** @param
310 ** void* pSensorHandle -
311 ** @return
312 ** int32_t -
313 ** ===================================================================
314 */
315 isf_dsa_status_t fsl_fxlc95000_EndData(isf_SensorHandle_t *pSensorHandle )
316 {
317 // Check pointers.
318 if(NULL == pSensorHandle){
319 return DSA_ERR_PARAM;
320 }
321
322 // Create helper reference pointers.
323 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
324 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
325
326 // Set the default return status.
327 int32_t retStat = DSA_ERR_END_DATA;
328
329 // Check the device descriptor.
330 if (NULL == pDeviceDescriptor)
331 return retStat;
332
333 // Lock the device descriptor.
334 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
335
336 // Check the driver state.
337 if (DSA_STATE_CONFIGURED_STOPPED >= pSensorHandle->adapterStatus)
338 goto unlockdescriptor;
339
340 // Check that the adapter is not already started.
341 if (DSA_STATE_CONFIGURED_STARTED == pSensorHandle->adapterStatus)
342 {
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 goto unlockdescriptor;
347 }
348
349 if ( pConfigSpecific->endDataCommands.numCommands > 0)
350 {
351 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->endDataCommands);
352 }
353 pSensorHandle->adapterStatus = DSA_STATE_CONFIGURED_STOPPED;
354 retStat = ISF_SUCCESS;
355
356 unlockdescriptor:
357 // Unlock the device descriptor.
358 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
359
360 return retStat;
361 }
362
363 /*
364 ** ===================================================================
365 ** Method : fsl_fxlc95000_Calibrate (component ISFDSA)
366 ** @brief
367 **
368 ** Parameters :
369 ** NAME - DESCRIPTION
370 ** @param
371 ** void* pSensorHandle -
372 ** @return
373 ** int32_t -
374 ** ===================================================================
375 */
376 isf_dsa_status_t fsl_fxlc95000_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData )
377 {
378 int32_t retStat = ISF_SUCCESS;
379
380 return retStat;
381 }
382
383 /*
384 ** ===================================================================
385 ** Method : fsl_fxlc95000_Shutdown (component ISFDSA)
386 ** @brief
387 **
388 ** Parameters :
389 ** NAME - DESCRIPTION
390 ** @param
391 ** void* pSensorHandle -
392 ** @return
393 ** int32_t -
394 ** ===================================================================
395 */
396 isf_dsa_status_t fsl_fxlc95000_Shutdown(isf_SensorHandle_t *pSensorHandle )
397 {
398 if(NULL == pSensorHandle){
399 return DSA_ERR_PARAM;
400 }
401
402 // Create helper reference pointers.
403 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
404 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
405
406 if ( pConfigSpecific->shutdownCommands.numCommands > 0)
407 {
408 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->shutdownCommands);
409 }
410
411 // Remove the sensor adapter from the Bus Manager callbacks.
412 bm_unregister_callback(pDeviceDescriptor->token);
413 pSensorHandle->adapterStatus = DSA_STATE_INITIALIZED;
414
415 return ISF_SUCCESS;
416 }
417
418 /*
419 ** ===================================================================
420 ** Method : fsl_fxlc95000_PeriodicCallback (component ISFDSA)
421 ** @brief
422 **
423 ** Parameters :
424 ** NAME - DESCRIPTION
425 ** @param
426 ** void* pSensorHandle -
427 ** @return
428 ** void -
429 ** ===================================================================
430 */
431 void fsl_fxlc95000_PeriodicCallback(void *pSensorHandle)
432 {
433 // Check pointers.
434 if(NULL == pSensorHandle)
435 {
436 return;
437 }
438
439 int32_t status;
440 int32 numBytes;
441
442 // Create helper reference pointers.
443 volatile isf_SensorHandle_t *pSensorHdl = (isf_SensorHandle_t *)pSensorHandle;
444 isf_fifo_t *pFifo = pSensorHdl->controlData.sensorSettings.pSampleBufferInfo;
445 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHdl->pDeviceDescriptor;
446 isf_status_t st;
447
448 // Check the device descriptor
449 if (NULL == pDeviceDescriptor)
450 {
451 return;
452 }
453
454 // Create a helper pointer to the current sample buffer.
455 fxlc95000_DataBuffer_t *pCurrentSampleBuffer = pDeviceDescriptor->pCurrentSample;
456
457 // Lock the device descriptor.
458 if (kStatus_OSA_Success != OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER))
459 {
460 goto unlockdescriptor;
461 }
462
463 // Check the driver state.
464 if (DSA_STATE_CONFIGURED_STARTED != pSensorHdl->adapterStatus)
465 {
466 goto unlockdescriptor;
467 }
468
469 // Get sensor data.
470 fxlc95000_GetData(&status, pSensorHandle, ((uint8*)&pCurrentSampleBuffer->timeStamp));
471
472 // Lock the fifo for update.
473 if(kStatus_OSA_Success != isf_fifo_lock(pFifo))
474 {
475 return;
476 }
477
478 fxlc95000_DataBuffer_t *pFifoEntry = (fxlc95000_DataBuffer_t *)isf_fifo_el_get_insert_pointer(pFifo);
479
480 // write the new data
481 if (pSensorHdl->controlData.sensorSettings.resultType == TYPE_NATIVE_SENSOR_DATA_TYPE )
482 {
483 *pFifoEntry = *pCurrentSampleBuffer;
484 }
485 else
486 {
487 fsl_fxlc95000_Convert(
488 pSensorHdl,
489 pSensorHdl->controlData.sensorSettings.resultType,
490 pSensorHdl->controlData.sensorSettings.resultFormat,
491 pCurrentSampleBuffer,
492 pFifoEntry,
493 &numBytes);
494 }
495
496 // Increment the fifo to the next sample entry.
497 st = isf_fifo_el_increment(pFifo);
498
499 // Unlock the fifo.
500 isf_fifo_unlock(pFifo);
501
502 if (st == ISF_FIFO_FULL)
503 {
504 // Notify the user using their registered event information
505 OSA_EventSet(pSensorHdl->controlData.pEventGroup,(uint32_t)pSensorHdl->controlData.nEventFieldIndex);
506 }
507
508 unlockdescriptor:
509 // Unlock the device descriptor.
510 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
511 }
512
513 /*
514 ** ===================================================================
515 ** Method : fsl_fxlc95000_Flash (component ISFDSA)
516 ** @brief
517 **
518 ** Parameters :
519 ** NAME - DESCRIPTION
520 ** @param
521 ** void* pSensorHandle -
522 ** @param
523 ** void* pFlashData -
524 ** @param
525 ** uint8 numBytes -
526 ** @return
527 ** int32_t -
528 ** ===================================================================
529 */
530 isf_dsa_status_t fsl_fxlc95000_Flash(isf_SensorHandle_t *pSensorHandle, void *pFlashData, uint8 numBytes)
531 {
532 // Check the input arguments.
533 if ((NULL == pSensorHandle) || (NULL == pFlashData))
534 {
535 return DSA_ERR_PARAM;
536 }
537
538 static bool flashingInProgress = FALSE;
539 int32_t status = ISF_SUCCESS;
540 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
541 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
542
543 // Lock the device descriptor.
544 OSA_SemaWait(&pDeviceDescriptor->deviceSemaphore, OSA_WAIT_FOREVER);
545
546 /* 1-Byte Flash Command are start and stop markers */
547 if(numBytes == 1 && flashingInProgress == FALSE && *((uint8*)pFlashData) == 0x00)
548 { /* Host has sent stating Flash Bytes.*/
549 flashingInProgress = TRUE;
550 status = fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->flashPreprocessCommands);
551 }
552 else if(numBytes == 1 && flashingInProgress == TRUE && *((uint8*)pFlashData) == 0xFF)
553 { /* Host has sent stop flashing bytes, re-initialize Sensor. */
554 flashingInProgress = FALSE;
555 status = fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->flashPostprocessCommands);
556 }
557 else if(numBytes >= 8 && flashingInProgress == TRUE)
558 { /* Prepare CI_WRITE ROM Command. */
559 /* Check if the write command being attempted spans across a page boundary. */
560 #define CI_READ_WRITE_MAX_LEN 32
561 #define CI_READ_WRITE_HDR_LEN 6
562 #define CI_READ_WRITE_ADDR_LEN 2
563 uint8 bytesToPageBoundary = 0xFF - *((uint8*)pFlashData+3) + 1;
564 uint8 bytesAfterPageBoundary = numBytes - bytesToPageBoundary - 4; /* Excluding 4-byte address. */
565
566 if(bytesToPageBoundary > 0 && bytesToPageBoundary < numBytes - 4)
567 {
568 /* Break it into 2 write commands. */
569 uint8 writeFlashCommand[CI_READ_WRITE_MAX_LEN] = { 0x0A, 0x00, 0x12, 0x34, 0x56, 0x78 };
570 uint8 writeFlashCommand_2[CI_READ_WRITE_MAX_LEN] = { 0x0A, 0x00, 0x12, 0x34, 0x56, 0x78 };
571
572 writeFlashCommand[1] = (*((uint8*)pFlashData+1) == 0)?0x1F&(bytesToPageBoundary):0xC0|(bytesToPageBoundary);
573 for(int i=0; i<bytesToPageBoundary+CI_READ_WRITE_ADDR_LEN;i++) // 2 LSB Bytes of Address + Data.
574 {
575 writeFlashCommand[CI_READ_WRITE_HDR_LEN+i] = ((uint8*)pFlashData)[CI_READ_WRITE_ADDR_LEN+i];
576 }
577
578 writeFlashCommand_2[1] = (*((uint8*)pFlashData+1) == 0)?0x1F&(bytesAfterPageBoundary):0xC0|(bytesAfterPageBoundary);
579 uint8 address[] = { *((uint8*)pFlashData+CI_READ_WRITE_ADDR_LEN+1), *((uint8*)pFlashData+CI_READ_WRITE_ADDR_LEN) };
580 *((uint16*)address) += bytesToPageBoundary;
581 writeFlashCommand_2[CI_READ_WRITE_HDR_LEN] = address[1];
582 writeFlashCommand_2[CI_READ_WRITE_HDR_LEN+1] = address[0];
583 for(int i=0; i<bytesAfterPageBoundary;i++)
584 {
585 writeFlashCommand_2[CI_READ_WRITE_HDR_LEN+CI_READ_WRITE_ADDR_LEN+i] = ((uint8*)pFlashData)[4+bytesToPageBoundary+i];
586 }
587
588 fxlc95000_Command_t writeFlashSequence[] =
589 {
590 {
591 .offset = 0,
592 .nByteWrite = CI_READ_WRITE_HDR_LEN + CI_READ_WRITE_ADDR_LEN + bytesToPageBoundary,
593 .pWriteBuffer = (uint8* const)writeFlashCommand
594 },
595 {
596 .offset = 0,
597 .nByteWrite = CI_READ_WRITE_HDR_LEN + CI_READ_WRITE_ADDR_LEN + bytesAfterPageBoundary,
598 .pWriteBuffer = (uint8* const)writeFlashCommand_2
599 }
600 };
601 fxlc95000_CommandList_t writeflashCommand =
602 {
603 .numCommands = sizeof(writeFlashSequence)/sizeof(fxlc95000_Command_t),
604 .commands = writeFlashSequence
605 };
606
607 /* Write Flash Bytes received from Host to Sensor. */
608 status = fxlc95000_send(&pDeviceDescriptor->deviceHandle, &writeflashCommand);
609 }
610 else
611 {
612 uint8 writeFlashCommand[CI_READ_WRITE_MAX_LEN] = { 0x0A, 0x00, 0x12, 0x34, 0x56, 0x78 };
613 writeFlashCommand[1] = (*((uint8*)pFlashData+1)== 0)?0x1F&(numBytes-4):0xC0|(numBytes-4); /* Excluding 4-byte address. */
614
615 for(int i=CI_READ_WRITE_ADDR_LEN; i<numBytes;i++) // Skip 2 MSBs of Address.
616 {
617 writeFlashCommand[CI_READ_WRITE_HDR_LEN+i-CI_READ_WRITE_ADDR_LEN] = ((uint8*)pFlashData)[i];
618 }
619
620 fxlc95000_Command_t writeFlashSequence[] =
621 {{
622 .offset = 0,
623 .nByteWrite = CI_READ_WRITE_HDR_LEN + numBytes - CI_READ_WRITE_ADDR_LEN,
624 .pWriteBuffer = (uint8* const)writeFlashCommand
625 }};
626 fxlc95000_CommandList_t writeflashCommand =
627 {
628 .numCommands = sizeof(writeFlashSequence)/sizeof(fxlc95000_Command_t),
629 .commands = writeFlashSequence
630 };
631
632 /* Write Flash Bytes received from Host to Sensor. */
633 status = fxlc95000_send(&pDeviceDescriptor->deviceHandle, &writeflashCommand);
634 }
635
636 }
637 else
638 { /* Adapter is not in a state to handle the command. Illegal flash sequence. */
639 status = DSA_ERR_BAD_RESULT_TYPE;
640 }
641
642 // Unlock the device descriptor.
643 OSA_SemaPost(&pDeviceDescriptor->deviceSemaphore);
644
645 return status;
646 }
647
648 /*!
649 * @brief This function converts the raw sample data to the desired output type.
650 */
651 isf_dsa_status_t fsl_fxlc95000_Convert
652 (
653 volatile isf_SensorHandle_t *pSensorHandle,
654 isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType,
655 void *pNativeSample,
656 void *pConvertedSample,
657 int32 *numBytes
658 )
659 {
660 isf_dsa_status_t retStat = DSA_ERR_BAD_SENSOR_DATA_TYPE;
661 isf_dsa_status_t (*pConverter)(fxlc95000_Sensor_Specific_Settings_t *, fxlc95000_DataBuffer_t *, void *);
662
663 pConverter = NULL;
664
665 switch (convertToType)
666 {
667 case TYPE_RAW_ACCELERATION_3D:
668 if (resultType == DSA_RESULT_TYPE_ENG_FLOAT)
669 pConverter = float_fxlc95000_converter;
670 else if (resultType == DSA_RESULT_TYPE_ENG_FIXED)
671 pConverter = fixed_fxlc95000_converter;
672 break;
673
674 default:
675 return DSA_ERR_BAD_SENSOR_DATA_TYPE;
676 }
677 if (pConverter == NULL)
678 return DSA_ERR_BAD_RESULT_TYPE;
679
680 retStat = pConverter(
681 (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings,
682 (fxlc95000_DataBuffer_t *)pNativeSample,
683 pConvertedSample
684 );
685
686 return retStat;
687 }
688
689 static isf_dsa_status_t float_fxlc95000_converter(fxlc95000_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxlc95000_DataBuffer_t *nativeSample, void *vpConvertedSample )
690 {
691 isf_Acceleration3D_Float_t *convertedSample = (isf_Acceleration3D_Float_t *)vpConvertedSample;
692 convertedSample->timestamp = nativeSample->timeStamp;
693 // These factors and offsets really depend on the configured sensor Range in pSensorSpecificConfig
694 convertedSample->accel[0] = nativeSample->accel[0] * pSensorSpecificConfig->engFloatConversionFactor;
695 convertedSample->accel[1] = nativeSample->accel[1] * pSensorSpecificConfig->engFloatConversionFactor;
696 convertedSample->accel[2] = nativeSample->accel[2] * pSensorSpecificConfig->engFloatConversionFactor;
697
698 return ISF_SUCCESS;
699 }
700
701 static isf_dsa_status_t fixed_fxlc95000_converter(fxlc95000_Sensor_Specific_Settings_t *pSensorSpecificConfig, fxlc95000_DataBuffer_t *nativeSample, void *vpConvertedSample )
702 {
703 isf_Acceleration3D_EngFixed_t *convertedSample = (isf_Acceleration3D_EngFixed_t *)vpConvertedSample;
704 isf_Acceleration3D_Float_t floatSample;
705 fxlc95000_Sensor_Specific_Settings_t *pSC = pSensorSpecificConfig; /* just a shorter name - shoud get optimized away */
706 isf_dsa_status_t st;
707
708 st = float_fxlc95000_converter(pSC, nativeSample, &floatSample);
709
710 convertedSample->timestamp = floatSample.timestamp;
711 // These factors and offsets really depend on the configured sensor Range in pSensorSpecificConfig
712 convertedSample->accel[0] = float32_To_AcFixed(floatSample.accel[0], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
713 convertedSample->accel[1] = float32_To_AcFixed(floatSample.accel[1], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
714 convertedSample->accel[2] = float32_To_AcFixed(floatSample.accel[2], pSC->engFixedTotalWidth, pSC->engFixedIntegerWidth, pSC->engFixedSignBit,&st);
715
716 return ISF_SUCCESS;
717 }
718
719 /*!
720 * @brief This function validates the configuration for the MAG3110 sensor.
721 */
722 void fxlc95000_ValidateConfig(int32_t *status, isf_SensorHandle_t* pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
723 {
724 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
725 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
726 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
727
728 if ( pConfigSpecific->validateSettingsCommands.numCommands > 0)
729 {
730 *status = fxlc95000_send(pDeviceHandle, &pConfigSpecific->validateSettingsCommands);
731 }
732 else
733 {
734 *status = ISF_SUCCESS;
735 }
736 }
737
738 /*!
739 * @brief This function retrieves the raw data from the MAG3110 sensor.
740 */
741 int32 fxlc95000_GetData(int32_t *status, isf_SensorHandle_t* pSensorHandle, void* pBuffer)
742 {
743 fxlc95000_status_t retStat = SENSOR_ERROR_GETDATA;
744 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
745 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
746 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
747
748 // Get fsl_fxlc95000 data.
749 retStat = fxlc95000_read
750 (
751 pDeviceHandle,
752 pConfigSpecific->sampleDataOffset,
753 pConfigSpecific->sampleDataSize,
754 pBuffer
755 );
756
757 return retStat;
758 }
759
760 int32 fxlc95000_GetConfig(isf_SensorHandle_t* pSensorHandle, fxlc95000_appConfigRegister_t* pConfig)
761 {
762 fxlc95000_status_t retStat = SENSOR_ERROR_GETDATA;
763 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
764 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
765 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
766
767 // Get fsl_fxlc95000 data.
768 if ( pConfigSpecific->readConfigCommands.numCommands > 0)
769 {
770 fxlc95000_send(&pDeviceDescriptor->deviceHandle, &pConfigSpecific->readConfigCommands);
771 }
772
773 retStat = fxlc95000_read
774 (
775 pDeviceHandle,
776 pConfigSpecific->configRegisterReadOffset,
777 pConfigSpecific->configRegisterReadSize,
778 (uint8*)pConfig
779 );
780
781 return retStat;
782 }
783 int32 fxlc95000_WriteConfig(isf_SensorHandle_t* pSensorHandle, fxlc95000_appConfigRegister_t* pConfig)
784 {
785 fxlc95000_status_t retStat = SENSOR_ERROR_GETDATA;
786 fxlc95000_DeviceDescriptor_t *pDeviceDescriptor = (fxlc95000_DeviceDescriptor_t*)pSensorHandle->pDeviceDescriptor;
787 dm_DeviceDescriptor_t *pDeviceHandle = &pDeviceDescriptor->deviceHandle;
788 fxlc95000_Sensor_Specific_Settings_t *pConfigSpecific = (fxlc95000_Sensor_Specific_Settings_t*)pSensorHandle->pSensorStaticConfig->pSensorSpecificSettings;
789 uint8 buffer[32];
790 int i,j;
791
792 for(i=0; i<pConfigSpecific->writeConfigRegisterPreamble.commands->nByteWrite; i++)
793 {
794 buffer[i] = pConfigSpecific->writeConfigRegisterPreamble.commands->pWriteBuffer[i];
795 }
796
797 for(j=0; j<pConfigSpecific->configRegisterReadSize; i++,j++)
798 {
799 buffer[i] = ((uint8*)pConfig)[j];
800 }
801
802 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
803 return -1;
804 }
805
806 retStat = dm_device_write
807 (
808 pDeviceHandle,
809 0,
810 buffer,
811 i,
812 i
813 );
814
815 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
816
817 return retStat;
818 }
819 int32 fxlc95000_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
820 {
821 int32_t retStat;
822
823 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
824 return -1;
825 }
826 retStat = dm_device_read(pDeviceHandle, offset, pBuffer, numBytes, numBytes);
827
828 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
829
830 return retStat;
831 }
832
833 int32 fxlc95000_send(dm_DeviceDescriptor_t* pDeviceHandle, const fxlc95000_CommandList_t *aCommandList)
834 {
835 int32_t retStat = 0;
836
837 // User Notice: This is a required function call. If it is not here, there may be conflicts, data loss,
838 // or any number of undesirable things may occur.
839 if (ISF_SUCCESS != dm_channel_acquire_lock(pDeviceHandle->pChannelDescriptor, 0)) {
840 return -1;
841 }
842
843 for (uint32 c=0; c < aCommandList->numCommands; c++)
844 {
845 retStat = dm_device_write
846 (
847 pDeviceHandle,
848 aCommandList->commands[c].offset,
849 aCommandList->commands[c].pWriteBuffer,
850 aCommandList->commands[c].nByteWrite,
851 aCommandList->commands[c].nByteWrite
852 );
853 if (retStat != ISF_SUCCESS)
854 {
855 return retStat;
856 }
857 retStat = fxlc95000_waitForCoCo(pDeviceHandle);
858 }
859
860 dm_channel_release_lock(pDeviceHandle->pChannelDescriptor);
861 return retStat;
862 }
863
864 uint8 fxlc95000_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
865 {
866 uint8 cmdComplete = 0;
867 int32_t retStat;
868 uint8 buffer[2] = { 0x00, 0xFF };
869
870 // This call expects that the dm channel lock is already held
871
872 while (!cmdComplete)
873 {
874 retStat = dm_device_read(pDeviceHandle, 0, buffer, 2, 2);
875 if (retStat != ISF_SUCCESS)
876 {
877 return retStat;
878 }
879 cmdComplete = buffer[1] & 0x80;
880
881 if (!cmdComplete) OSA_TimeDelay(1);
882 }
883
884 return buffer[1] & 0x7F;
885 }
886
887 /*!
888 ** @}
889 */
890
891 /* END fsl_fxlc95000. */
892
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
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
fsl_fxlc95000_Calibrate
isf_dsa_status_t fsl_fxlc95000_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
Definition: fsl_fxlc95000_i2cspi_pedo.c:376
isf_dsa_adapter.h
DSA_ERR_BAD_RESULT_TYPE
Definition: isf_dsa_adapter.h:39
fxlc95000_SensorSetting_t::nMode
uint8 nMode
sensor specific mode
Definition: fxlc95000.h:27
isf_Acceleration3D_EngFixed_t
Standard fixed type for three axis accelerometers.
Definition: isf_accelerometer_types.h:39
isf_Acceleration3D_Float_t::timestamp
isf_timestamp_t timestamp
Definition: isf_accelerometer_types.h:81
fxlc95000_Sensor_Specific_Settings_t::startDataCommands
const fxlc95000_CommandList_t startDataCommands
Definition: fxlc95000.h:81
ISF_SUCCESS
Definition: isf.h:31
fxlc95000_DataBuffer_t::accel
int16 accel[3]
Definition: fsl_fxlc95000_i2cspi_pedo.h:30
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
fxlc95000_Sensor_Specific_Settings_t::sampleDataOffset
const int32 sampleDataOffset
Definition: fxlc95000.h:65
fxlc95000_read
int32 fxlc95000_read(dm_DeviceDescriptor_t *pDeviceHandle, int32 offset, int32 numBytes, uint8 *pBuffer)
Definition: fsl_fxlc95000_i2cspi_pedo.c:819
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
fxlc95000_Sensor_Specific_Settings_t::configRegisterReadOffset
const int32 configRegisterReadOffset
Definition: fxlc95000.h:67
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 ...
fsl_fxlc95000_Flash
isf_dsa_status_t fsl_fxlc95000_Flash(isf_SensorHandle_t *pSensorHandle, void *pFlashData, uint8 numBytes)
Definition: fsl_fxlc95000_i2cspi_pedo.c:530
fxlc95000_SupportedDataTypes
isf_SensorDataTypes_t fxlc95000_SupportedDataTypes[]
Definition: fsl_fxlc95000_i2cspi_pedo.c:28
FALSE
#define FALSE
Definition: isf_types.h:86
fxlc95000_SensorSetting_t::nCurrentResolution
uint8 nCurrentResolution
Expected sensor resolution.
Definition: fxlc95000.h:25
isf_pedometer_types.h
dm_DeviceDescriptor_struct::pChannelDescriptor
dm_ChannelDescriptor_t * pChannelDescriptor
Definition: isf_devmsg.h:62
fxlc95000_Sensor_Specific_Settings_t::flashPostprocessCommands
const fxlc95000_CommandList_t flashPostprocessCommands
Definition: fxlc95000.h:87
isf_bm.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Bus Manager (BM)...
fxlc95000_Sensor_Specific_Settings_t
Definition: fxlc95000.h:63
isf_SensorHandle_st
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
Definition: isf_dsa_adapter.h:107
fxlc95000_Sensor_Specific_Settings_t::configRegisterReadSize
const int32 configRegisterReadSize
Definition: fxlc95000.h:68
fxlc95000_appConfigRegister_t::settings
fxlc95000_SensorSetting_t settings
Definition: fxlc95000.h:33
isf_dsa_SensorSettings_st::nSamplePeriod
uint32 nSamplePeriod
Definition: isf_dsa_adapter.h:82
fxlc95000_DeviceDescriptor_t::deviceHandle
dm_DeviceDescriptor_t deviceHandle
Definition: fsl_fxlc95000_i2cspi_pedo.h:37
fxlc95000_DataBuffer_t
This structure defines the dummy DSA data buffer format.
Definition: fsl_fxlc95000_i2cspi_pedo.h:28
fxlc95000_Sensor_Specific_Settings_t::flashPreprocessCommands
const fxlc95000_CommandList_t flashPreprocessCommands
Definition: fxlc95000.h:86
fsl_fxlc95000_Convert
isf_dsa_status_t fsl_fxlc95000_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_fxlc95000_i2cspi_pedo.c:652
fsl_fxlc95000_Configure
isf_dsa_status_t fsl_fxlc95000_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
Definition: fsl_fxlc95000_i2cspi_pedo.c:166
fsl_fxlc95000_EndData
isf_dsa_status_t fsl_fxlc95000_EndData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:315
isf_SensorTypes_t
isf_SensorTypes_t
Definition: isf_sensor_types.h:14
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
isf_types.h
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
fxlc95000_send
int32 fxlc95000_send(dm_DeviceDescriptor_t *pDeviceHandle, const fxlc95000_CommandList_t *aCommandList)
Definition: fsl_fxlc95000_i2cspi_pedo.c:833
DSA_ERR_INITIALIZE
Definition: isf_dsa_adapter.h:29
fxlc95000_Command_t
Definition: fxlc95000.h:50
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
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
fxlc95000_GetData
int32 fxlc95000_GetData(int32_t *status, isf_SensorHandle_t *pSensorHandle, void *pBuffer)
This function retrieves the raw data from the MAG3110 sensor.
Definition: fsl_fxlc95000_i2cspi_pedo.c:741
isf_Acceleration3D_Float_t::accel
isf_acceleration_g_float_t accel[3]
Definition: isf_accelerometer_types.h:82
fxlc95000_CommandList_t::commands
const fxlc95000_Command_t * commands
Definition: fxlc95000.h:60
fxlc95000_WriteConfig
int32 fxlc95000_WriteConfig(isf_SensorHandle_t *pSensorHandle, fxlc95000_appConfigRegister_t *pConfig)
Definition: fsl_fxlc95000_i2cspi_pedo.c:783
fxlc95000_SupportedSensorTypes
isf_SensorTypes_t fxlc95000_SupportedSensorTypes[]
Supported sensor and data types.
Definition: fsl_fxlc95000_i2cspi_pedo.c:27
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.
fxlc95000_GetConfig
int32 fxlc95000_GetConfig(isf_SensorHandle_t *pSensorHandle, fxlc95000_appConfigRegister_t *pConfig)
Definition: fsl_fxlc95000_i2cspi_pedo.c:760
isf_dsa_result_types_t
enum isf_dsa_result_enums isf_dsa_result_types_t
fxlc95000_Sensor_Specific_Settings_t::engFixedIntegerWidth
const uint8 engFixedIntegerWidth
Definition: fxlc95000.h:71
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
fxlc95000_status_t
int32 fxlc95000_status_t
Definition: fxlc95000.h:16
fxlc95000_CommandList_t
Definition: fxlc95000.h:57
fxlc95000_SensorSetting_t::nCurrentReportRate
uint32 nCurrentReportRate
Sample period in microseconds.
Definition: fxlc95000.h:24
fxlc95000.h
The fxlc95000.h contains the FXLC95000 Intelligent Sensor register definitions, access macros...
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
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
fxlc95000_DeviceDescriptor_t::token
bm_callback_token_t token
Definition: fsl_fxlc95000_i2cspi_pedo.h:39
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
fsl_fxlc95000_ValidateSettings
isf_dsa_status_t fsl_fxlc95000_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
Definition: fsl_fxlc95000_i2cspi_pedo.c:133
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_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
fxlc95000_appConfigRegister_t
Definition: fxlc95000.h:30
CI_READ_WRITE_HDR_LEN
#define CI_READ_WRITE_HDR_LEN
fxlc95000_Sensor_Specific_Settings_t::validateSettingsCommands
const fxlc95000_CommandList_t validateSettingsCommands
Definition: fxlc95000.h:78
fxlc95000_CommandList_t::numCommands
uint32 numCommands
Definition: fxlc95000.h:59
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
fsl_fxlc95000_StartData
isf_dsa_status_t fsl_fxlc95000_StartData(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:256
fxlc95000_DeviceDescriptor_t::pCurrentSample
fxlc95000_DataBuffer_t * pCurrentSample
Definition: fsl_fxlc95000_i2cspi_pedo.h:40
fsl_fxlc95000_Initialize
isf_dsa_status_t fsl_fxlc95000_Initialize(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:56
fxlc95000_DeviceDescriptor_t::deviceSemaphore
semaphore_t deviceSemaphore
Definition: fsl_fxlc95000_i2cspi_pedo.h:38
fsl_fxlc95000_Shutdown
isf_dsa_status_t fsl_fxlc95000_Shutdown(isf_SensorHandle_t *pSensorHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:396
CI_READ_WRITE_ADDR_LEN
#define CI_READ_WRITE_ADDR_LEN
isf_dsa_ControlData_st::nEventFieldIndex
uint32 nEventFieldIndex
Definition: isf_dsa_adapter.h:93
fxlc95000_DataBuffer_t::timeStamp
uint32 timeStamp
Definition: fsl_fxlc95000_i2cspi_pedo.h:29
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
fxlc95000_Sensor_Specific_Settings_t::engFixedTotalWidth
const uint8 engFixedTotalWidth
Definition: fxlc95000.h:70
fxlc95000_DeviceDescriptor_t::cDescriptor
dm_ChannelDescriptor_t cDescriptor
Definition: fsl_fxlc95000_i2cspi_pedo.h:36
fsl_fxlc95000_PeriodicCallback
void fsl_fxlc95000_PeriodicCallback(void *pSensorHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:431
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
fxlc95000_Sensor_Specific_Settings_t::engFloatConversionFactor
const float engFloatConversionFactor
Definition: fxlc95000.h:69
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
isf_swap4byte
uint32 isf_swap4byte(uint32 n)
4 byte swapping method
Definition: isf_util.c:143
fxlc95000_ValidateConfig
void fxlc95000_ValidateConfig(int32_t *status, isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSubSettings)
This function validates the configuration for the MAG3110 sensor.
Definition: fsl_fxlc95000_i2cspi_pedo.c:722
fxlc95000_Sensor_Specific_Settings_t::writeConfigRegisterPreamble
const fxlc95000_CommandList_t writeConfigRegisterPreamble
Definition: fxlc95000.h:76
fsl_fxlc95000_i2cspi_pedo.h
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
DSA_ERR_START_DATA
Definition: isf_dsa_adapter.h:32
fxlc95000_DeviceDescriptor_t
Definition: fsl_fxlc95000_i2cspi_pedo.h:35
uint32
unsigned long int uint32
Definition: isf_types.h:78
SENSOR_ERROR_GETDATA
Definition: isf_sensors.h:43
fxlc95000_Sensor_Specific_Settings_t::sampleDataSize
const int32 sampleDataSize
Definition: fxlc95000.h:66
fxlc95000_DeviceDescriptor_t::localCfgBuffer
fxlc95000_appConfigRegister_t localCfgBuffer
Definition: fsl_fxlc95000_i2cspi_pedo.h:41
dm_DeviceDescriptor_struct
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
fxlc95000_SensorSetting_t::nRange
uint8 nRange
Expected sensor dynamic range.
Definition: fxlc95000.h:26
TYPE_RAW_ACCELERATION_3D
Definition: isf_sensor_types.h:71
fxlc95000_Command_t::offset
int32 offset
Definition: fxlc95000.h:52
CI_READ_WRITE_MAX_LEN
#define CI_READ_WRITE_MAX_LEN
fxlc95000_Sensor_Specific_Settings_t::engFixedSignBit
const uint8 engFixedSignBit
Definition: fxlc95000.h:72
TYPE_NATIVE_SENSOR_DATA_TYPE
Definition: isf_sensor_types.h:63
fxlc95000_waitForCoCo
uint8 fxlc95000_waitForCoCo(dm_DeviceDescriptor_t *pDeviceHandle)
Definition: fsl_fxlc95000_i2cspi_pedo.c:864
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
fxlc95000_Sensor_Specific_Settings_t::readConfigCommands
const fxlc95000_CommandList_t readConfigCommands
Definition: fxlc95000.h:77
DSA_ERR_CONFIGURE
Definition: isf_dsa_adapter.h:31
fxlc95000_Command_t::pWriteBuffer
uint8 *const pWriteBuffer
Definition: fxlc95000.h:54
fxlc95000_Command_t::nByteWrite
uint32 nByteWrite
Definition: fxlc95000.h:53
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.