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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

BasicApp1.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** This component module is generated by Processor Expert. Do not modify it.
3 ** Filename : BasicApp1.c
4 ** CDE edition : Standard
5 ** Project : ISF2P2_K64F_MQX_PROJ
6 ** Processor : MK64FN1M0VLL12
7 ** Component : ISF_KSDK_BasicApp
8 ** Version : Component 02.500, Driver 02.00, CPU db: 3.00.000
9 ** Repository : My Components
10 ** Compiler : GNU C Compiler
11 ** Date/Time : 2016-10-06, 13:38, # CodeGen: 0
12 ** Abstract :
13 **
14 ** Settings :
15 ** Component Name : BasicApp1
16 ** Main Application Settings :
17 ** Processed Data Buffer Size : 34
18 ** Application Version Number : 0100
19 ** Additional User-Defined App Info :
20 ** Host Interface :
21 ** Host Command Interface Supported : yes
22 ** ISF_Core : ISFCore1
23 ** App Task Priority : 11
24 ** App Task Stack Size : 1200
25 ** Subscription List : 20
26 ** Sensor Subscription :
27 ** Sensor Type : Accelerometer
28 ** Selected Sensor : FXLC95000_1
29 ** Settings To Use : UseGiven
30 ** Sample Period : 10000
31 ** Sensor Data Format : Raw Sensor Format
32 ** Sensor Data Type : Native Sensor Output
33 ** FIFO Depth : 1
34 ** Sensor Subscription :
35 ** Sensor Type : Accelerometer
36 ** Selected Sensor : FXLC95000_2
37 ** Settings To Use : UseGiven
38 ** Sample Period : 10000
39 ** Sensor Data Format : Raw Sensor Format
40 ** Sensor Data Type : Native Sensor Output
41 ** FIFO Depth : 1
42 ** Sensor Subscription :
43 ** Sensor Type : Accelerometer
44 ** Selected Sensor : FXLS8471_1
45 ** Settings To Use : UseGiven
46 ** Sample Period : 10000
47 ** Sensor Data Format : Raw Sensor Format
48 ** Sensor Data Type : Native Sensor Output
49 ** FIFO Depth : 1
50 ** Sensor Subscription :
51 ** Sensor Type : Accelerometer
52 ** Selected Sensor : FXLS8471_2
53 ** Settings To Use : UseGiven
54 ** Sample Period : 10000
55 ** Sensor Data Format : Raw Sensor Format
56 ** Sensor Data Type : Native Sensor Output
57 ** FIFO Depth : 1
58 ** Sensor Subscription :
59 ** Sensor Type : Accelerometer
60 ** Selected Sensor : FXLS8952_1
61 ** Settings To Use : UseGiven
62 ** Sample Period : 10000
63 ** Sensor Data Format : Raw Sensor Format
64 ** Sensor Data Type : Native Sensor Output
65 ** FIFO Depth : 1
66 ** Sensor Subscription :
67 ** Sensor Type : Accelerometer
68 ** Selected Sensor : FXOS8700_1
69 ** Settings To Use : UseGiven
70 ** Sample Period : 10000
71 ** Sensor Data Format : Raw Sensor Format
72 ** Sensor Data Type : Native Sensor Output
73 ** FIFO Depth : 1
74 ** Sensor Subscription :
75 ** Sensor Type : Accelerometer
76 ** Selected Sensor : MMA8491Q_1
77 ** Settings To Use : UseGiven
78 ** Sample Period : 10000
79 ** Sensor Data Format : Raw Sensor Format
80 ** Sensor Data Type : Native Sensor Output
81 ** FIFO Depth : 1
82 ** Sensor Subscription :
83 ** Sensor Type : Accelerometer
84 ** Selected Sensor : MMA865x_1
85 ** Settings To Use : UseGiven
86 ** Sample Period : 10000
87 ** Sensor Data Format : Raw Sensor Format
88 ** Sensor Data Type : Native Sensor Output
89 ** FIFO Depth : 1
90 ** Sensor Subscription :
91 ** Sensor Type : Magnetometer
92 ** Selected Sensor : FXOS8700_2
93 ** Settings To Use : UseGiven
94 ** Sample Period : 10000
95 ** Sensor Data Format : Raw Sensor Format
96 ** Sensor Data Type : Native Sensor Output
97 ** FIFO Depth : 1
98 ** Sensor Subscription :
99 ** Sensor Type : Magnetometer
100 ** Selected Sensor : MAG3110_1
101 ** Settings To Use : UseGiven
102 ** Sample Period : 200000
103 ** Sensor Data Format : Raw Sensor Format
104 ** Sensor Data Type : Native Sensor Output
105 ** FIFO Depth : 1
106 ** Sensor Subscription :
107 ** Sensor Type : Gyrometer
108 ** Selected Sensor : FXAS21002_1
109 ** Settings To Use : UseGiven
110 ** Sample Period : 10000
111 ** Sensor Data Format : Raw Sensor Format
112 ** Sensor Data Type : Native Sensor Output
113 ** FIFO Depth : 1
114 ** Sensor Subscription :
115 ** Sensor Type : Gyrometer
116 ** Selected Sensor : FXAS21002_2
117 ** Settings To Use : UseGiven
118 ** Sample Period : 10000
119 ** Sensor Data Format : Raw Sensor Format
120 ** Sensor Data Type : Native Sensor Output
121 ** FIFO Depth : 1
122 ** Sensor Subscription :
123 ** Sensor Type : Pressure
124 ** Selected Sensor : MPL3115_1
125 ** Settings To Use : UseGiven
126 ** Sample Period : 10000
127 ** Sensor Data Format : Raw Sensor Format
128 ** Sensor Data Type : Native Sensor Output
129 ** FIFO Depth : 1
130 ** Sensor Subscription :
131 ** Sensor Type : Temperature
132 ** Selected Sensor : MPL3115_1
133 ** Settings To Use : UseGiven
134 ** Sample Period : 10000
135 ** Sensor Data Format : Raw Sensor Format
136 ** Sensor Data Type : Native Sensor Output
137 ** FIFO Depth : 1
138 ** Sensor Subscription :
139 ** Sensor Type : Orientation
140 ** Selected Sensor : ORIENT_1
141 ** Settings To Use : UseGiven
142 ** Sample Period : 10000
143 ** Sensor Data Format : Raw Sensor Format
144 ** Sensor Data Type : Native Sensor Output
145 ** FIFO Depth : 1
146 ** Sensor Subscription :
147 ** Sensor Type : Altitude
148 ** Selected Sensor : MPL3115_1
149 ** Settings To Use : UseGiven
150 ** Sample Period : 10000
151 ** Sensor Data Format : Raw Sensor Format
152 ** Sensor Data Type : Native Sensor Output
153 ** FIFO Depth : 1
154 ** Sensor Subscription :
155 ** Sensor Type : Pedometer
156 ** Selected Sensor : MMA955x_1
157 ** Settings To Use : UseGiven
158 ** Sample Period : 8192
159 ** Sensor Data Format : Raw Sensor Format
160 ** Sensor Data Type : Native Sensor Output
161 ** FIFO Depth : 1
162 ** Sensor Subscription :
163 ** Sensor Type : Pedometer
164 ** Selected Sensor : MMA955x_2
165 ** Settings To Use : UseGiven
166 ** Sample Period : 8192
167 ** Sensor Data Format : Raw Sensor Format
168 ** Sensor Data Type : Native Sensor Output
169 ** FIFO Depth : 1
170 ** Sensor Subscription :
171 ** Sensor Type : Custom
172 ** Selected Sensor : Custom_1
173 ** Settings To Use : UseGiven
174 ** Sample Period : 10000
175 ** Sensor Data Format : Raw Sensor Format
176 ** Sensor Data Type : Native Sensor Output
177 ** FIFO Depth : 1
178 ** Sensor Subscription :
179 ** Sensor Type : Analog
180 ** Selected Sensor : Analog_1
181 ** Settings To Use : UseGiven
182 ** Sample Period : 10000
183 ** Sensor Data Format : Raw Sensor Format
184 ** Sensor Data Type : Native Sensor Output
185 ** FIFO Depth : 1
186 ** Contents :
187 ** No public methods
188 **
189 ** (c) Copyright Freescale Semiconductor, Inc., 2015,
190 **
191 http://www.freescale.com
192 ** ###################################################################*/
193 /*!
194 ** @file BasicApp1.c
195 ** @version 02.00
196 ** @brief
197 **
198 */
199 /*!
200 ** @addtogroup BasicApp1_module BasicApp1 module documentation
201 ** @{
202 */
203
204 /* MODULE BasicApp1. */
205
206 #include "BasicApp1_Functions.h"
207 #include "BasicApp1.h"
208 #include "BasicApp1_types.h"
209 /* MQX includes */
210
211 /* ISF includes */
212 #include "isf_dsa_direct.h"
213 #include "isf_sensor_configuration.h"
214 #include "isf_sensor_configuration_extern.h"
215 #include "isf_ci_stream.h"
216 /* Task1 task name */
217 #define BasicApp1_TASK_NAME "BasicApp1_task"
218 /* Task1 task stack size */
219 #define BasicApp1_TASK_STACK_SIZE 1200
220 /* Task1 task priority value */
221 #define BasicApp1_TASK_PRIORITY 11
222 OSA_TASK_DEFINE(BasicApp1, BasicApp1_TASK_STACK_SIZE);
223
224 /* Generic sensor interfaces */
225 #include "isf_accelerometer_types.h"
226 #include "isf_accelerometer_types.h"
227 #include "isf_accelerometer_types.h"
228 #include "isf_accelerometer_types.h"
229 #include "isf_accelerometer_types.h"
230 #include "isf_accelerometer_types.h"
231 #include "isf_accelerometer_types.h"
232 #include "isf_accelerometer_types.h"
233 #include "isf_magnetometer_types.h"
234 #include "isf_magnetometer_types.h"
235 #include "isf_gyrometer_types.h"
236 #include "isf_gyrometer_types.h"
237 #include "isf_pressure_types.h"
238 #include "isf_temperature_types.h"
239 #include "isf_orientation_types.h"
240 #include "isf_altitude_types.h"
241 #include "isf_pedometer_types.h"
242 #include "isf_pedometer_types.h"
243 #include "fsl_Sensor_Custom_1_Functions.h"
244 #include "fsl_Sensor_Analog_1_Functions.h"
245
246 /* Variable to hold application status
247 * This can be read in the debugger if the application fails and exits */
248 volatile int gAppStatus;
249
250 /* Array to hold the sensor fifos */
251 isf_fifo_t gSensorFifos[NUM_SUBSCRIPTIONS];
252
253 /* Array to hold the sensor handles for subscribed sensors */
254 isf_SensorHandle_t gSensorHandles[NUM_SUBSCRIPTIONS];
255
256 /* Structure holding each sensor's output buffer */
257 BasicApp1SensorData_t gSensorData;
258
259 /* Declare the App's output and config buffers */
260 BasicApp1DataBuffers_t gBasicApp1DataBuffers;
261
262 /* Define the sensor subscription settings. */
263 isf_SubscriptionSettings_t gSubscriptionSettings[] =
264 {
265 {
266 .resultType = 0,
267 .resultFormat = 1,
268 .nSamplePeriod = 10000,
269 .nSettingsToUse = 2,
270 .nFifoDepth = 1,
271 },
272 {
273 .resultType = 0,
274 .resultFormat = 1,
275 .nSamplePeriod = 10000,
276 .nSettingsToUse = 2,
277 .nFifoDepth = 1,
278 },
279 {
280 .resultType = 0,
281 .resultFormat = 1,
282 .nSamplePeriod = 10000,
283 .nSettingsToUse = 2,
284 .nFifoDepth = 1,
285 },
286 {
287 .resultType = 0,
288 .resultFormat = 1,
289 .nSamplePeriod = 10000,
290 .nSettingsToUse = 2,
291 .nFifoDepth = 1,
292 },
293 {
294 .resultType = 0,
295 .resultFormat = 1,
296 .nSamplePeriod = 10000,
297 .nSettingsToUse = 2,
298 .nFifoDepth = 1,
299 },
300 {
301 .resultType = 0,
302 .resultFormat = 1,
303 .nSamplePeriod = 10000,
304 .nSettingsToUse = 2,
305 .nFifoDepth = 1,
306 },
307 {
308 .resultType = 0,
309 .resultFormat = 1,
310 .nSamplePeriod = 10000,
311 .nSettingsToUse = 2,
312 .nFifoDepth = 1,
313 },
314 {
315 .resultType = 0,
316 .resultFormat = 1,
317 .nSamplePeriod = 10000,
318 .nSettingsToUse = 2,
319 .nFifoDepth = 1,
320 },
321 {
322 .resultType = 0,
323 .resultFormat = 1,
324 .nSamplePeriod = 10000,
325 .nSettingsToUse = 2,
326 .nFifoDepth = 1,
327 },
328 {
329 .resultType = 0,
330 .resultFormat = 1,
331 .nSamplePeriod = 200000,
332 .nSettingsToUse = 2,
333 .nFifoDepth = 1,
334 },
335 {
336 .resultType = 0,
337 .resultFormat = 1,
338 .nSamplePeriod = 10000,
339 .nSettingsToUse = 2,
340 .nFifoDepth = 1,
341 },
342 {
343 .resultType = 0,
344 .resultFormat = 1,
345 .nSamplePeriod = 10000,
346 .nSettingsToUse = 2,
347 .nFifoDepth = 1,
348 },
349 {
350 .resultType = 0,
351 .resultFormat = 1,
352 .nSamplePeriod = 10000,
353 .nSettingsToUse = 2,
354 .nFifoDepth = 1,
355 },
356 {
357 .resultType = 0,
358 .resultFormat = 1,
359 .nSamplePeriod = 10000,
360 .nSettingsToUse = 2,
361 .nFifoDepth = 1,
362 },
363 {
364 .resultType = 0,
365 .resultFormat = 1,
366 .nSamplePeriod = 10000,
367 .nSettingsToUse = 2,
368 .nFifoDepth = 1,
369 },
370 {
371 .resultType = 0,
372 .resultFormat = 1,
373 .nSamplePeriod = 10000,
374 .nSettingsToUse = 2,
375 .nFifoDepth = 1,
376 },
377 {
378 .resultType = 0,
379 .resultFormat = 1,
380 .nSamplePeriod = 8192,
381 .nSettingsToUse = 2,
382 .nFifoDepth = 1,
383 },
384 {
385 .resultType = 0,
386 .resultFormat = 1,
387 .nSamplePeriod = 8192,
388 .nSettingsToUse = 2,
389 .nFifoDepth = 1,
390 },
391 {
392 .resultType = 0,
393 .resultFormat = 1,
394 .nSamplePeriod = 10000,
395 .nSettingsToUse = 2,
396 .nFifoDepth = 1,
397 },
398 {
399 .resultType = 0,
400 .resultFormat = 1,
401 .nSamplePeriod = 10000,
402 .nSettingsToUse = 2,
403 .nFifoDepth = 1,
404 },
405 };
406
407 /* Convenience array of pointers to subscription data in BasicApp1SensorData_t */
408 void *pSensorData[] =
409 {
410 (void *)&gSensorData.rawAccelerometerData_Sub0,
411 (void *)&gSensorData.rawAccelerometerData_Sub1,
412 (void *)&gSensorData.rawAccelerometerData_Sub2,
413 (void *)&gSensorData.rawAccelerometerData_Sub3,
414 (void *)&gSensorData.rawAccelerometerData_Sub4,
415 (void *)&gSensorData.rawAccelerometerData_Sub5,
416 (void *)&gSensorData.rawAccelerometerData_Sub6,
417 (void *)&gSensorData.rawAccelerometerData_Sub7,
418 (void *)&gSensorData.rawMagnetometerData_Sub8,
419 (void *)&gSensorData.rawMagnetometerData_Sub9,
420 (void *)&gSensorData.rawGyrometerData_Sub10,
421 (void *)&gSensorData.rawGyrometerData_Sub11,
422 (void *)&gSensorData.rawPressureData_Sub12,
423 (void *)&gSensorData.rawTemperatureData_Sub13,
424 (void *)&gSensorData.rawOrientationData_Sub14,
425 (void *)&gSensorData.rawAltitudeData_Sub15,
426 (void *)&gSensorData.rawPedometerData_Sub16,
427 (void *)&gSensorData.rawPedometerData_Sub17,
428 (void *)&gSensorData.rawCustomData_Sub18,
429 (void *)&gSensorData.rawAnalogData_Sub19,
430 };
431
432 SensorInfo_t gSensorInfo[] =
433 {
434 {
435 .sensorId = DSA_FXLC95000_1,
436 .dataReadyEventFlag = ((uint32)(1 << 0)),
437 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub0),
438 },
439 {
440 .sensorId = DSA_FXLC95000_2,
441 .dataReadyEventFlag = ((uint32)(1 << 1)),
442 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub1),
443 },
444 {
445 .sensorId = DSA_FXLS8471_1,
446 .dataReadyEventFlag = ((uint32)(1 << 2)),
447 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub2),
448 },
449 {
450 .sensorId = DSA_FXLS8471_2,
451 .dataReadyEventFlag = ((uint32)(1 << 3)),
452 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub3),
453 },
454 {
455 .sensorId = DSA_FXLS8952_1,
456 .dataReadyEventFlag = ((uint32)(1 << 4)),
457 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub4),
458 },
459 {
460 .sensorId = DSA_FXOS8700_1,
461 .dataReadyEventFlag = ((uint32)(1 << 5)),
462 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub5),
463 },
464 {
465 .sensorId = DSA_MMA8491Q_1,
466 .dataReadyEventFlag = ((uint32)(1 << 6)),
467 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub6),
468 },
469 {
470 .sensorId = DSA_MMA865x_1,
471 .dataReadyEventFlag = ((uint32)(1 << 7)),
472 .dataTypeSize = sizeof(gSensorData.rawAccelerometerData_Sub7),
473 },
474 {
475 .sensorId = DSA_FXOS8700_2,
476 .dataReadyEventFlag = ((uint32)(1 << 8)),
477 .dataTypeSize = sizeof(gSensorData.rawMagnetometerData_Sub8),
478 },
479 {
480 .sensorId = DSA_MAG3110_1,
481 .dataReadyEventFlag = ((uint32)(1 << 9)),
482 .dataTypeSize = sizeof(gSensorData.rawMagnetometerData_Sub9),
483 },
484 {
485 .sensorId = DSA_FXAS21002_1,
486 .dataReadyEventFlag = ((uint32)(1 << 10)),
487 .dataTypeSize = sizeof(gSensorData.rawGyrometerData_Sub10),
488 },
489 {
490 .sensorId = DSA_FXAS21002_2,
491 .dataReadyEventFlag = ((uint32)(1 << 11)),
492 .dataTypeSize = sizeof(gSensorData.rawGyrometerData_Sub11),
493 },
494 {
495 .sensorId = DSA_MPL3115_1,
496 .dataReadyEventFlag = ((uint32)(1 << 12)),
497 .dataTypeSize = sizeof(gSensorData.rawPressureData_Sub12),
498 },
499 {
500 .sensorId = DSA_MPL3115_1,
501 .dataReadyEventFlag = ((uint32)(1 << 13)),
502 .dataTypeSize = sizeof(gSensorData.rawTemperatureData_Sub13),
503 },
504 {
505 .sensorId = DSA_ORIENT_1,
506 .dataReadyEventFlag = ((uint32)(1 << 14)),
507 .dataTypeSize = sizeof(gSensorData.rawOrientationData_Sub14),
508 },
509 {
510 .sensorId = DSA_MPL3115_1,
511 .dataReadyEventFlag = ((uint32)(1 << 15)),
512 .dataTypeSize = sizeof(gSensorData.rawAltitudeData_Sub15),
513 },
514 {
515 .sensorId = DSA_MMA955x_1,
516 .dataReadyEventFlag = ((uint32)(1 << 16)),
517 .dataTypeSize = sizeof(gSensorData.rawPedometerData_Sub16),
518 },
519 {
520 .sensorId = DSA_MMA955x_2,
521 .dataReadyEventFlag = ((uint32)(1 << 17)),
522 .dataTypeSize = sizeof(gSensorData.rawPedometerData_Sub17),
523 },
524 {
525 .sensorId = DSA_Custom_1,
526 .dataReadyEventFlag = ((uint32)(1 << 18)),
527 .dataTypeSize = sizeof(gSensorData.rawCustomData_Sub18),
528 },
529 {
530 .sensorId = DSA_Analog_1,
531 .dataReadyEventFlag = ((uint32)(1 << 19)),
532 .dataTypeSize = sizeof(gSensorData.rawAnalogData_Sub19),
533 },
534 };
535
536 /*
537 ** ===================================================================
538 ** Method : BasicApp1_ci_app_callback
539 **
540 ** Description :
541 ** This function implements the BasicApp1 user application callback
542 ** for the Command Interpreter.
543 ** This function implements the predefined Command Interpreter command enumerations.
544 ** It will also include calling user-define commands if configured.
545 ** This method is internal. It is used by Processor Expert only.
546 ** Parameters :
547 ** NAME DESCRIPTION
548 ** pHostPacket Pointer to the host command.
549 ** pAppPacket Pointer to the response data.
550 ** Returns :
551 ** returns a value of type ci_response_t
552 ** ===================================================================
553 */
554 ci_response_t BasicApp1_ci_app_callback(
555 ci_host_cmd_packet_t *pHostPacket, ci_app_resp_packet_t *pAppPacket)
556 {
557 uint8 response = CI_ERROR_COMMAND;
558
559 BasicApp1_CI_Callback(pHostPacket, pAppPacket, &response);
560 return response;
561 }
562
563 /*
564 ** ===================================================================
565 ** Method : BasicApp1_MainTask()
566 **
567 ** Description :
568 ** The method functions as the main task for the Embedded Application.
569 ** The method initializes the Embedded Application global instance, calls the
570 ** user defined initialization, brings the selected subscriptions to a known state,
571 ** waits for raw sensor data as prescribed, calls the user defined data processing,
572 ** performs processed data output to the host interface. If the task should exit,
573 ** then it will call the user defined exit processing before the task is destroyed.
574 ** This method is internal. It is used by Processor Expert only.
575 ** Parameters : None.
576 ** Returns : None.
577 ** ===================================================================
578 */
579 void BasicApp1_MainTask(os_task_param_t task_init_data)
580 {
581 int i; /* sensor index */
582 int32 smstt;
583 event_t sensorLWEvent; /* Sensor lightweight event. */
584
585 // ISF initialization.
586 isf_lib_init(0);
587 // Wait for ISF Core initialization to complete
588 isf_system_sync();
589
590 // Initialize and clear the lwevent passed to the Sensor Manager as part
591 // of the subscription to the BasicApp1 Sensor Adapter.
592 OSA_EventCreate(&sensorLWEvent, kEventAutoClear);
593 OSA_EventClear(&sensorLWEvent, 0x00FFFFFF);
594 // Create the outputBufferLock used to prevent updates made while
595 // data is being read by the host.
596 OSA_SemaCreate(&gBasicApp1DataBuffers.outputDataLock, 1);
597
598 BasicApp1_Initialization();
599
600 // initialize the sensor fifos and configure the sensors
601 for (i=0, smstt=0; i< NUM_SUBSCRIPTIONS; i++)
602 {
603 isf_fifo_init(&(gSensorFifos[i]), pSensorData[i],
604 gSensorInfo[i].dataTypeSize, gSubscriptionSettings[i].nFifoDepth);
605
606 // Call the DSA direct interface to initialize the sensor.
607 smstt |= init_sensor(
608 gSensorInfo[i].sensorId,
609 &(gSensorHandles[i]),
610 &sensorLWEvent,
611 gSensorInfo[i].dataReadyEventFlag);
612
613 smstt |= configure_sensor(
614 &(gSensorHandles[i]),
615 &(gSubscriptionSettings[i]),
616 &(gSensorFifos[i]));
617 }
618 if (smstt != ISF_SUCCESS)
619 {
620 gAppStatus = 1;
621 return;
622 }
623
624 // start the sensors sampling
625 for (i=0, smstt=0; i< NUM_SUBSCRIPTIONS; i++)
626 {
627 smstt |= start_sensor(&(gSensorHandles[i]));
628 }
629 if (smstt != ISF_SUCCESS) {
630 gAppStatus = 2;
631 return;
632 }
633
634 // Main task loop (forever).
635 while (1)
636 {
637 // Get the signalled event.
638 uint32 signalledEvents = 0;
639
640 // Wait for sensor data.
641 OSA_EventWait
642 (&sensorLWEvent, ALL_SENSOR_DATA_READY_BasicApp1, FALSE, OSA_WAIT_FOREVER, &signalledEvents);
643 OSA_SemaWait(&gBasicApp1DataBuffers.outputDataLock, OSA_WAIT_FOREVER);
644
645 // Updated based on received event(s).
646 for (i=0, smstt=0; i< NUM_SUBSCRIPTIONS; i++)
647 {
648 if (signalledEvents & gSensorInfo[i].dataReadyEventFlag)
649 {
650 // Lock the fifo.
651 isf_fifo_lock(&(gSensorFifos[i]));
652 isf_ci_stream_update_data
653 (i+1,gSensorInfo[i].dataTypeSize, 0, pSensorData[i]); /* i+1 because stream IDs start at 1 */
654 isf_fifo_el_clear(&(gSensorFifos[i]));
655 isf_fifo_unlock(&(gSensorFifos[i]));
656
657 // Your code here executes whenever any data arrives
658 BasicApp1_OnAnySensor_Data_Ready
659 (i, signalledEvents, pSensorData, &gBasicApp1DataBuffers);
660 }
661 }
662 // Unlock the buffer when done updating
663 OSA_SemaPost(&gBasicApp1DataBuffers.outputDataLock);
664 } /* end while() */
665
666 // This code never really executes but is left here for reference to show the stop and shutdown calls
667 for (i=0; i<NUM_SUBSCRIPTIONS; i++)
668 {
669 stop_sensor(&(gSensorHandles[i]));
670 shutdown_sensor(&(gSensorHandles[i]));
671 }
672 }
673
674 /*
675 ** ===================================================================
676 ** Method : BasicApp1_init
677 **
678 ** Description : Start the task
679 ** Parameters : None.
680 ** Returns : None.
681 ** ===================================================================
682 */
683 void BasicApp1_init(void)
684 {
685 // Create the Application Task
686 OSA_TaskCreate(BasicApp1_MainTask, /* The task function entry */
687 (uint8_t *)BasicApp1_TASK_NAME, /* The name of this task */
688 BasicApp1_TASK_STACK_SIZE, /* The stack size in byte */
689 BasicApp1_stack, /* Pointer to the stack */
690 BasicApp1_TASK_PRIORITY, /* Initial priority of the task */
691 (task_param_t)(NULL), /* Pointer to be passed to the task when it is created */
692 false, /* This task will use not float register */
693 &BasicApp1_task_handler); /* Pointer to the task handler */
694 }
695
696 /*
697 ** ===================================================================
698 ** Method : BasicApp1_FlashSensor()
699 **
700 ** Description :
701 ** This function is used to FLASH supported sensors. This is done
702 ** with the assumption that the sensor is in the proper state where it can be flashed AND that error will
703 ** be returned to a higher level, so don't try to check errors further here.
704 ** Parameters :
705 ** numBytes : Number of Bytes of Flash Data.
706 ** pFlashData : pointer pointing to bytes of flash.
707 ** Returns :
708 ** Status : 0 on Success.
709 ** ===================================================================
710 */
711 int8 BasicApp1_FlashSensor(uint8 numBytes, uint8 *pFlashData)
712 {
713 uint8 sensorSubscription = pFlashData[0];
714 isf_SensorHandle_t *pSensorAdapterHandle;
715
716 if (sensorSubscription < gNumSupportedSensors)
717 {
718 pSensorAdapterHandle = &gSensorHandles[sensorSubscription];
719 }
720
721 if(pFlashData && pSensorAdapterHandle->pSensorStaticConfig->pAdapter->control.Flash)
722 return pSensorAdapterHandle->pSensorStaticConfig->pAdapter->control.Flash(pSensorAdapterHandle, pFlashData+1, numBytes-1);
723 else
724 return -1;
725 }
726
727 /* END BasicApp1. */
728 /*!
729 ** @}
730 */
731 /*
732 ** ###################################################################
733 **
734 ** This file was created by Processor Expert 10.5 [05.21]
735 ** for the Freescale Kinetis series of microcontrollers.
736 **
737 ** ###################################################################
738 */
739
BasicApp1DataBuffers_t::outputDataLock
semaphore_t outputDataLock
Definition: BasicApp1_types.h:399
uint8
unsigned char uint8
Definition: isf_types.h:76
isf_sensor_configuration_extern.h
The isf_sensor_configuration_extern.h contains external declarations referenced by the Sensor Manager...
OSA_TASK_DEFINE
OSA_TASK_DEFINE(BasicApp1, BasicApp1_TASK_STACK_SIZE)
ALL_SENSOR_DATA_READY_BasicApp1
#define ALL_SENSOR_DATA_READY_BasicApp1
Definition: BasicApp1_types.h:360
DSA_MMA8491Q_1
Definition: isf_sensor_configuration.h:35
gSensorData
BasicApp1SensorData_t gSensorData
Definition: BasicApp1.c:257
DSA_FXLC95000_2
Definition: isf_sensor_configuration.h:27
BasicApp1SensorData_t::rawMagnetometerData_Sub9
DATA_TYPE_SUB9 rawMagnetometerData_Sub9[DATA_FIFO_LEN_SUB9]
Definition: BasicApp1_types.h:383
stop_sensor
int32 stop_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
Definition: isf_dsa_direct.c:119
isf_magnetometer_types.h
The isf_magnetometer_types.h file contains the ISF data type definitions for use with the ISF generic...
ISF_SUCCESS
Definition: isf.h:31
fsl_Sensor_Analog_1_Functions.h
This is user's event module. Put your event handler code here.
DSA_MMA865x_1
Definition: isf_sensor_configuration.h:36
isf_ci_stream.h
ISF Command Interpreter (CI) stream protocol header file.
isf_system_sync
void isf_system_sync(void)
This function synchronizes the user tasks and the system initialization.
Definition: isf_init.c:50
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
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
SensorConfig_st::pAdapter
const isf_dsa_Adapter_t * pAdapter
Definition: isf_dsa_adapter.h:156
BasicApp1SensorData_t::rawAccelerometerData_Sub5
DATA_TYPE_SUB5 rawAccelerometerData_Sub5[DATA_FIFO_LEN_SUB5]
Definition: BasicApp1_types.h:379
BasicApp1_Initialization
void BasicApp1_Initialization()
Definition: BasicApp1_Functions.c:60
BasicApp1SensorData_t::rawAnalogData_Sub19
DATA_TYPE_SUB19 rawAnalogData_Sub19[DATA_FIFO_LEN_SUB19]
Definition: BasicApp1_types.h:393
DSA_MMA955x_2
Definition: isf_sensor_configuration.h:38
FALSE
#define FALSE
Definition: isf_types.h:86
BasicApp1_ci_app_callback
ci_response_t BasicApp1_ci_app_callback(ci_host_cmd_packet_t *pHostPacket, ci_app_resp_packet_t *pAppPacket)
Definition: BasicApp1.c:554
isf_pedometer_types.h
CI_ERROR_COMMAND
Definition: isf_ci.h:137
BasicApp1_MainTask
void BasicApp1_MainTask(os_task_param_t task_init_data)
Definition: BasicApp1.c:579
isf_SensorHandle_st
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
Definition: isf_dsa_adapter.h:107
isf_fifo_el_clear
isf_fifo_status_t isf_fifo_el_clear(isf_fifo_t *pFifo)
Routine to clear the fifo.
Definition: isf_fifo.c:217
BasicApp1.h
isf_dsa_Adapter_st::control
isf_dsa_ControlInterface_t control
Definition: isf_dsa_adapter.h:147
BasicApp1SensorData_t::rawAccelerometerData_Sub7
DATA_TYPE_SUB7 rawAccelerometerData_Sub7[DATA_FIFO_LEN_SUB7]
Definition: BasicApp1_types.h:381
DSA_ORIENT_1
Definition: isf_sensor_configuration.h:40
pSensorData
void * pSensorData[]
Definition: BasicApp1.c:408
isf_sensor_configuration.h
The isf_sensor_configuration.h contains the enumerated list of Digital Sensor Abstraction (DSA) senso...
isf_dsa_ControlInterface_st::Flash
isf_dsa_status_t(* Flash)(isf_SensorHandle_t *pSensorHandle, void *pFlashData, uint8 numBytes)
Definition: isf_dsa_adapter.h:135
SensorInfo_t::sensorId
uint8 sensorId
Definition: App1_types.h:194
DSA_FXOS8700_2
Definition: isf_sensor_configuration.h:32
SensorInfo_t
Definition: App1_types.h:192
BasicApp1DataBuffers_t
Definition: BasicApp1_types.h:397
BasicApp1SensorData_t::rawAccelerometerData_Sub0
DATA_TYPE_SUB0 rawAccelerometerData_Sub0[DATA_FIFO_LEN_SUB0]
Definition: BasicApp1_types.h:374
init_sensor
int32 init_sensor(uint8 nSensorID, isf_SensorHandle_t *pSensorAdapterHandle, event_t *pEventGroup, uint32 nEventFieldIndex)
This function initializes the sensor adapters in the absence of the Sensor Manager.
Definition: isf_dsa_direct.c:41
isf_dsa_direct.h
BasicApp1SensorData_t::rawPressureData_Sub12
DATA_TYPE_SUB12 rawPressureData_Sub12[DATA_FIFO_LEN_SUB12]
Definition: BasicApp1_types.h:386
DSA_FXLS8471_2
Definition: isf_sensor_configuration.h:29
BasicApp1SensorData_t::rawMagnetometerData_Sub8
DATA_TYPE_SUB8 rawMagnetometerData_Sub8[DATA_FIFO_LEN_SUB8]
Definition: BasicApp1_types.h:382
BasicApp1SensorData_t::rawTemperatureData_Sub13
DATA_TYPE_SUB13 rawTemperatureData_Sub13[DATA_FIFO_LEN_SUB13]
Definition: BasicApp1_types.h:387
BasicApp1SensorData_t
Definition: BasicApp1_types.h:372
BasicApp1SensorData_t::rawPedometerData_Sub16
DATA_TYPE_SUB16 rawPedometerData_Sub16[DATA_FIFO_LEN_SUB16]
Definition: BasicApp1_types.h:390
DSA_FXAS21002_1
Definition: isf_sensor_configuration.h:24
isf_pressure_types.h
The isf_pressure_types.h file contains the ISF data type definitions for use with the ISF generic pre...
BasicApp1_FlashSensor
int8 BasicApp1_FlashSensor(uint8 numBytes, uint8 *pFlashData)
Definition: BasicApp1.c:711
gSensorHandles
isf_SensorHandle_t gSensorHandles[NUM_SUBSCRIPTIONS]
Definition: BasicApp1.c:254
gSubscriptionSettings
isf_SubscriptionSettings_t gSubscriptionSettings[]
Definition: BasicApp1.c:263
BasicApp1SensorData_t::rawAccelerometerData_Sub6
DATA_TYPE_SUB6 rawAccelerometerData_Sub6[DATA_FIFO_LEN_SUB6]
Definition: BasicApp1_types.h:380
gNumSupportedSensors
uint8 gNumSupportedSensors
This is the external declaration of the current number of available sensors.
Definition: isf_sensor_configuration.c:64
BasicApp1SensorData_t::rawAccelerometerData_Sub2
DATA_TYPE_SUB2 rawAccelerometerData_Sub2[DATA_FIFO_LEN_SUB2]
Definition: BasicApp1_types.h:376
isf_gyrometer_types.h
The isf_gyrometer_types.h file contains the ISF data type definitions for use with the ISF generic gy...
gBasicApp1DataBuffers
BasicApp1DataBuffers_t gBasicApp1DataBuffers
Definition: BasicApp1.c:260
os_task_param_t
task_param_t os_task_param_t
Definition: mqx_ksdk.h:354
BasicApp1SensorData_t::rawAccelerometerData_Sub4
DATA_TYPE_SUB4 rawAccelerometerData_Sub4[DATA_FIFO_LEN_SUB4]
Definition: BasicApp1_types.h:378
BasicApp1_types.h
BasicApp1_CI_Callback
void BasicApp1_CI_Callback(void *p_HostPacket, void *p_AppPacket, uint8_t *response)
Definition: BasicApp1_Functions.c:94
configure_sensor
int32 configure_sensor(isf_SensorHandle_t *pSensorAdapterHandle, isf_SubscriptionSettings_t *pRequiredSettings, isf_fifo_t *pfifo)
Definition: isf_dsa_direct.c:88
isf_lib_init
isf_status_t isf_lib_init(void *pNull)
API to get ISF information.
Definition: isf_init.c:18
start_sensor
int32 start_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
Definition: isf_dsa_direct.c:112
BasicApp1SensorData_t::rawOrientationData_Sub14
DATA_TYPE_SUB14 rawOrientationData_Sub14[DATA_FIFO_LEN_SUB14]
Definition: BasicApp1_types.h:388
DSA_FXLS8471_1
Definition: isf_sensor_configuration.h:28
isf_fifo_init
isf_fifo_status_t isf_fifo_init(isf_fifo_t *pFifo, void *pData, uint16 sampleSize, uint16 bufferCapacity)
Initializes a new fifo structure with a provided buffer.
Definition: isf_fifo.c:24
DSA_FXAS21002_2
Definition: isf_sensor_configuration.h:25
DSA_FXOS8700_1
Definition: isf_sensor_configuration.h:31
gAppStatus
volatile int gAppStatus
Definition: BasicApp1.c:248
isf_altitude_types.h
The isf_altitude_types.h file contains the ISF data type definitions for use with the ISF generic alt...
isf_temperature_types.h
The isf_temperature_fixed_t.h file contains the ISF data type definitions for use with the ISF generi...
BasicApp1SensorData_t::rawAccelerometerData_Sub1
DATA_TYPE_SUB1 rawAccelerometerData_Sub1[DATA_FIFO_LEN_SUB1]
Definition: BasicApp1_types.h:375
isf_fifo_t
Definition: isf_fifo.h:19
isf_SensorHandle_st::pSensorStaticConfig
const isf_SensorConfig_t * pSensorStaticConfig
Definition: isf_dsa_adapter.h:110
NUM_SUBSCRIPTIONS
#define NUM_SUBSCRIPTIONS
Definition: BasicApp1_types.h:361
isf_SubscriptionSettings_t::resultType
isf_SensorDataTypes_t resultType
The desired data type of the subscription.
Definition: isf_dsa_direct_types.h:24
BasicApp1_TASK_NAME
#define BasicApp1_TASK_NAME
Definition: BasicApp1.c:217
int32
signed long int int32
Definition: isf_types.h:74
BasicApp1_init
void BasicApp1_init(void)
Definition: BasicApp1.c:683
DSA_Custom_1
Definition: isf_sensor_configuration.h:23
isf_orientation_types.h
BasicApp1_TASK_STACK_SIZE
#define BasicApp1_TASK_STACK_SIZE
Definition: BasicApp1.c:219
isf_SubscriptionSettings_t
Definition: isf_dsa_direct_types.h:22
DSA_FXLC95000_1
Definition: isf_sensor_configuration.h:26
BasicApp1SensorData_t::rawCustomData_Sub18
DATA_TYPE_SUB18 rawCustomData_Sub18[DATA_FIFO_LEN_SUB18]
Definition: BasicApp1_types.h:392
BasicApp1SensorData_t::rawAccelerometerData_Sub3
DATA_TYPE_SUB3 rawAccelerometerData_Sub3[DATA_FIFO_LEN_SUB3]
Definition: BasicApp1_types.h:377
ci_app_resp_packet_t
This structure enables an application to read from or write to the host.
Definition: isf_ci.h:221
BasicApp1_TASK_PRIORITY
#define BasicApp1_TASK_PRIORITY
Definition: BasicApp1.c:221
BasicApp1_Functions.h
This is user's event module. Put your event handler code here.
BasicApp1SensorData_t::rawPedometerData_Sub17
DATA_TYPE_SUB17 rawPedometerData_Sub17[DATA_FIFO_LEN_SUB17]
Definition: BasicApp1_types.h:391
ci_host_cmd_packet_t
This structure contains host command information.
Definition: isf_ci.h:197
BasicApp1SensorData_t::rawAltitudeData_Sub15
DATA_TYPE_SUB15 rawAltitudeData_Sub15[DATA_FIFO_LEN_SUB15]
Definition: BasicApp1_types.h:389
uint32
unsigned long int uint32
Definition: isf_types.h:78
fsl_Sensor_Custom_1_Functions.h
This is user's event module. Put your event handler code here.
BasicApp1SensorData_t::rawGyrometerData_Sub11
DATA_TYPE_SUB11 rawGyrometerData_Sub11[DATA_FIFO_LEN_SUB11]
Definition: BasicApp1_types.h:385
DSA_FXLS8952_1
Definition: isf_sensor_configuration.h:30
DSA_MMA955x_1
Definition: isf_sensor_configuration.h:37
shutdown_sensor
int32 shutdown_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
Definition: isf_dsa_direct.c:126
DSA_MAG3110_1
Definition: isf_sensor_configuration.h:34
DSA_Analog_1
Definition: isf_sensor_configuration.h:33
ci_response_enum
ci_response_enum
These are the CI errors provided to the host.
Definition: isf_ci.h:119
isf_accelerometer_types.h
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
isf_ci_stream_update_data
isf_status_t isf_ci_stream_update_data(uint8 aDataSetID, uint16 aLength, uint16 aOffset, uint8 *apSrc)
This API updates the data of a dataset.
Definition: ci_protocol_stream.c:449
gSensorInfo
SensorInfo_t gSensorInfo[]
Definition: BasicApp1.c:432
DSA_MPL3115_1
Definition: isf_sensor_configuration.h:39
BasicApp1_OnAnySensor_Data_Ready
void BasicApp1_OnAnySensor_Data_Ready(uint8_t sensorIdx, uint32_t signalledEvents, void **pAppSensorData, void *pAppDataBuffers)
Definition: BasicApp1_Functions.c:202
BasicApp1SensorData_t::rawGyrometerData_Sub10
DATA_TYPE_SUB10 rawGyrometerData_Sub10[DATA_FIFO_LEN_SUB10]
Definition: BasicApp1_types.h:384
gSensorFifos
isf_fifo_t gSensorFifos[NUM_SUBSCRIPTIONS]
Definition: BasicApp1.c:251
int8
signed char int8
Definition: isf_types.h:72
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.