ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
App1.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** This component module is generated by Processor Expert. Do not modify it.
3 ** Filename : App1.c
4 ** CDE edition : Standard
5 ** Project : ISF2P2_K64F_MQX_PROJ
6 ** Processor : MK64FN1M0VLL12
7 ** Component : ISF_KSDK_EmbApp
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 : App1
16 ** Main Application Settings :
17 ** App ID : 2
18 ** Sensor Signalling Method : AnySensor
19 ** Processed Data Buffer Size : 34
20 ** App Control Register :
21 ** Initial Power : Normal Power
22 ** Quick Read Output Enabled : no
23 ** Initial State : STOPPED_UNSUBSCRIBED
24 ** Application Version Number : 0100
25 ** Additional User-Defined App Info :
26 ** Host Interface :
27 ** Host Command Interface Supported : yes
28 ** User Defined Host Commands : 0
29 ** ISF_Core : ISFCore1
30 ** App Task Priority : 11
31 ** App Task Stack Size : 1200
32 ** Subscription List : 20
33 ** Sensor Subscription :
34 ** Sensor Type : Accelerometer
35 ** Selected Sensor : FXLC95000_1
36 ** Settings To Use : UseGiven
37 ** Sample Period : 10000
38 ** Sensor Data Format : Raw Sensor Format
39 ** Sensor Data Type : Native Sensor Output
40 ** FIFO Depth : 1
41 ** Sensor Subscription :
42 ** Sensor Type : Accelerometer
43 ** Selected Sensor : FXLC95000_2
44 ** Settings To Use : UseGiven
45 ** Sample Period : 10000
46 ** Sensor Data Format : Raw Sensor Format
47 ** Sensor Data Type : Native Sensor Output
48 ** FIFO Depth : 1
49 ** Sensor Subscription :
50 ** Sensor Type : Accelerometer
51 ** Selected Sensor : FXLS8471_1
52 ** Settings To Use : UseGiven
53 ** Sample Period : 10000
54 ** Sensor Data Format : Raw Sensor Format
55 ** Sensor Data Type : Native Sensor Output
56 ** FIFO Depth : 1
57 ** Sensor Subscription :
58 ** Sensor Type : Accelerometer
59 ** Selected Sensor : FXLS8471_2
60 ** Settings To Use : UseGiven
61 ** Sample Period : 10000
62 ** Sensor Data Format : Raw Sensor Format
63 ** Sensor Data Type : Native Sensor Output
64 ** FIFO Depth : 1
65 ** Sensor Subscription :
66 ** Sensor Type : Accelerometer
67 ** Selected Sensor : FXLS8952_1
68 ** Settings To Use : UseGiven
69 ** Sample Period : 10000
70 ** Sensor Data Format : Raw Sensor Format
71 ** Sensor Data Type : Native Sensor Output
72 ** FIFO Depth : 1
73 ** Sensor Subscription :
74 ** Sensor Type : Accelerometer
75 ** Selected Sensor : FXOS8700_1
76 ** Settings To Use : UseGiven
77 ** Sample Period : 10000
78 ** Sensor Data Format : Raw Sensor Format
79 ** Sensor Data Type : Native Sensor Output
80 ** FIFO Depth : 1
81 ** Sensor Subscription :
82 ** Sensor Type : Accelerometer
83 ** Selected Sensor : MMA8491Q_1
84 ** Settings To Use : UseGiven
85 ** Sample Period : 10000
86 ** Sensor Data Format : Raw Sensor Format
87 ** Sensor Data Type : Native Sensor Output
88 ** FIFO Depth : 1
89 ** Sensor Subscription :
90 ** Sensor Type : Accelerometer
91 ** Selected Sensor : MMA865x_1
92 ** Settings To Use : UseGiven
93 ** Sample Period : 10000
94 ** Sensor Data Format : Raw Sensor Format
95 ** Sensor Data Type : Native Sensor Output
96 ** FIFO Depth : 1
97 ** Sensor Subscription :
98 ** Sensor Type : Magnetometer
99 ** Selected Sensor : FXOS8700_2
100 ** Settings To Use : UseGiven
101 ** Sample Period : 10000
102 ** Sensor Data Format : Raw Sensor Format
103 ** Sensor Data Type : Native Sensor Output
104 ** FIFO Depth : 1
105 ** Sensor Subscription :
106 ** Sensor Type : Magnetometer
107 ** Selected Sensor : MAG3110_1
108 ** Settings To Use : UseGiven
109 ** Sample Period : 200000
110 ** Sensor Data Format : Raw Sensor Format
111 ** Sensor Data Type : Native Sensor Output
112 ** FIFO Depth : 1
113 ** Sensor Subscription :
114 ** Sensor Type : Gyrometer
115 ** Selected Sensor : FXAS21002_1
116 ** Settings To Use : UseGiven
117 ** Sample Period : 10000
118 ** Sensor Data Format : Raw Sensor Format
119 ** Sensor Data Type : Native Sensor Output
120 ** FIFO Depth : 1
121 ** Sensor Subscription :
122 ** Sensor Type : Gyrometer
123 ** Selected Sensor : FXAS21002_2
124 ** Settings To Use : UseGiven
125 ** Sample Period : 10000
126 ** Sensor Data Format : Raw Sensor Format
127 ** Sensor Data Type : Native Sensor Output
128 ** FIFO Depth : 1
129 ** Sensor Subscription :
130 ** Sensor Type : Pressure
131 ** Selected Sensor : MPL3115_1
132 ** Settings To Use : UseGiven
133 ** Sample Period : 10000
134 ** Sensor Data Format : Raw Sensor Format
135 ** Sensor Data Type : Native Sensor Output
136 ** FIFO Depth : 1
137 ** Sensor Subscription :
138 ** Sensor Type : Temperature
139 ** Selected Sensor : MPL3115_1
140 ** Settings To Use : UseGiven
141 ** Sample Period : 10000
142 ** Sensor Data Format : Raw Sensor Format
143 ** Sensor Data Type : Native Sensor Output
144 ** FIFO Depth : 1
145 ** Sensor Subscription :
146 ** Sensor Type : Orientation
147 ** Selected Sensor : ORIENT_1
148 ** Settings To Use : UseGiven
149 ** Sample Period : 10000
150 ** Sensor Data Format : Raw Sensor Format
151 ** Sensor Data Type : Native Sensor Output
152 ** FIFO Depth : 1
153 ** Sensor Subscription :
154 ** Sensor Type : Altitude
155 ** Selected Sensor : MPL3115_1
156 ** Settings To Use : UseGiven
157 ** Sample Period : 10000
158 ** Sensor Data Format : Raw Sensor Format
159 ** Sensor Data Type : Native Sensor Output
160 ** FIFO Depth : 1
161 ** Sensor Subscription :
162 ** Sensor Type : Pedometer
163 ** Selected Sensor : MMA955x_1
164 ** Settings To Use : UseGiven
165 ** Sample Period : 8192
166 ** Sensor Data Format : Raw Sensor Format
167 ** Sensor Data Type : Native Sensor Output
168 ** FIFO Depth : 1
169 ** Sensor Subscription :
170 ** Sensor Type : Pedometer
171 ** Selected Sensor : MMA955x_2
172 ** Settings To Use : UseGiven
173 ** Sample Period : 8192
174 ** Sensor Data Format : Raw Sensor Format
175 ** Sensor Data Type : Native Sensor Output
176 ** FIFO Depth : 1
177 ** Sensor Subscription :
178 ** Sensor Type : Custom
179 ** Selected Sensor : Custom_1
180 ** Settings To Use : UseGiven
181 ** Sample Period : 10000
182 ** Sensor Data Format : Raw Sensor Format
183 ** Sensor Data Type : Native Sensor Output
184 ** FIFO Depth : 1
185 ** Sensor Subscription :
186 ** Sensor Type : Analog
187 ** Selected Sensor : Analog_1
188 ** Settings To Use : UseGiven
189 ** Sample Period : 10000
190 ** Sensor Data Format : Raw Sensor Format
191 ** Sensor Data Type : Native Sensor Output
192 ** FIFO Depth : 1
193 ** Contents :
194 ** No public methods
195 **
196 ** (c) Copyright Freescale Semiconductor, Inc., 2015,
197 **
198 http://www.freescale.com
199 ** ###################################################################*/
200 /*!
201 ** @file App1.c
202 ** @version 02.00
203 ** @brief
204 **
205 */
206 /*!
207 ** @addtogroup App1_module App1 module documentation
208 ** @{
209 */
210 
211 /* MODULE App1. */
212 
213 #include "App1_Functions.h"
214 #include "App1.h"
215 #include "App1_types.h"
216 
217 /* MQX includes */
218 
219 /* ISF includes */
220 #include "isf_target.h"
221 #include "isf_types.h"
222 #include "isf.h"
223 #include "isf_init.h"
224 #include "isf_ci.h"
225 #include "isf_ci_stream.h"
226 #include "isf_sm_types.h"
227 #include "fsl_os_abstraction.h"
228 #include "isf_util.h"
229 #include "isf_dsa_direct.h"
230 #include "isf_pm.h"
231 #include "Events.h"
234 
235 /* Task1 task name */
236 #define App1_TASK_NAME "App1_task"
237 /* Task1 task stack size */
238 #define App1_TASK_STACK_SIZE 1200
239 /* Task1 task priority value */
240 #define App1_TASK_PRIORITY 11
242 
243 /* App Info Structure returned by the CI_CMD_READ_APP_VERSION command */
244 static const App1_app_info_t gsApp1_AppInfo = {
245  .appType = ISF_EMB_APP,
246  .version_info = 0x0100,
247  .numBytes = sizeof(App1_APP_DATA),
248  .appData = App1_APP_DATA
249 };
250 
251 /* Generic sensor interfaces */
252 #include "isf_accelerometer_types.h"
253 #include "isf_accelerometer_types.h"
254 #include "isf_accelerometer_types.h"
255 #include "isf_accelerometer_types.h"
256 #include "isf_accelerometer_types.h"
257 #include "isf_accelerometer_types.h"
258 #include "isf_accelerometer_types.h"
259 #include "isf_accelerometer_types.h"
260 #include "isf_magnetometer_types.h"
261 #include "isf_magnetometer_types.h"
262 #include "isf_gyrometer_types.h"
263 #include "isf_gyrometer_types.h"
264 #include "isf_pressure_types.h"
265 #include "isf_temperature_types.h"
266 #include "isf_orientation_types.h"
267 #include "isf_altitude_types.h"
268 #include "isf_pedometer_types.h"
269 #include "isf_pedometer_types.h"
272 
273 /* Structure offset calculation macros */
274 #define startof(type,member) ((int32)&((type *)0)->member)
275 
276 /*! @brief Macro thats holds number of active sensors. */
277 #define NUM_SENSORS (sizeof(App1AppInstance.info)/sizeof(SensorInfo_t))
278 
279 /*! @brief Macro that extracts one of the fields below. */
280 #define SET_FIELD(name,val) (((val)<<name##_SHIFT)&(name##_MASK))
281 #define GET_FIELD(name,val) ((val&name##_MASK)>>name##_SHIFT)
282 
283 /*! @brief Control register mask/shift definitions for the application. */
284 #define CTRL_STATE_MASK 0x0F
285 #define CTRL_STATE_SHIFT 0
286 #define CTRL_QREN_MASK 0x10
287 #define CTRL_QREN_SHIFT 4
288 #define CTRL_RESET_MASK 0x20
289 #define CTRL_RESET_SHIFT 5
290 #define CTRL_POWER_MASK 0xC0
291 #define CTRL_POWER_SHIFT 6
292 
293 /******************************************************
294  * Global Variables
295  *****************************************************/
296 
297 /* Generate the initial default configuration statically for now.
298  Eventually this data should partially come from the actual sensor
299  components */
301  .instance.appId = 2,
302  .settings.control = SET_FIELD(CTRL_STATE,App1_STATE_STOPPED_UNSUBSCRIBED) | SET_FIELD(CTRL_POWER,1) | SET_FIELD(CTRL_QREN,0),
303  .info.AccelerometerInfo_Sub0.sensorId = DSA_FXLC95000_1,
304  .info.AccelerometerInfo_Sub1.sensorId = DSA_FXLC95000_2,
305  .info.AccelerometerInfo_Sub2.sensorId = DSA_FXLS8471_1,
306  .info.AccelerometerInfo_Sub3.sensorId = DSA_FXLS8471_2,
307  .info.AccelerometerInfo_Sub4.sensorId = DSA_FXLS8952_1,
308  .info.AccelerometerInfo_Sub5.sensorId = DSA_FXOS8700_1,
309  .info.AccelerometerInfo_Sub6.sensorId = DSA_MMA8491Q_1,
310  .info.AccelerometerInfo_Sub7.sensorId = DSA_MMA865x_1,
311  .info.MagnetometerInfo_Sub8.sensorId = DSA_FXOS8700_2,
312  .info.MagnetometerInfo_Sub9.sensorId = DSA_MAG3110_1,
313  .info.GyrometerInfo_Sub10.sensorId = DSA_FXAS21002_1,
314  .info.GyrometerInfo_Sub11.sensorId = DSA_FXAS21002_2,
315  .info.PressureInfo_Sub12.sensorId = DSA_MPL3115_1,
316  .info.TemperatureInfo_Sub13.sensorId = DSA_MPL3115_1,
317  .info.OrientationInfo_Sub14.sensorId = DSA_ORIENT_1,
318  .info.AltitudeInfo_Sub15.sensorId = DSA_MPL3115_1,
319  .info.PedometerInfo_Sub16.sensorId = DSA_MMA955x_1,
320  .info.PedometerInfo_Sub17.sensorId = DSA_MMA955x_2,
321  .info.CustomInfo_Sub18.sensorId = DSA_Custom_1,
322  .info.AnalogInfo_Sub19.sensorId = DSA_Analog_1,
323 };
324 
325 /*!
326  * @struct subscriptionConfig_t
327  * @brief This structure holds the sensor subscriptions configuration info.
328  *
329 */
330 typedef struct {
336 
337 /* Attempts to match the App1AppSettings_t array layout in order to compute the Subscription settings offset only*/
338 /* Not actually used to hold any real information */
339 typedef struct {
343 
344 /*!
345  * @struct appSubscriptionResponse_t
346  * @brief This structure holds the ISF application subscriptions information
347  * in the "GET_APP_SUBSCRIPTION" CI command response buffer.
348  *
349 */
350 #pragma pack(push,1)
351 typedef struct {
356 #pragma pack(pop)
357 
358 
359 /******************************************************
360  * Function Prototypes
361  *****************************************************/
362 int32 App1_GotoState(uint8 desiredState);
363 static int8 App1_FlashSensor(uint8 numBytes, uint8 *pFlashData);
364 static int32 SettingsCompare(const isf_SubscriptionSettings_t *s1, const isf_SubscriptionSettings_t *s2);
365 static int32 SmSettingsCompare(const App1AppSettings_t *s1, const App1AppSettings_t *s2);
366 
367 
368 /*
369 ** ===================================================================
370 ** Method : App1_Task()
371 **
372 ** Description :
373 ** inititialize the app task
374 ** Parameters : None.
375 ** Returns : None.
376 ** ===================================================================
377 */
378 void App1_task(os_task_param_t task_init_data)
379 {
380  // Waiting for the system synchronisation.
381  // ISF initialization.
382  isf_lib_init(0);
383  isf_system_sync();
384  App1_MainTask();
385 }
386 
387 /*
388 ** ===================================================================
389 ** Method : d App1_init
390 **
391 ** Description :
392 ** start the task
393 ** Parameters : None.
394 ** Returns : None.
395 ** ===================================================================
396 */
397 void App1_init(void)
398 {
399  // Create the Application Task
400  OSA_TaskCreate(App1_task, /* The task function entry */
401  (uint8_t *)App1_TASK_NAME, /* The name of this task */
402  App1_TASK_STACK_SIZE, /* The stack size in byte */
403  App1_stack, /* Pointer to the stack */
404  App1_TASK_PRIORITY, /* Initial priority of the task */
405  (task_param_t)(NULL), /* Pointer to be passed to the task when it is created */
406  false, /* This task will use not float register */
407  &App1_task_handler); /* Pointer to the task handler */
408 }
409 
410 /*
411 ** ===================================================================
412 ** Method : App1_MainTask()
413 **
414 ** Description :
415 ** The method functions as the main task for the Embedded Application.
416 ** The method initializes the Embedded Application global instance, calls the
417 ** user defined initialization, brings the selected subscriptions to a known state,
418 ** waits for raw sensor data as prescribed, calls the user defined data processing,
419 ** performs processed data output to the host interface. If the task should exit,
420 ** then it will call the user defined exit processing before the task is destroyed.
421 ** This method is internal. It is used by Processor Expert only.
422 ** Parameters : None.
423 ** Returns : None.
424 ** ===================================================================
425 */
426 void App1_MainTask(void) {
427  // User function for initialization.
429 
430  // Initialize the application instance.
432  App1AppInstance.settings.AccelerometerSettings_Sub0.resultType = 0;
434  App1AppInstance.settings.AccelerometerSettings_Sub0.nSamplePeriod = 10000;
436  App1AppInstance.settings.AccelerometerSettings_Sub0.nFifoDepth = 1;
438  App1AppInstance.settings.AccelerometerSettings_Sub1.resultType = 0;
440  App1AppInstance.settings.AccelerometerSettings_Sub1.nSamplePeriod = 10000;
442  App1AppInstance.settings.AccelerometerSettings_Sub1.nFifoDepth = 1;
444  App1AppInstance.settings.AccelerometerSettings_Sub2.resultType = 0;
446  App1AppInstance.settings.AccelerometerSettings_Sub2.nSamplePeriod = 10000;
448  App1AppInstance.settings.AccelerometerSettings_Sub2.nFifoDepth = 1;
450  App1AppInstance.settings.AccelerometerSettings_Sub3.resultType = 0;
452  App1AppInstance.settings.AccelerometerSettings_Sub3.nSamplePeriod = 10000;
454  App1AppInstance.settings.AccelerometerSettings_Sub3.nFifoDepth = 1;
456  App1AppInstance.settings.AccelerometerSettings_Sub4.resultType = 0;
458  App1AppInstance.settings.AccelerometerSettings_Sub4.nSamplePeriod = 10000;
460  App1AppInstance.settings.AccelerometerSettings_Sub4.nFifoDepth = 1;
462  App1AppInstance.settings.AccelerometerSettings_Sub5.resultType = 0;
464  App1AppInstance.settings.AccelerometerSettings_Sub5.nSamplePeriod = 10000;
466  App1AppInstance.settings.AccelerometerSettings_Sub5.nFifoDepth = 1;
468  App1AppInstance.settings.AccelerometerSettings_Sub6.resultType = 0;
470  App1AppInstance.settings.AccelerometerSettings_Sub6.nSamplePeriod = 10000;
472  App1AppInstance.settings.AccelerometerSettings_Sub6.nFifoDepth = 1;
474  App1AppInstance.settings.AccelerometerSettings_Sub7.resultType = 0;
476  App1AppInstance.settings.AccelerometerSettings_Sub7.nSamplePeriod = 10000;
478  App1AppInstance.settings.AccelerometerSettings_Sub7.nFifoDepth = 1;
480  App1AppInstance.settings.MagnetometerSettings_Sub8.resultType = 0;
481  App1AppInstance.settings.MagnetometerSettings_Sub8.resultFormat = 1;
482  App1AppInstance.settings.MagnetometerSettings_Sub8.nSamplePeriod = 10000;
484  App1AppInstance.settings.MagnetometerSettings_Sub8.nFifoDepth = 1;
486  App1AppInstance.settings.MagnetometerSettings_Sub9.resultType = 0;
487  App1AppInstance.settings.MagnetometerSettings_Sub9.resultFormat = 1;
488  App1AppInstance.settings.MagnetometerSettings_Sub9.nSamplePeriod = 200000;
490  App1AppInstance.settings.MagnetometerSettings_Sub9.nFifoDepth = 1;
492  App1AppInstance.settings.GyrometerSettings_Sub10.resultType = 0;
493  App1AppInstance.settings.GyrometerSettings_Sub10.resultFormat = 1;
494  App1AppInstance.settings.GyrometerSettings_Sub10.nSamplePeriod = 10000;
495  App1AppInstance.settings.GyrometerSettings_Sub10.nSettingsToUse = 2;
496  App1AppInstance.settings.GyrometerSettings_Sub10.nFifoDepth = 1;
498  App1AppInstance.settings.GyrometerSettings_Sub11.resultType = 0;
499  App1AppInstance.settings.GyrometerSettings_Sub11.resultFormat = 1;
500  App1AppInstance.settings.GyrometerSettings_Sub11.nSamplePeriod = 10000;
501  App1AppInstance.settings.GyrometerSettings_Sub11.nSettingsToUse = 2;
502  App1AppInstance.settings.GyrometerSettings_Sub11.nFifoDepth = 1;
503  App1AppInstance.info.PressureInfo_Sub12.sensorId = DSA_MPL3115_1;
504  App1AppInstance.settings.PressureSettings_Sub12.resultType = 0;
505  App1AppInstance.settings.PressureSettings_Sub12.resultFormat = 1;
506  App1AppInstance.settings.PressureSettings_Sub12.nSamplePeriod = 10000;
507  App1AppInstance.settings.PressureSettings_Sub12.nSettingsToUse = 2;
508  App1AppInstance.settings.PressureSettings_Sub12.nFifoDepth = 1;
510  App1AppInstance.settings.TemperatureSettings_Sub13.resultType = 0;
511  App1AppInstance.settings.TemperatureSettings_Sub13.resultFormat = 1;
512  App1AppInstance.settings.TemperatureSettings_Sub13.nSamplePeriod = 10000;
514  App1AppInstance.settings.TemperatureSettings_Sub13.nFifoDepth = 1;
516  App1AppInstance.settings.OrientationSettings_Sub14.resultType = 0;
517  App1AppInstance.settings.OrientationSettings_Sub14.resultFormat = 1;
518  App1AppInstance.settings.OrientationSettings_Sub14.nSamplePeriod = 10000;
520  App1AppInstance.settings.OrientationSettings_Sub14.nFifoDepth = 1;
521  App1AppInstance.info.AltitudeInfo_Sub15.sensorId = DSA_MPL3115_1;
522  App1AppInstance.settings.AltitudeSettings_Sub15.resultType = 0;
523  App1AppInstance.settings.AltitudeSettings_Sub15.resultFormat = 1;
524  App1AppInstance.settings.AltitudeSettings_Sub15.nSamplePeriod = 10000;
525  App1AppInstance.settings.AltitudeSettings_Sub15.nSettingsToUse = 2;
526  App1AppInstance.settings.AltitudeSettings_Sub15.nFifoDepth = 1;
528  App1AppInstance.settings.PedometerSettings_Sub16.resultType = 0;
529  App1AppInstance.settings.PedometerSettings_Sub16.resultFormat = 1;
530  App1AppInstance.settings.PedometerSettings_Sub16.nSamplePeriod = 8192;
531  App1AppInstance.settings.PedometerSettings_Sub16.nSettingsToUse = 2;
532  App1AppInstance.settings.PedometerSettings_Sub16.nFifoDepth = 1;
534  App1AppInstance.settings.PedometerSettings_Sub17.resultType = 0;
535  App1AppInstance.settings.PedometerSettings_Sub17.resultFormat = 1;
536  App1AppInstance.settings.PedometerSettings_Sub17.nSamplePeriod = 8192;
537  App1AppInstance.settings.PedometerSettings_Sub17.nSettingsToUse = 2;
538  App1AppInstance.settings.PedometerSettings_Sub17.nFifoDepth = 1;
539  App1AppInstance.info.CustomInfo_Sub18.sensorId = DSA_Custom_1;
540  App1AppInstance.settings.CustomSettings_Sub18.resultType = 0;
541  App1AppInstance.settings.CustomSettings_Sub18.resultFormat = 1;
542  App1AppInstance.settings.CustomSettings_Sub18.nSamplePeriod = 10000;
543  App1AppInstance.settings.CustomSettings_Sub18.nSettingsToUse = 2;
544  App1AppInstance.settings.CustomSettings_Sub18.nFifoDepth = 1;
545  App1AppInstance.info.AnalogInfo_Sub19.sensorId = DSA_Analog_1;
546  App1AppInstance.settings.AnalogSettings_Sub19.resultType = 0;
547  App1AppInstance.settings.AnalogSettings_Sub19.resultFormat = 1;
548  App1AppInstance.settings.AnalogSettings_Sub19.nSamplePeriod = 10000;
549  App1AppInstance.settings.AnalogSettings_Sub19.nSettingsToUse = 2;
550  App1AppInstance.settings.AnalogSettings_Sub19.nFifoDepth = 1;
551 
552  /* Initialize and clear the lwevent passed to the Sensor Manager as part
553  * of the subscription to the App1 Sensor Adapter. */
554  OSA_EventCreate(&App1AppInstance.instance.smLWEvent, kEventAutoClear);
555  OSA_EventClear(&App1AppInstance.instance.smLWEvent, 0x00FFFFFF);
556  /* Create the outputBufferLock used to prevent updates made while
557  * data is being read by the host. */
558  OSA_SemaCreate(&App1AppInstance.instance.outputBufferLock, 1);
559 
560  // initialize the fifo using an explicitly provided data buffer
581  // Call the DSA direct interface to initialize the sensor.
582  init_sensor(
583  App1AppInstance.info.AccelerometerInfo_Sub0.sensorId,
585  &App1AppInstance.instance.smLWEvent,
587  //Save the Sensor's handle in the global list.
589  &App1AppInstance.info.AccelerometerInfo_Sub0.smAdapterHandle;
590  init_sensor(
591  App1AppInstance.info.AccelerometerInfo_Sub1.sensorId,
593  &App1AppInstance.instance.smLWEvent,
595  //Save the Sensor's handle in the global list.
597  &App1AppInstance.info.AccelerometerInfo_Sub1.smAdapterHandle;
598  init_sensor(
599  App1AppInstance.info.AccelerometerInfo_Sub2.sensorId,
601  &App1AppInstance.instance.smLWEvent,
603  //Save the Sensor's handle in the global list.
605  &App1AppInstance.info.AccelerometerInfo_Sub2.smAdapterHandle;
606  init_sensor(
607  App1AppInstance.info.AccelerometerInfo_Sub3.sensorId,
609  &App1AppInstance.instance.smLWEvent,
611  //Save the Sensor's handle in the global list.
613  &App1AppInstance.info.AccelerometerInfo_Sub3.smAdapterHandle;
614  init_sensor(
615  App1AppInstance.info.AccelerometerInfo_Sub4.sensorId,
617  &App1AppInstance.instance.smLWEvent,
619  //Save the Sensor's handle in the global list.
621  &App1AppInstance.info.AccelerometerInfo_Sub4.smAdapterHandle;
622  init_sensor(
623  App1AppInstance.info.AccelerometerInfo_Sub5.sensorId,
625  &App1AppInstance.instance.smLWEvent,
627  //Save the Sensor's handle in the global list.
629  &App1AppInstance.info.AccelerometerInfo_Sub5.smAdapterHandle;
630  init_sensor(
631  App1AppInstance.info.AccelerometerInfo_Sub6.sensorId,
633  &App1AppInstance.instance.smLWEvent,
635  //Save the Sensor's handle in the global list.
637  &App1AppInstance.info.AccelerometerInfo_Sub6.smAdapterHandle;
638  init_sensor(
639  App1AppInstance.info.AccelerometerInfo_Sub7.sensorId,
641  &App1AppInstance.instance.smLWEvent,
643  //Save the Sensor's handle in the global list.
645  &App1AppInstance.info.AccelerometerInfo_Sub7.smAdapterHandle;
646  init_sensor(
647  App1AppInstance.info.MagnetometerInfo_Sub8.sensorId,
648  &App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle,
649  &App1AppInstance.instance.smLWEvent,
651  //Save the Sensor's handle in the global list.
653  &App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle;
654  init_sensor(
655  App1AppInstance.info.MagnetometerInfo_Sub9.sensorId,
656  &App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle,
657  &App1AppInstance.instance.smLWEvent,
659  //Save the Sensor's handle in the global list.
661  &App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle;
662  init_sensor(
663  App1AppInstance.info.GyrometerInfo_Sub10.sensorId,
664  &App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle,
665  &App1AppInstance.instance.smLWEvent,
667  //Save the Sensor's handle in the global list.
669  &App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle;
670  init_sensor(
671  App1AppInstance.info.GyrometerInfo_Sub11.sensorId,
672  &App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle,
673  &App1AppInstance.instance.smLWEvent,
675  //Save the Sensor's handle in the global list.
677  &App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle;
678  init_sensor(
679  App1AppInstance.info.PressureInfo_Sub12.sensorId,
680  &App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle,
681  &App1AppInstance.instance.smLWEvent,
683  //Save the Sensor's handle in the global list.
685  &App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle;
686  init_sensor(
687  App1AppInstance.info.TemperatureInfo_Sub13.sensorId,
688  &App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle,
689  &App1AppInstance.instance.smLWEvent,
691  //Save the Sensor's handle in the global list.
693  &App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle;
694  init_sensor(
695  App1AppInstance.info.OrientationInfo_Sub14.sensorId,
696  &App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle,
697  &App1AppInstance.instance.smLWEvent,
699  //Save the Sensor's handle in the global list.
701  &App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle;
702  init_sensor(
703  App1AppInstance.info.AltitudeInfo_Sub15.sensorId,
704  &App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle,
705  &App1AppInstance.instance.smLWEvent,
707  //Save the Sensor's handle in the global list.
709  &App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle;
710  init_sensor(
711  App1AppInstance.info.PedometerInfo_Sub16.sensorId,
712  &App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle,
713  &App1AppInstance.instance.smLWEvent,
715  //Save the Sensor's handle in the global list.
717  &App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle;
718  init_sensor(
719  App1AppInstance.info.PedometerInfo_Sub17.sensorId,
720  &App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle,
721  &App1AppInstance.instance.smLWEvent,
723  //Save the Sensor's handle in the global list.
725  &App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle;
726  init_sensor(
727  App1AppInstance.info.CustomInfo_Sub18.sensorId,
728  &App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle,
729  &App1AppInstance.instance.smLWEvent,
731  //Save the Sensor's handle in the global list.
733  &App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle;
734  init_sensor(
735  App1AppInstance.info.AnalogInfo_Sub19.sensorId,
736  &App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle,
737  &App1AppInstance.instance.smLWEvent,
739  //Save the Sensor's handle in the global list.
741  &App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle;
742 
743  // Initialize the sensor subscriptions to Stopped/Unsubscribed state.
744  App1_GotoState(0);
745 
746  // Main task loop (forever).
747  while (1) {
748  // Wait for sensor data.
749  uint32 signalledEvents = 0;
750  OSA_EventWait(&App1AppInstance.instance.smLWEvent, App1_ALL_SENSOR_DATA_READY, 0, OSA_WAIT_FOREVER, &signalledEvents );
751  OSA_SemaWait(&App1AppInstance.instance.outputBufferLock, OSA_WAIT_FOREVER);
752  // Updated based on received event(s).
753  if (signalledEvents & App1_Accelerometer0_DATA_READY_EVENT) // Accelerometer event.
754  {
755  // Lock the fifo.
757  void *pData = NULL;
759  do {
760  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub0, &pData);
761  isf_ci_stream_update_data(1,sizeof(App1AppInstance.data.rawAccelerometerData_Sub0[0]), 0, (uint8 *)pData);
762  } while (status == ISF_SUCCESS);
763 
766  }
767  if (signalledEvents & App1_Accelerometer1_DATA_READY_EVENT) // Accelerometer event.
768  {
769  // Lock the fifo.
771  void *pData = NULL;
773  do {
774  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub1, &pData);
775  isf_ci_stream_update_data(2,sizeof(App1AppInstance.data.rawAccelerometerData_Sub1[0]), 0, (uint8 *)pData);
776  } while (status == ISF_SUCCESS);
777 
780  }
781  if (signalledEvents & App1_Accelerometer2_DATA_READY_EVENT) // Accelerometer event.
782  {
783  // Lock the fifo.
785  void *pData = NULL;
787  do {
788  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub2, &pData);
789  isf_ci_stream_update_data(3,sizeof(App1AppInstance.data.rawAccelerometerData_Sub2[0]), 0, (uint8 *)pData);
790  } while (status == ISF_SUCCESS);
791 
794  }
795  if (signalledEvents & App1_Accelerometer3_DATA_READY_EVENT) // Accelerometer event.
796  {
797  // Lock the fifo.
799  void *pData = NULL;
801  do {
802  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub3, &pData);
803  isf_ci_stream_update_data(4,sizeof(App1AppInstance.data.rawAccelerometerData_Sub3[0]), 0, (uint8 *)pData);
804  } while (status == ISF_SUCCESS);
805 
808  }
809  if (signalledEvents & App1_Accelerometer4_DATA_READY_EVENT) // Accelerometer event.
810  {
811  // Lock the fifo.
813  void *pData = NULL;
815  do {
816  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub4, &pData);
817  isf_ci_stream_update_data(5,sizeof(App1AppInstance.data.rawAccelerometerData_Sub4[0]), 0, (uint8 *)pData);
818  } while (status == ISF_SUCCESS);
819 
822  }
823  if (signalledEvents & App1_Accelerometer5_DATA_READY_EVENT) // Accelerometer event.
824  {
825  // Lock the fifo.
827  void *pData = NULL;
829  do {
830  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub5, &pData);
831  isf_ci_stream_update_data(6,sizeof(App1AppInstance.data.rawAccelerometerData_Sub5[0]), 0, (uint8 *)pData);
832  } while (status == ISF_SUCCESS);
833 
836  }
837  if (signalledEvents & App1_Accelerometer6_DATA_READY_EVENT) // Accelerometer event.
838  {
839  // Lock the fifo.
841  void *pData = NULL;
843  do {
844  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub6, &pData);
845  isf_ci_stream_update_data(7,sizeof(App1AppInstance.data.rawAccelerometerData_Sub6[0]), 0, (uint8 *)pData);
846  } while (status == ISF_SUCCESS);
847 
850  }
851  if (signalledEvents & App1_Accelerometer7_DATA_READY_EVENT) // Accelerometer event.
852  {
853  // Lock the fifo.
855  void *pData = NULL;
857  do {
858  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AccelerometerDataFifo_Sub7, &pData);
859  isf_ci_stream_update_data(8,sizeof(App1AppInstance.data.rawAccelerometerData_Sub7[0]), 0, (uint8 *)pData);
860  } while (status == ISF_SUCCESS);
861 
864  }
865  if (signalledEvents & App1_Magnetometer8_DATA_READY_EVENT) // Magnetometer event.
866  {
867  // Lock the fifo.
869  void *pData = NULL;
871  do {
872  status = isf_fifo_el_traverse(&App1AppInstance.fifos.MagnetometerDataFifo_Sub8, &pData);
873  isf_ci_stream_update_data(9,sizeof(App1AppInstance.data.rawMagnetometerData_Sub8[0]), 0, (uint8 *)pData);
874  } while (status == ISF_SUCCESS);
875 
878  }
879  if (signalledEvents & App1_Magnetometer9_DATA_READY_EVENT) // Magnetometer event.
880  {
881  // Lock the fifo.
883  void *pData = NULL;
885  do {
886  status = isf_fifo_el_traverse(&App1AppInstance.fifos.MagnetometerDataFifo_Sub9, &pData);
887  isf_ci_stream_update_data(10,sizeof(App1AppInstance.data.rawMagnetometerData_Sub9[0]), 0, (uint8 *)pData);
888  } while (status == ISF_SUCCESS);
889 
892  }
893  if (signalledEvents & App1_Gyrometer10_DATA_READY_EVENT) // Gyrometer event.
894  {
895  // Lock the fifo.
896  isf_fifo_lock(&App1AppInstance.fifos.GyrometerDataFifo_Sub10);
897  void *pData = NULL;
899  do {
900  status = isf_fifo_el_traverse(&App1AppInstance.fifos.GyrometerDataFifo_Sub10, &pData);
901  isf_ci_stream_update_data(11,sizeof(App1AppInstance.data.rawGyrometerData_Sub10[0]), 0, (uint8 *)pData);
902  } while (status == ISF_SUCCESS);
903 
906  }
907  if (signalledEvents & App1_Gyrometer11_DATA_READY_EVENT) // Gyrometer event.
908  {
909  // Lock the fifo.
910  isf_fifo_lock(&App1AppInstance.fifos.GyrometerDataFifo_Sub11);
911  void *pData = NULL;
913  do {
914  status = isf_fifo_el_traverse(&App1AppInstance.fifos.GyrometerDataFifo_Sub11, &pData);
915  isf_ci_stream_update_data(12,sizeof(App1AppInstance.data.rawGyrometerData_Sub11[0]), 0, (uint8 *)pData);
916  } while (status == ISF_SUCCESS);
917 
920  }
921  if (signalledEvents & App1_Pressure12_DATA_READY_EVENT) // Pressure event.
922  {
923  // Lock the fifo.
924  isf_fifo_lock(&App1AppInstance.fifos.PressureDataFifo_Sub12);
925  void *pData = NULL;
927  do {
928  status = isf_fifo_el_traverse(&App1AppInstance.fifos.PressureDataFifo_Sub12, &pData);
929  isf_ci_stream_update_data(13,sizeof(App1AppInstance.data.rawPressureData_Sub12[0]), 0, (uint8 *)pData);
930  } while (status == ISF_SUCCESS);
931 
933  isf_fifo_unlock(&App1AppInstance.fifos.PressureDataFifo_Sub12);
934  }
935  if (signalledEvents & App1_Temperature13_DATA_READY_EVENT) // Temperature event.
936  {
937  // Lock the fifo.
939  void *pData = NULL;
941  do {
942  status = isf_fifo_el_traverse(&App1AppInstance.fifos.TemperatureDataFifo_Sub13, &pData);
943  isf_ci_stream_update_data(14,sizeof(App1AppInstance.data.rawTemperatureData_Sub13[0]), 0, (uint8 *)pData);
944  } while (status == ISF_SUCCESS);
945 
948  }
949  if (signalledEvents & App1_Orientation14_DATA_READY_EVENT) // Orientation event.
950  {
951  // Lock the fifo.
953  void *pData = NULL;
955  do {
956  status = isf_fifo_el_traverse(&App1AppInstance.fifos.OrientationDataFifo_Sub14, &pData);
957  isf_ci_stream_update_data(15,sizeof(App1AppInstance.data.rawOrientationData_Sub14[0]), 0, (uint8 *)pData);
958  } while (status == ISF_SUCCESS);
959 
962  }
963  if (signalledEvents & App1_Altitude15_DATA_READY_EVENT) // Altitude event.
964  {
965  // Lock the fifo.
966  isf_fifo_lock(&App1AppInstance.fifos.AltitudeDataFifo_Sub15);
967  void *pData = NULL;
969  do {
970  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AltitudeDataFifo_Sub15, &pData);
971  isf_ci_stream_update_data(16,sizeof(App1AppInstance.data.rawAltitudeData_Sub15[0]), 0, (uint8 *)pData);
972  } while (status == ISF_SUCCESS);
973 
975  isf_fifo_unlock(&App1AppInstance.fifos.AltitudeDataFifo_Sub15);
976  }
977  if (signalledEvents & App1_Pedometer16_DATA_READY_EVENT) // Pedometer event.
978  {
979  // Lock the fifo.
980  isf_fifo_lock(&App1AppInstance.fifos.PedometerDataFifo_Sub16);
981  void *pData = NULL;
983  do {
984  status = isf_fifo_el_traverse(&App1AppInstance.fifos.PedometerDataFifo_Sub16, &pData);
985  isf_ci_stream_update_data(17,sizeof(App1AppInstance.data.rawPedometerData_Sub16[0]), 0, (uint8 *)pData);
986  } while (status == ISF_SUCCESS);
987 
990  }
991  if (signalledEvents & App1_Pedometer17_DATA_READY_EVENT) // Pedometer event.
992  {
993  // Lock the fifo.
994  isf_fifo_lock(&App1AppInstance.fifos.PedometerDataFifo_Sub17);
995  void *pData = NULL;
997  do {
998  status = isf_fifo_el_traverse(&App1AppInstance.fifos.PedometerDataFifo_Sub17, &pData);
999  isf_ci_stream_update_data(18,sizeof(App1AppInstance.data.rawPedometerData_Sub17[0]), 0, (uint8 *)pData);
1000  } while (status == ISF_SUCCESS);
1001 
1003  isf_fifo_unlock(&App1AppInstance.fifos.PedometerDataFifo_Sub17);
1004  }
1005  if (signalledEvents & App1_Custom18_DATA_READY_EVENT) // Custom event.
1006  {
1007  // Lock the fifo.
1008  isf_fifo_lock(&App1AppInstance.fifos.CustomDataFifo_Sub18);
1009  void *pData = NULL;
1010  isf_fifo_status_t status = ISF_SUCCESS;
1011  do {
1012  status = isf_fifo_el_traverse(&App1AppInstance.fifos.CustomDataFifo_Sub18, &pData);
1013  isf_ci_stream_update_data(19,sizeof(App1AppInstance.data.rawCustomData_Sub18[0]), 0, (uint8 *)pData);
1014  } while (status == ISF_SUCCESS);
1015 
1016  isf_fifo_el_clear(&App1AppInstance.fifos.CustomDataFifo_Sub18);
1017  isf_fifo_unlock(&App1AppInstance.fifos.CustomDataFifo_Sub18);
1018  }
1019  if (signalledEvents & App1_Analog19_DATA_READY_EVENT) // Analog event.
1020  {
1021  // Lock the fifo.
1022  isf_fifo_lock(&App1AppInstance.fifos.AnalogDataFifo_Sub19);
1023  void *pData = NULL;
1024  isf_fifo_status_t status = ISF_SUCCESS;
1025  do {
1026  status = isf_fifo_el_traverse(&App1AppInstance.fifos.AnalogDataFifo_Sub19, &pData);
1027  isf_ci_stream_update_data(20,sizeof(App1AppInstance.data.rawAnalogData_Sub19[0]), 0, (uint8 *)pData);
1028  } while (status == ISF_SUCCESS);
1029 
1030  isf_fifo_el_clear(&App1AppInstance.fifos.AnalogDataFifo_Sub19);
1031  isf_fifo_unlock(&App1AppInstance.fifos.AnalogDataFifo_Sub19);
1032  }
1033  // Have the Command Interpreter update the Quick-Read registers if they are enabled.
1034  if (GET_FIELD(CTRL_QREN,App1AppInstance.settings.control))
1035  {
1036  // If the application is in a state that can produce streaming output, then send it to the host interface.
1037  isf_ci_qr_update(App1AppInstance.instance.appId, sizeof(App1AppInstance.data), (uint8 *)&App1AppInstance.data);
1038  }
1039  // User function to process the raw sensor data.
1040  App1_ProcessData(&App1AppInstance.data, signalledEvents);
1041  // Unlock the buffer when it is no longer used.
1042  OSA_SemaPost(&App1AppInstance.instance.outputBufferLock);
1043  } /* end while() */
1044 
1045  // User function to clean up on exit.
1046  App1_Exit();
1047 }
1048 
1049 /*
1050 ** ===================================================================
1051 ** Method : App1_HCIAppCallback
1052 **
1053 ** Description :
1054 ** This function implements the App1 user application callback
1055 ** for the Command Interpreter.
1056 ** This function implements the predefined Command Interpreter command enumerations.
1057 ** It will also include calling user-define commands if configured.
1058 ** This method is internal. It is used by Processor Expert only.
1059 ** Parameters :
1060 ** NAME DESCRIPTION
1061 ** pHostPacket Pointer to the host command.
1062 ** pAppPacket Pointer to the response data.
1063 ** Returns :
1064 ** returns a value of type ci_response_t
1065 ** ===================================================================
1066 */
1068  // New application configuration.
1069  App1AppSettings_t NewConfig;
1070  // Helper pointers to application configuration and data structures.
1071  uint8 *pData = (uint8 *)&App1AppInstance.data;
1072  App1AppSettings_t *pConfig = &App1AppInstance.settings;
1073  appSubscriptionResponse_t isf_app_subscription_info;
1074  pseudoSettings_t *sensorSettings = (pseudoSettings_t*)&App1AppInstance.settings;
1075  SensorInfo_t *sensorInfo = (SensorInfo_t*)&App1AppInstance.info;
1076  uint8 num_sensors;
1077  int index=0;
1078 
1079  // Handle each valid host command.
1080  switch(pHostPacket->cmd)
1081  {
1082  // Read data from the host output buffer.
1083  case CI_CMD_READ_APP_DATA:
1084  // Check if the command accesses bytes outside the valid range.
1085  if (pHostPacket->byte_cnt > sizeof(App1AppInstance.data)) {
1086  return CI_INVALID_COUNT;
1087  }
1088  if (pHostPacket->offset + pHostPacket->byte_cnt > sizeof(App1AppInstance.data)) {
1089  return CI_ERROR_COMMAND;
1090  }
1091 
1092  // Lock the output buffer, update the data to the CI, then unlock the buffer.
1093  OSA_SemaWait(&App1AppInstance.instance.outputBufferLock, OSA_WAIT_FOREVER);
1094  pAppPacket->bytes_xfer = isf_ci_app_write(pHostPacket->appId, pHostPacket->byte_cnt, (uint8*)pData + pHostPacket->offset);
1095  OSA_SemaPost(&App1AppInstance.instance.outputBufferLock);
1096  break;
1097 
1098  // Update the Quick-Read data.
1100  OSA_SemaWait(&App1AppInstance.instance.outputBufferLock, OSA_WAIT_FOREVER);
1101  isf_ci_qr_update(App1AppInstance.instance.appId, (int8)sizeof(*pData), (uint8 *)&App1AppInstance.data);
1102  OSA_SemaPost(&App1AppInstance.instance.outputBufferLock);
1103  break;
1104 
1105  // Read or write the application configuration structure.
1106  case CI_CMD_READ_CONFIG:
1107  // Fall through
1108  case CI_CMD_WRITE_CONFIG:
1109  // Check if the command accesses bytes outside the valid range.
1110  if (pHostPacket->byte_cnt > sizeof(*pConfig))
1111  return CI_INVALID_COUNT;
1112  if (pHostPacket->offset + pHostPacket->byte_cnt > sizeof(*pConfig))
1113  return CI_ERROR_COMMAND;
1114 
1115  if (CI_CMD_READ_CONFIG == pHostPacket->cmd) {
1116  // Create a copy of the current settings.
1117  NewConfig = App1AppInstance.settings;
1118 
1119  // Convert the timestamp to big endian before sending data to the host.
1140  // Write the requested (READ) information to the host interface.
1141  pAppPacket->bytes_xfer = (uint8)isf_ci_app_write(pHostPacket->appId, (uint32)pHostPacket->byte_cnt,
1142  (uint8*)&NewConfig + pHostPacket->offset);
1143  }
1144  else
1145  {
1146  uint8 powerMode;
1147  // The host may not write the entire configuration buffer, so start with the current configuration.
1148  NewConfig = App1AppInstance.settings;
1149 
1150  // Read the new data from the host.
1151  pAppPacket->bytes_xfer = (uint8)isf_ci_app_read(pHostPacket->appId, (uint32)pHostPacket->byte_cnt,
1152  (uint8*)&NewConfig + pHostPacket->offset);
1153  // If the host updated the report rate, then convert big endian to little endian for each subscription.
1154  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub0.nSamplePeriod) >= pHostPacket->offset) &&
1155  ((startof(App1AppSettings_t,AccelerometerSettings_Sub0.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1156  {
1158  }
1159  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub1.nSamplePeriod) >= pHostPacket->offset) &&
1160  ((startof(App1AppSettings_t,AccelerometerSettings_Sub1.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1161  {
1163  }
1164  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub2.nSamplePeriod) >= pHostPacket->offset) &&
1165  ((startof(App1AppSettings_t,AccelerometerSettings_Sub2.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1166  {
1168  }
1169  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub3.nSamplePeriod) >= pHostPacket->offset) &&
1170  ((startof(App1AppSettings_t,AccelerometerSettings_Sub3.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1171  {
1173  }
1174  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub4.nSamplePeriod) >= pHostPacket->offset) &&
1175  ((startof(App1AppSettings_t,AccelerometerSettings_Sub4.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1176  {
1178  }
1179  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub5.nSamplePeriod) >= pHostPacket->offset) &&
1180  ((startof(App1AppSettings_t,AccelerometerSettings_Sub5.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1181  {
1183  }
1184  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub6.nSamplePeriod) >= pHostPacket->offset) &&
1185  ((startof(App1AppSettings_t,AccelerometerSettings_Sub6.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1186  {
1188  }
1189  if ((startof(App1AppSettings_t,AccelerometerSettings_Sub7.nSamplePeriod) >= pHostPacket->offset) &&
1190  ((startof(App1AppSettings_t,AccelerometerSettings_Sub7.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1191  {
1193  }
1194  if ((startof(App1AppSettings_t,MagnetometerSettings_Sub8.nSamplePeriod) >= pHostPacket->offset) &&
1195  ((startof(App1AppSettings_t,MagnetometerSettings_Sub8.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1196  {
1198  }
1199  if ((startof(App1AppSettings_t,MagnetometerSettings_Sub9.nSamplePeriod) >= pHostPacket->offset) &&
1200  ((startof(App1AppSettings_t,MagnetometerSettings_Sub9.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1201  {
1203  }
1204  if ((startof(App1AppSettings_t,GyrometerSettings_Sub10.nSamplePeriod) >= pHostPacket->offset) &&
1205  ((startof(App1AppSettings_t,GyrometerSettings_Sub10.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1206  {
1208  }
1209  if ((startof(App1AppSettings_t,GyrometerSettings_Sub11.nSamplePeriod) >= pHostPacket->offset) &&
1210  ((startof(App1AppSettings_t,GyrometerSettings_Sub11.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1211  {
1213  }
1214  if ((startof(App1AppSettings_t,PressureSettings_Sub12.nSamplePeriod) >= pHostPacket->offset) &&
1215  ((startof(App1AppSettings_t,PressureSettings_Sub12.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1216  {
1218  }
1219  if ((startof(App1AppSettings_t,TemperatureSettings_Sub13.nSamplePeriod) >= pHostPacket->offset) &&
1220  ((startof(App1AppSettings_t,TemperatureSettings_Sub13.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1221  {
1223  }
1224  if ((startof(App1AppSettings_t,OrientationSettings_Sub14.nSamplePeriod) >= pHostPacket->offset) &&
1225  ((startof(App1AppSettings_t,OrientationSettings_Sub14.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1226  {
1228  }
1229  if ((startof(App1AppSettings_t,AltitudeSettings_Sub15.nSamplePeriod) >= pHostPacket->offset) &&
1230  ((startof(App1AppSettings_t,AltitudeSettings_Sub15.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1231  {
1233  }
1234  if ((startof(App1AppSettings_t,PedometerSettings_Sub16.nSamplePeriod) >= pHostPacket->offset) &&
1235  ((startof(App1AppSettings_t,PedometerSettings_Sub16.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1236  {
1238  }
1239  if ((startof(App1AppSettings_t,PedometerSettings_Sub17.nSamplePeriod) >= pHostPacket->offset) &&
1240  ((startof(App1AppSettings_t,PedometerSettings_Sub17.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1241  {
1243  }
1244  if ((startof(App1AppSettings_t,CustomSettings_Sub18.nSamplePeriod) >= pHostPacket->offset) &&
1245  ((startof(App1AppSettings_t,CustomSettings_Sub18.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1246  {
1248  }
1249  if ((startof(App1AppSettings_t,AnalogSettings_Sub19.nSamplePeriod) >= pHostPacket->offset) &&
1250  ((startof(App1AppSettings_t,AnalogSettings_Sub19.nSettingsToUse) - 1) <= (pHostPacket->offset + pHostPacket->byte_cnt) ))
1251  {
1253  }
1254  // If the sensor settings are changed while subscribed, then unsubscribe and resubscribe to
1255  // achieve the new settings. If not currently subscribed, then just store the new settings.
1256  // Update the Quick-Read enable and power mode.
1257  App1AppInstance.settings.control =
1258  (App1AppInstance.settings.control & CTRL_STATE_MASK) |
1259  SET_FIELD(CTRL_QREN,GET_FIELD(CTRL_QREN,NewConfig.control)) |
1260  SET_FIELD(CTRL_POWER,GET_FIELD(CTRL_POWER,NewConfig.control));
1261 
1262  // Set the ISF power mode based on the host request.
1263  powerMode = GET_FIELD(CTRL_POWER,App1AppInstance.settings.control);
1264  //powerMode = isf_power_set(powerMode);
1265 
1266  // Store the resulting mode into the application state structure.
1267  App1AppInstance.settings.control =
1268  (App1AppInstance.settings.control & ~CTRL_POWER_MASK) |
1269  SET_FIELD(CTRL_POWER,powerMode);
1270 
1271  // If the embedded application settings have been changed by the host, then bring subscriptions to Stopped/Unsubscribed.
1272  if ( SmSettingsCompare(&NewConfig, &App1AppInstance.settings)) {
1282  App1AppInstance.settings.MagnetometerSettings_Sub8 = NewConfig.MagnetometerSettings_Sub8;
1283  App1AppInstance.settings.MagnetometerSettings_Sub9 = NewConfig.MagnetometerSettings_Sub9;
1284  App1AppInstance.settings.GyrometerSettings_Sub10 = NewConfig.GyrometerSettings_Sub10;
1285  App1AppInstance.settings.GyrometerSettings_Sub11 = NewConfig.GyrometerSettings_Sub11;
1286  App1AppInstance.settings.PressureSettings_Sub12 = NewConfig.PressureSettings_Sub12;
1287  App1AppInstance.settings.TemperatureSettings_Sub13 = NewConfig.TemperatureSettings_Sub13;
1288  App1AppInstance.settings.OrientationSettings_Sub14 = NewConfig.OrientationSettings_Sub14;
1289  App1AppInstance.settings.AltitudeSettings_Sub15 = NewConfig.AltitudeSettings_Sub15;
1290  App1AppInstance.settings.PedometerSettings_Sub16 = NewConfig.PedometerSettings_Sub16;
1291  App1AppInstance.settings.PedometerSettings_Sub17 = NewConfig.PedometerSettings_Sub17;
1292  App1AppInstance.settings.CustomSettings_Sub18 = NewConfig.CustomSettings_Sub18;
1293  App1AppInstance.settings.AnalogSettings_Sub19 = NewConfig.AnalogSettings_Sub19;
1294  }
1295  // Return the subscriptions to the requested state.
1296  if (App1_GotoState(GET_FIELD(CTRL_STATE,NewConfig.control))) {
1297  return CI_ERROR_COMMAND;
1298  }
1299 
1300  }
1301  break;
1302 
1303  // Reset the application state.
1304  case CI_CMD_RESET_APP:
1305  if (App1_GotoState(0) != 0) {
1306  return CI_ERROR_COMMAND;
1307  }
1308  break;
1309 
1310  // Read ISF Embedded Application Version Info.
1311  case CI_CMD_READ_VERSION:
1312  // Write the ISF Application information to the host interface.
1313  pAppPacket->bytes_xfer = isf_ci_app_write(pHostPacket->appId, sizeof(gsApp1_AppInfo), (uint8*)&gsApp1_AppInfo);
1314  break;
1315 
1316  // Read ISF Embedded Application Sensor Subscription Info.
1318  // Get the ISF Application Sensor Subscription Information
1319  num_sensors = sizeof(App1AppInstance.info)/sizeof(SensorInfo_t);
1320 
1321  isf_app_subscription_info.numSensors = num_sensors;
1322 
1323  for (index=0; index< num_sensors; index++)
1324  {
1325  isf_app_subscription_info.configArray[index].sensorId = sensorInfo[index].sensorId;
1326  isf_app_subscription_info.configArray[index].sensorDataType = sensorSettings->subArray[index].resultType;
1327  isf_app_subscription_info.configArray[index].sensorResultType = sensorSettings->subArray[index].resultFormat;
1328  isf_app_subscription_info.configArray[index].sampleRateOffset = startof(pseudoSettings_t,subArray[index].nSamplePeriod);
1329  }
1330 
1331  isf_app_subscription_info.processedDataBufferOffset = startof(App1AppInstance_t, data.processedData);
1332 
1333  // Write the ISF Application Sensor Subscription Info to the host interface.
1334  pAppPacket->bytes_xfer = isf_ci_app_write(pHostPacket->appId, sizeof(appSubscriptionResponse_t), (uint8*)&isf_app_subscription_info);
1335  break;
1336  // Host writing SREC FLASH Bytes.
1338  // Check if the command accesses bytes outside the valid range.
1339  if (pHostPacket->byte_cnt > CI_MAX_FLASH_BYTES)
1340  return CI_INVALID_COUNT;
1341 
1342  // Call f/n to send command to target Sensor.
1343  {
1344  uint8 pData[CI_MAX_FLASH_BYTES];
1345 
1346  pAppPacket->bytes_xfer = (uint8)isf_ci_app_read(pHostPacket->appId, (uint32)pHostPacket->byte_cnt, pData);
1347  if(0 != App1_FlashSensor(pHostPacket->byte_cnt, pData))
1348  return CI_ERROR_COMMAND;
1349  }
1350  break;
1351 
1352 
1353  default:
1354  return CI_ERROR_COMMAND;
1355  break;
1356  }
1357  return CI_ERROR_NONE;
1358 }
1359 
1360 /*
1361 ** ===================================================================
1362 ** Method : App1_ReturnSensorsToInit()
1363 **
1364 ** Description :
1365 ** This function is used by the App1_GotoState() state machine to manually return the sensors
1366 ** to the 'DSA_STATE_INITIALIZED' state when there is an error with any of the sensors. This is done
1367 ** with the assumption that we are already in an Error state with at least one sensor AND that error will
1368 ** be returned to a higher level, so don't try to check errors further here.
1369 ** Parameters :
1370 ** None.
1371 ** Returns :
1372 ** Nothing
1373 ** ===================================================================
1374 */
1376 {
1377  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1379  {
1381  }
1383  {
1385  }
1386  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1388  {
1390  }
1392  {
1394  }
1395  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1397  {
1399  }
1401  {
1403  }
1404  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1406  {
1408  }
1410  {
1412  }
1413  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1415  {
1417  }
1419  {
1421  }
1422  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1424  {
1426  }
1428  {
1430  }
1431  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1433  {
1435  }
1437  {
1439  }
1440  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1442  {
1444  }
1446  {
1448  }
1449  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1451  {
1453  }
1455  {
1457  }
1458  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1460  {
1462  }
1464  {
1466  }
1467  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1469  {
1471  }
1473  {
1475  }
1476  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1478  {
1480  }
1482  {
1484  }
1485  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1487  {
1489  }
1491  {
1493  }
1494  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1496  {
1498  }
1500  {
1502  }
1503  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1505  {
1507  }
1509  {
1511  }
1512  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1514  {
1516  }
1518  {
1520  }
1521  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1523  {
1525  }
1527  {
1529  }
1530  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1532  {
1534  }
1536  {
1538  }
1539  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1541  {
1543  }
1545  {
1547  }
1548  // Return the Sensor back to the DSA_STATE_INITIALIZED.
1550  {
1552  }
1554  {
1556  }
1557 }
1558 
1559 /*
1560 ** ===================================================================
1561 ** Method : App1_FlashSensor()
1562 **
1563 ** Description :
1564 ** This function is used to FLASH supported sensors. This is done
1565 ** with the assumption that the sensor is in the proper state where it can be flashed AND that error will
1566 ** be returned to a higher level, so don't try to check errors further here.
1567 ** Parameters :
1568 ** numBytes : Number of Bytes of Flash Data.
1569 ** pFlashData : pointer pointing to bytes of flash.
1570 ** Returns :
1571 ** Status : 0 on Success.
1572 ** ===================================================================
1573 */
1574 int8 App1_FlashSensor(uint8 numBytes, uint8 *pFlashData)
1575 {
1576  uint8 sensorSubscription = pFlashData[0];
1577  isf_SensorHandle_t *pSensorAdapterHandle;
1578 
1579  if (sensorSubscription < gNumSupportedSensors)
1580  {
1581  pSensorAdapterHandle = gSensorHandleList[sensorSubscription];
1582  }
1583 
1584  if(pFlashData && pSensorAdapterHandle->pSensorStaticConfig->pAdapter->control.Flash)
1585  return pSensorAdapterHandle->pSensorStaticConfig->pAdapter->control.Flash(pSensorAdapterHandle, pFlashData+1, numBytes-1);
1586  else
1587  return -1;
1588 }
1589 
1590 /*
1591 ** ===================================================================
1592 ** Method : App1_GotoState()
1593 **
1594 ** Description :
1595 ** This function implements the App1 sensor subscription state machine.
1596 ** The implementation currently supports three states:
1597 ** App1_STATE_STOPPED_UNSUBSCRIBED = 0, // Sensor is Unsubscribed; Data Flow is Stopped (Initial State).
1598 ** App1_STATE_STOPPED_SUBSCRIBED = 1, // Sensor is Subscribed; Data Flow is Stopped.
1599 ** App1_STATE_STARTED_SUBSCRIBED = 2, // Sensor is Subscribed; Data Flow has Started.
1600 ** As the state machine transitions between the states, it makes calls to the ISF Sensor Manager
1601 ** functions as necessary.
1602 ** This method is internal. It is used by Processor Expert only.
1603 ** Parameters :
1604 ** NAME DESCRIPTION
1605 ** desiredState The desiredstate for the application at the
1606 ** completion of the function call.
1607 ** pAppPacket Pointer to the response data.
1608 ** Returns :
1609 ** returns an int32 value indicating the status of its operation.
1610 ** ===================================================================
1611 */
1613 {
1614  isf_status_t smstt = 0;
1615  int32 retval = 0;
1616 
1617  // Check that the desired state is within range, otherwise return an error.
1618  if (desiredState > App1_STATE_STARTED_SUBSCRIBED)
1619  {
1620  return 1;
1621  }
1622 
1623  // Loop until the desired state is reached or an error occurs.
1624  while ( !smstt && (desiredState != GET_FIELD(CTRL_STATE,App1AppInstance.settings.control)) )
1625  {
1626  switch ( GET_FIELD(CTRL_STATE,App1AppInstance.settings.control) )
1627  {
1629  // The only valid transition from current state is to stopped, subscribed.
1630  // Subscribe to the sensor data.
1631  smstt = ISF_SUCCESS;
1632 
1633  smstt |= configure_sensor(
1634  &App1AppInstance.info.AccelerometerInfo_Sub0.smAdapterHandle,
1635  &App1AppInstance.settings.AccelerometerSettings_Sub0,
1636  &App1AppInstance.fifos.AccelerometerDataFifo_Sub0);
1637  smstt |= configure_sensor(
1638  &App1AppInstance.info.AccelerometerInfo_Sub1.smAdapterHandle,
1639  &App1AppInstance.settings.AccelerometerSettings_Sub1,
1640  &App1AppInstance.fifos.AccelerometerDataFifo_Sub1);
1641  smstt |= configure_sensor(
1642  &App1AppInstance.info.AccelerometerInfo_Sub2.smAdapterHandle,
1643  &App1AppInstance.settings.AccelerometerSettings_Sub2,
1644  &App1AppInstance.fifos.AccelerometerDataFifo_Sub2);
1645  smstt |= configure_sensor(
1646  &App1AppInstance.info.AccelerometerInfo_Sub3.smAdapterHandle,
1647  &App1AppInstance.settings.AccelerometerSettings_Sub3,
1648  &App1AppInstance.fifos.AccelerometerDataFifo_Sub3);
1649  smstt |= configure_sensor(
1650  &App1AppInstance.info.AccelerometerInfo_Sub4.smAdapterHandle,
1651  &App1AppInstance.settings.AccelerometerSettings_Sub4,
1652  &App1AppInstance.fifos.AccelerometerDataFifo_Sub4);
1653  smstt |= configure_sensor(
1654  &App1AppInstance.info.AccelerometerInfo_Sub5.smAdapterHandle,
1655  &App1AppInstance.settings.AccelerometerSettings_Sub5,
1656  &App1AppInstance.fifos.AccelerometerDataFifo_Sub5);
1657  smstt |= configure_sensor(
1658  &App1AppInstance.info.AccelerometerInfo_Sub6.smAdapterHandle,
1659  &App1AppInstance.settings.AccelerometerSettings_Sub6,
1660  &App1AppInstance.fifos.AccelerometerDataFifo_Sub6);
1661  smstt |= configure_sensor(
1662  &App1AppInstance.info.AccelerometerInfo_Sub7.smAdapterHandle,
1663  &App1AppInstance.settings.AccelerometerSettings_Sub7,
1664  &App1AppInstance.fifos.AccelerometerDataFifo_Sub7);
1665  smstt |= configure_sensor(
1666  &App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle,
1667  &App1AppInstance.settings.MagnetometerSettings_Sub8,
1668  &App1AppInstance.fifos.MagnetometerDataFifo_Sub8);
1669  smstt |= configure_sensor(
1670  &App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle,
1671  &App1AppInstance.settings.MagnetometerSettings_Sub9,
1672  &App1AppInstance.fifos.MagnetometerDataFifo_Sub9);
1673  smstt |= configure_sensor(
1674  &App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle,
1675  &App1AppInstance.settings.GyrometerSettings_Sub10,
1676  &App1AppInstance.fifos.GyrometerDataFifo_Sub10);
1677  smstt |= configure_sensor(
1678  &App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle,
1679  &App1AppInstance.settings.GyrometerSettings_Sub11,
1680  &App1AppInstance.fifos.GyrometerDataFifo_Sub11);
1681  smstt |= configure_sensor(
1682  &App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle,
1683  &App1AppInstance.settings.PressureSettings_Sub12,
1684  &App1AppInstance.fifos.PressureDataFifo_Sub12);
1685  smstt |= configure_sensor(
1686  &App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle,
1687  &App1AppInstance.settings.TemperatureSettings_Sub13,
1688  &App1AppInstance.fifos.TemperatureDataFifo_Sub13);
1689  smstt |= configure_sensor(
1690  &App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle,
1691  &App1AppInstance.settings.OrientationSettings_Sub14,
1692  &App1AppInstance.fifos.OrientationDataFifo_Sub14);
1693  smstt |= configure_sensor(
1694  &App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle,
1695  &App1AppInstance.settings.AltitudeSettings_Sub15,
1696  &App1AppInstance.fifos.AltitudeDataFifo_Sub15);
1697  smstt |= configure_sensor(
1698  &App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle,
1699  &App1AppInstance.settings.PedometerSettings_Sub16,
1700  &App1AppInstance.fifos.PedometerDataFifo_Sub16);
1701  smstt |= configure_sensor(
1702  &App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle,
1703  &App1AppInstance.settings.PedometerSettings_Sub17,
1704  &App1AppInstance.fifos.PedometerDataFifo_Sub17);
1705  smstt |= configure_sensor(
1706  &App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle,
1707  &App1AppInstance.settings.CustomSettings_Sub18,
1708  &App1AppInstance.fifos.CustomDataFifo_Sub18);
1709  smstt |= configure_sensor(
1710  &App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle,
1711  &App1AppInstance.settings.AnalogSettings_Sub19,
1712  &App1AppInstance.fifos.AnalogDataFifo_Sub19);
1713  if (smstt != ISF_SUCCESS) {
1715  retval = 1;
1716  }
1717  else
1718  {
1719  // State transition.
1720  App1AppInstance.settings.control = (App1AppInstance.settings.control & ~CTRL_STATE_MASK) |
1722  }
1723  break;
1724 
1726  // The only valid transition from the current state is to the stopped, subscribed state.
1727  smstt = ISF_SUCCESS;
1728  // End subscription to the sensor data.
1729  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub0.smAdapterHandle);
1730  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub1.smAdapterHandle);
1731  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub2.smAdapterHandle);
1732  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub3.smAdapterHandle);
1733  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub4.smAdapterHandle);
1734  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub5.smAdapterHandle);
1735  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub6.smAdapterHandle);
1736  smstt |= stop_sensor(&App1AppInstance.info.AccelerometerInfo_Sub7.smAdapterHandle);
1737  smstt |= stop_sensor(&App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle);
1738  smstt |= stop_sensor(&App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle);
1739  smstt |= stop_sensor(&App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle);
1740  smstt |= stop_sensor(&App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle);
1741  smstt |= stop_sensor(&App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle);
1742  smstt |= stop_sensor(&App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle);
1743  smstt |= stop_sensor(&App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle);
1744  smstt |= stop_sensor(&App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle);
1745  smstt |= stop_sensor(&App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle);
1746  smstt |= stop_sensor(&App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle);
1747  smstt |= stop_sensor(&App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle);
1748  smstt |= stop_sensor(&App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle);
1749  if (smstt != ISF_SUCCESS) {
1751  retval = 1;
1752  }
1753  else
1754  {
1755  // State transition.
1756  App1AppInstance.settings.control = (App1AppInstance.settings.control & ~CTRL_STATE_MASK) |
1758  }
1759  break;
1760 
1762  // From the current state, the valid transitions are to the stopped, unsubscribed, or started, subscribed states.
1763  smstt = ISF_SUCCESS;
1764  if (desiredState)
1765  {
1766  // Begin subscription to the sensor data.
1767  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub0.smAdapterHandle);
1768  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub1.smAdapterHandle);
1769  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub2.smAdapterHandle);
1770  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub3.smAdapterHandle);
1771  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub4.smAdapterHandle);
1772  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub5.smAdapterHandle);
1773  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub6.smAdapterHandle);
1774  smstt |= start_sensor(&App1AppInstance.info.AccelerometerInfo_Sub7.smAdapterHandle);
1775  smstt |= start_sensor(&App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle);
1776  smstt |= start_sensor(&App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle);
1777  smstt |= start_sensor(&App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle);
1778  smstt |= start_sensor(&App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle);
1779  smstt |= start_sensor(&App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle);
1780  smstt |= start_sensor(&App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle);
1781  smstt |= start_sensor(&App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle);
1782  smstt |= start_sensor(&App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle);
1783  smstt |= start_sensor(&App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle);
1784  smstt |= start_sensor(&App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle);
1785  smstt |= start_sensor(&App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle);
1786  smstt |= start_sensor(&App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle);
1787  if (smstt != ISF_SUCCESS) {
1789  retval = 1;
1790  }
1791  else
1792  {
1793  // State transition.
1794  App1AppInstance.settings.control = (App1AppInstance.settings.control & ~CTRL_STATE_MASK) |
1796  }
1797  }
1798  else
1799  {
1800  // Unsubscribe from the sensor adapter data.
1801  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub0.smAdapterHandle);
1802  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub1.smAdapterHandle);
1803  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub2.smAdapterHandle);
1804  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub3.smAdapterHandle);
1805  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub4.smAdapterHandle);
1806  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub5.smAdapterHandle);
1807  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub6.smAdapterHandle);
1808  smstt |= shutdown_sensor(&App1AppInstance.info.AccelerometerInfo_Sub7.smAdapterHandle);
1809  smstt |= shutdown_sensor(&App1AppInstance.info.MagnetometerInfo_Sub8.smAdapterHandle);
1810  smstt |= shutdown_sensor(&App1AppInstance.info.MagnetometerInfo_Sub9.smAdapterHandle);
1811  smstt |= shutdown_sensor(&App1AppInstance.info.GyrometerInfo_Sub10.smAdapterHandle);
1812  smstt |= shutdown_sensor(&App1AppInstance.info.GyrometerInfo_Sub11.smAdapterHandle);
1813  smstt |= shutdown_sensor(&App1AppInstance.info.PressureInfo_Sub12.smAdapterHandle);
1814  smstt |= shutdown_sensor(&App1AppInstance.info.TemperatureInfo_Sub13.smAdapterHandle);
1815  smstt |= shutdown_sensor(&App1AppInstance.info.OrientationInfo_Sub14.smAdapterHandle);
1816  smstt |= shutdown_sensor(&App1AppInstance.info.AltitudeInfo_Sub15.smAdapterHandle);
1817  smstt |= shutdown_sensor(&App1AppInstance.info.PedometerInfo_Sub16.smAdapterHandle);
1818  smstt |= shutdown_sensor(&App1AppInstance.info.PedometerInfo_Sub17.smAdapterHandle);
1819  smstt |= shutdown_sensor(&App1AppInstance.info.CustomInfo_Sub18.smAdapterHandle);
1820  smstt |= shutdown_sensor(&App1AppInstance.info.AnalogInfo_Sub19.smAdapterHandle);
1821  if (smstt != ISF_SUCCESS) {
1823  retval = 1;
1824  } else {
1825  // State transition.
1826  App1AppInstance.settings.control = (App1AppInstance.settings.control & ~CTRL_STATE_MASK) |
1828  }
1829  }
1830  break;
1831 
1832  default:
1833  // This is an invalid current state.
1834  retval = 1;
1835  }
1836  }
1837  return retval;
1838 }
1839 
1840 /*
1841 ** ===================================================================
1842 ** Method : SettingsCompare()
1843 **
1844 ** Description :
1845 ** This function compares the members of the App1AppSettings_t C structure
1846 ** because C does not automatically provide for comparison of structures.
1847 ** This method is internal. It is used by Processor Expert only.
1848 ** Parameters :
1849 ** NAME DESCRIPTION
1850 ** s1 A pointer to the first structure to compare
1851 ** s2 A pointer to the second structure to compare
1852 ** Returns :
1853 ** 0 The structures are equivalent. 1 The structures are different.
1854 ** ===================================================================
1855 */
1856 static int32 SettingsCompare(const isf_SubscriptionSettings_t *s1, const isf_SubscriptionSettings_t *s2)
1857 {
1858  return (
1859  (s1->resultType != s2->resultType) ||
1860  (s1->resultFormat != s2->resultFormat) ||
1861  (s1->nSettingsToUse != s2->nSettingsToUse) ||
1862  (s1->nFifoDepth != s2->nFifoDepth) ||
1863  (s1->nSamplePeriod != s2->nSamplePeriod));
1864 }
1865 
1866 /*
1867 ** ===================================================================
1868 ** Method : SmSettingsCompare()
1869 **
1870 ** Description :
1871 ** This function compares the members of the App1AppConfig_t C structure
1872 ** because C does not automatically provide for comparison of structures.
1873 ** This method is internal. It is used by Processor Expert only.
1874 ** Parameters :
1875 ** NAME DESCRIPTION
1876 ** s1 A pointer to the first structure to compare
1877 ** s2 A pointer to the second structure to compare
1878 ** Returns :
1879 ** 0 The structures are equivalent. 1 The structures are different.
1880 ** ===================================================================
1881 */
1882 static int32 SmSettingsCompare(const App1AppSettings_t *s1, const App1AppSettings_t *s2)
1883 {
1884  return (
1885  SettingsCompare(&s1->AccelerometerSettings_Sub0,&s2->AccelerometerSettings_Sub0) ||
1886  SettingsCompare(&s1->AccelerometerSettings_Sub1,&s2->AccelerometerSettings_Sub1) ||
1887  SettingsCompare(&s1->AccelerometerSettings_Sub2,&s2->AccelerometerSettings_Sub2) ||
1888  SettingsCompare(&s1->AccelerometerSettings_Sub3,&s2->AccelerometerSettings_Sub3) ||
1889  SettingsCompare(&s1->AccelerometerSettings_Sub4,&s2->AccelerometerSettings_Sub4) ||
1890  SettingsCompare(&s1->AccelerometerSettings_Sub5,&s2->AccelerometerSettings_Sub5) ||
1891  SettingsCompare(&s1->AccelerometerSettings_Sub6,&s2->AccelerometerSettings_Sub6) ||
1892  SettingsCompare(&s1->AccelerometerSettings_Sub7,&s2->AccelerometerSettings_Sub7) ||
1893  SettingsCompare(&s1->MagnetometerSettings_Sub8,&s2->MagnetometerSettings_Sub8) ||
1894  SettingsCompare(&s1->MagnetometerSettings_Sub9,&s2->MagnetometerSettings_Sub9) ||
1895  SettingsCompare(&s1->GyrometerSettings_Sub10,&s2->GyrometerSettings_Sub10) ||
1896  SettingsCompare(&s1->GyrometerSettings_Sub11,&s2->GyrometerSettings_Sub11) ||
1897  SettingsCompare(&s1->PressureSettings_Sub12,&s2->PressureSettings_Sub12) ||
1898  SettingsCompare(&s1->TemperatureSettings_Sub13,&s2->TemperatureSettings_Sub13) ||
1899  SettingsCompare(&s1->OrientationSettings_Sub14,&s2->OrientationSettings_Sub14) ||
1900  SettingsCompare(&s1->AltitudeSettings_Sub15,&s2->AltitudeSettings_Sub15) ||
1901  SettingsCompare(&s1->PedometerSettings_Sub16,&s2->PedometerSettings_Sub16) ||
1902  SettingsCompare(&s1->PedometerSettings_Sub17,&s2->PedometerSettings_Sub17) ||
1903  SettingsCompare(&s1->CustomSettings_Sub18,&s2->CustomSettings_Sub18) ||
1904  SettingsCompare(&s1->AnalogSettings_Sub19,&s2->AnalogSettings_Sub19) ||
1905  (1 != 1));
1906 }
1907 /* END App1. */
1908 /*!
1909 ** @}
1910 */
1911 /*
1912 ** ###################################################################
1913 **
1914 ** This file was created by Processor Expert 10.5 [05.21]
1915 ** for the Freescale Kinetis series of microcontrollers.
1916 **
1917 ** ###################################################################
1918 */
DATA_TYPE_SUB7 rawAccelerometerData_Sub7[DATA_FIFO_LEN_SUB7]
Definition: App1_types.h:168
#define DATA_FIFO_LEN_SUB8
Definition: App1_types.h:90
struct App1AppInstance_t::@1 info
uint16 processedDataBufferOffset
Definition: App1.c:353
SensorInfo_t PressureInfo_Sub12
Definition: App1_types.h:242
isf_fifo_t GyrometerDataFifo_Sub11
Definition: App1_types.h:264
ISF board support header files.
#define App1_Pedometer16_DATA_READY_EVENT
Definition: App1_types.h:149
unsigned char uint8
Definition: isf_types.h:76
#define App1_ALL_SENSOR_DATA_READY
Definition: App1_types.h:157
The isf_sensor_configuration_extern.h contains external declarations referenced by the Sensor Manager...
isf_SensorHandle_t smAdapterHandle
Definition: App1_types.h:193
DATA_TYPE_SUB1 rawAccelerometerData_Sub1[DATA_FIFO_LEN_SUB1]
Definition: App1_types.h:162
SensorInfo_t GyrometerInfo_Sub10
Definition: App1_types.h:240
int32 stop_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
#define App1_Accelerometer2_DATA_READY_EVENT
Definition: App1_types.h:121
isf_SubscriptionSettings_t AccelerometerSettings_Sub7
Definition: App1_types.h:207
#define CI_MAX_FLASH_BYTES
Definition: isf_ci.h:180
ISF Application Type for Embedded Application.
Definition: isf.h:55
isf_SubscriptionSettings_t PressureSettings_Sub12
Definition: App1_types.h:212
The isf_magnetometer_types.h file contains the ISF data type definitions for use with the ISF generic...
semaphore_t outputBufferLock
Definition: App1_types.h:227
SensorInfo_t AccelerometerInfo_Sub4
Definition: App1_types.h:234
DATA_TYPE_SUB6 rawAccelerometerData_Sub6[DATA_FIFO_LEN_SUB6]
Definition: App1_types.h:167
This is user's event module. Put your event handler code here.
uint8 control
Definition: App1.c:340
void App1_init(void)
Definition: App1.c:397
ISF Command Interpreter (CI) stream protocol header file.
void isf_system_sync(void)
This function synchronizes the user tasks and the system initialization.
Definition: isf_init.c:50
App1AppInstance_t App1AppInstance
Definition: App1.c:300
#define App1_TASK_NAME
Definition: App1.c:236
void App1_MainTask(void)
Definition: App1.c:426
isf_fifo_status_t isf_fifo_lock(isf_fifo_t *pFifo)
Lock a sample buffer for exclusive access.
Definition: isf_fifo.c:170
SensorInfo_t MagnetometerInfo_Sub9
Definition: App1_types.h:239
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
DATA_TYPE_SUB18 rawCustomData_Sub18[DATA_FIFO_LEN_SUB18]
Definition: App1_types.h:179
#define DATA_TYPE_SUB8
Definition: App1_types.h:91
ci_response_t App1_ci_app_callback(ci_host_cmd_packet_t *pHostPacket, ci_app_resp_packet_t *pAppPacket)
Definition: App1.c:1067
#define DATA_FIFO_LEN_SUB14
Definition: App1_types.h:102
const isf_dsa_Adapter_t * pAdapter
#define App1_Accelerometer5_DATA_READY_EVENT
Definition: App1_types.h:127
DATA_TYPE_SUB19 rawAnalogData_Sub19[DATA_FIFO_LEN_SUB19]
Definition: App1_types.h:180
#define App1_Gyrometer11_DATA_READY_EVENT
Definition: App1_types.h:139
#define CTRL_POWER_MASK
Definition: App1.c:290
#define App1_Gyrometer10_DATA_READY_EVENT
Definition: App1_types.h:137
#define SET_FIELD(name, val)
Macro that extracts one of the fields below.
Definition: App1.c:280
#define DATA_FIFO_LEN_SUB5
Definition: App1_types.h:84
SensorInfo_t AccelerometerInfo_Sub3
Definition: App1_types.h:233
SensorInfo_t AltitudeInfo_Sub15
Definition: App1_types.h:245
#define DATA_FIFO_LEN_SUB18
Definition: App1_types.h:110
DATA_TYPE_SUB8 rawMagnetometerData_Sub8[DATA_FIFO_LEN_SUB8]
Definition: App1_types.h:169
DATA_TYPE_SUB4 rawAccelerometerData_Sub4[DATA_FIFO_LEN_SUB4]
Definition: App1_types.h:165
SensorInfo_t AccelerometerInfo_Sub7
Definition: App1_types.h:237
SensorInfo_t AccelerometerInfo_Sub2
Definition: App1_types.h:232
#define App1_Accelerometer0_DATA_READY_EVENT
Definition: App1_types.h:117
This defines the DSA sensor device handle structure used to invoke the adapter access functions...
isf_fifo_t AccelerometerDataFifo_Sub1
Definition: App1_types.h:254
isf_fifo_status_t isf_fifo_el_clear(isf_fifo_t *pFifo)
Routine to clear the fifo.
Definition: isf_fifo.c:217
isf_fifo_t AltitudeDataFifo_Sub15
Definition: App1_types.h:268
#define App1_Custom18_DATA_READY_EVENT
Definition: App1_types.h:153
isf_dsa_result_types_t resultFormat
The format of the data to be returned- 0=RAW, 1=FIXED, 2=FLOAT.
#define DATA_TYPE_SUB19
Definition: App1_types.h:113
#define DATA_TYPE_SUB15
Definition: App1_types.h:105
isf_dsa_ControlInterface_t control
isf_SubscriptionSettings_t AnalogSettings_Sub19
Definition: App1_types.h:219
DATA_TYPE_SUB16 rawPedometerData_Sub16[DATA_FIFO_LEN_SUB16]
Definition: App1_types.h:177
isf_SubscriptionSettings_t OrientationSettings_Sub14
Definition: App1_types.h:214
#define DATA_TYPE_SUB0
Definition: App1_types.h:75
#define App1_Accelerometer3_DATA_READY_EVENT
Definition: App1_types.h:123
#define DATA_FIFO_LEN_SUB10
Definition: App1_types.h:94
#define DATA_TYPE_SUB17
Definition: App1_types.h:109
DATA_TYPE_SUB11 rawGyrometerData_Sub11[DATA_FIFO_LEN_SUB11]
Definition: App1_types.h:172
The isf_sensor_configuration.h contains the enumerated list of Digital Sensor Abstraction (DSA) senso...
isf_dsa_status_t(* Flash)(isf_SensorHandle_t *pSensorHandle, void *pFlashData, uint8 numBytes)
This is user's event module. Put your event handler code here.
#define startof(type, member)
Definition: App1.c:274
uint8 sensorId
Definition: App1_types.h:194
#define DATA_TYPE_SUB2
Definition: App1_types.h:79
isf_fifo_t AccelerometerDataFifo_Sub5
Definition: App1_types.h:258
isf_fifo_t AccelerometerDataFifo_Sub7
Definition: App1_types.h:260
int32 App1_GotoState(uint8 desiredState)
Definition: App1.c:1612
void App1_ProcessData(void *pProcessedDataBuffer, int32_t signalledEvents)
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.
#define App1_Pedometer17_DATA_READY_EVENT
Definition: App1_types.h:151
uint8 appType
ISF Embedded Application type.
Definition: App1_types.h:20
DATA_TYPE_SUB10 rawGyrometerData_Sub10[DATA_FIFO_LEN_SUB10]
Definition: App1_types.h:171
#define App1_APP_DATA
Definition: App1_types.h:9
SensorInfo_t AccelerometerInfo_Sub6
Definition: App1_types.h:236
isf_fifo_t AccelerometerDataFifo_Sub2
Definition: App1_types.h:255
#define DATA_TYPE_SUB13
Definition: App1_types.h:101
#define NUM_SENSORS
Macro thats holds number of active sensors.
Definition: App1.c:277
uint8 nFifoDepth
1 = no FIFO, or another value < SM_MAX_FIFO_DEPTH
#define App1_TASK_STACK_SIZE
Definition: App1.c:238
isf_fifo_t AccelerometerDataFifo_Sub4
Definition: App1_types.h:257
DATA_TYPE_SUB12 rawPressureData_Sub12[DATA_FIFO_LEN_SUB12]
Definition: App1_types.h:173
isf_SubscriptionSettings_t AccelerometerSettings_Sub1
Definition: App1_types.h:201
isf_pm.h describes the API definitions, types, and macros for the Intelligent Sensing Framework (ISF)...
The isf_types.h file contains the ISF data type definitions and some of the globally used macros...
DATA_TYPE_SUB0 rawAccelerometerData_Sub0[DATA_FIFO_LEN_SUB0]
Definition: App1_types.h:161
isf_SubscriptionSettings_t AccelerometerSettings_Sub5
Definition: App1_types.h:205
The isf_pressure_types.h file contains the ISF data type definitions for use with the ISF generic pre...
void App1_ReturnSensorsToInit()
Definition: App1.c:1375
SensorInfo_t GyrometerInfo_Sub11
Definition: App1_types.h:241
uint8 gNumSupportedSensors
This is the external declaration of the current number of available sensors.
#define DATA_FIFO_LEN_SUB12
Definition: App1_types.h:98
isf_SubscriptionSettings_t AccelerometerSettings_Sub2
Definition: App1_types.h:202
isf_fifo_t PressureDataFifo_Sub12
Definition: App1_types.h:265
isf_SubscriptionSettings_t MagnetometerSettings_Sub9
Definition: App1_types.h:209
#define DATA_TYPE_SUB18
Definition: App1_types.h:111
isf_fifo_t GyrometerDataFifo_Sub10
Definition: App1_types.h:263
SensorInfo_t OrientationInfo_Sub14
Definition: App1_types.h:244
The isf_gyrometer_types.h file contains the ISF data type definitions for use with the ISF generic gy...
#define DATA_TYPE_SUB11
Definition: App1_types.h:97
App1AppSettings_t settings
Definition: App1_types.h:251
isf_SubscriptionSettings_t PedometerSettings_Sub16
Definition: App1_types.h:216
task_param_t os_task_param_t
Definition: mqx_ksdk.h:354
App1SensorData_t data
Definition: App1_types.h:274
This structure holds the ISF application subscriptions information in the "GET_APP_SUBSCRIPTION" CI c...
Definition: App1.c:351
isf_fifo_t MagnetometerDataFifo_Sub8
Definition: App1_types.h:261
uint32 isf_fifo_status_t
Definition: isf_fifo.h:16
#define DATA_FIFO_LEN_SUB17
Definition: App1_types.h:108
void App1_Initialization()
DATA_TYPE_SUB5 rawAccelerometerData_Sub5[DATA_FIFO_LEN_SUB5]
Definition: App1_types.h:166
isf_SubscriptionSettings_t AccelerometerSettings_Sub4
Definition: App1_types.h:204
The isf_util.h file contains the utility method declarations and macros.
enum isf_dsa_result_enums isf_dsa_result_types_t
int32 configure_sensor(isf_SensorHandle_t *pSensorAdapterHandle, isf_SubscriptionSettings_t *pRequiredSettings, isf_fifo_t *pfifo)
SensorInfo_t TemperatureInfo_Sub13
Definition: App1_types.h:243
#define DATA_FIFO_LEN_SUB7
Definition: App1_types.h:88
#define DATA_FIFO_LEN_SUB6
Definition: App1_types.h:86
#define DATA_TYPE_SUB10
Definition: App1_types.h:95
isf_status_t isf_lib_init(void *pNull)
API to get ISF information.
Definition: isf_init.c:18
SensorInfo_t AnalogInfo_Sub19
Definition: App1_types.h:249
int32 start_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
isf_fifo_t TemperatureDataFifo_Sub13
Definition: App1_types.h:266
#define DATA_TYPE_SUB7
Definition: App1_types.h:89
#define DATA_FIFO_LEN_SUB15
Definition: App1_types.h:104
#define DATA_FIFO_LEN_SUB16
Definition: App1_types.h:106
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
struct App1AppInstance_t::@0 instance
isf_SensorDataTypes_t sensorDataType
Definition: App1.c:332
#define App1_Orientation14_DATA_READY_EVENT
Definition: App1_types.h:145
uint32 isf_ci_app_read(uint8 aAppId, uint32 anumBytes, uint8 *apDst)
This API reads data from the host via the mailboxes.
uint32 isf_ci_app_write(uint8 aAppId, uint32 anumBytes, uint8 *apSrc)
This API writes data to the host via the mailboxes.
This structure holds the sensor subscriptions configuration info.
Definition: App1.c:330
isf_fifo_t PedometerDataFifo_Sub17
Definition: App1_types.h:270
SensorInfo_t AccelerometerInfo_Sub0
Definition: App1_types.h:230
#define App1_Accelerometer6_DATA_READY_EVENT
Definition: App1_types.h:129
#define DATA_FIFO_LEN_SUB0
Definition: App1_types.h:74
isf_SensorDataTypes_t
isf_SubscriptionSettings_t AccelerometerSettings_Sub0
Definition: App1_types.h:200
#define App1_Altitude15_DATA_READY_EVENT
Definition: App1_types.h:147
This is user's event module. Put your event handler code here.
The isf_altitude_types.h file contains the ISF data type definitions for use with the ISF generic alt...
The isf_temperature_fixed_t.h file contains the ISF data type definitions for use with the ISF generi...
DATA_TYPE_SUB14 rawOrientationData_Sub14[DATA_FIFO_LEN_SUB14]
Definition: App1_types.h:175
#define App1_Temperature13_DATA_READY_EVENT
Definition: App1_types.h:143
#define DATA_FIFO_LEN_SUB19
Definition: App1_types.h:112
const isf_SensorConfig_t * pSensorStaticConfig
DATA_TYPE_SUB2 rawAccelerometerData_Sub2[DATA_FIFO_LEN_SUB2]
Definition: App1_types.h:163
isf_SensorDataTypes_t resultType
The desired data type of the subscription.
uint16 sampleRateOffset
Definition: App1.c:334
#define DATA_FIFO_LEN_SUB11
Definition: App1_types.h:96
SensorInfo_t AccelerometerInfo_Sub5
Definition: App1_types.h:235
Main ISF header file. Contains code common to all ISF components.
isf_SubscriptionSettings_t AccelerometerSettings_Sub3
Definition: App1_types.h:203
#define App1_Magnetometer9_DATA_READY_EVENT
Definition: App1_types.h:135
isf_dsa_AdapterStatus_t adapterStatus
signed long int int32
Definition: isf_types.h:74
unsigned short int uint16
Definition: isf_types.h:77
#define DATA_FIFO_LEN_SUB13
Definition: App1_types.h:100
struct App1AppInstance_t::@2 fifos
#define App1_Accelerometer7_DATA_READY_EVENT
Definition: App1_types.h:131
isf_fifo_t CustomDataFifo_Sub18
Definition: App1_types.h:271
isf_fifo_t AccelerometerDataFifo_Sub0
Definition: App1_types.h:253
uint8 nSettingsToUse
1 = current; 2=given; 3=best possible
#define DATA_TYPE_SUB3
Definition: App1_types.h:81
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Command Interpreter (C...
uint32 nSamplePeriod
Sample period in microseconds.
ci_status_t isf_ci_qr_update(uint8 aAppId, int8 anumBytes, uint8 *apSrc)
This API updates the Quick-Read mailboxes.
The isf_init.h file contains the task initialization attributes required for initialization of the fo...
#define App1_Accelerometer1_DATA_READY_EVENT
Definition: App1_types.h:119
isf_fifo_t MagnetometerDataFifo_Sub9
Definition: App1_types.h:262
#define CTRL_STATE_MASK
Control register mask/shift definitions for the application.
Definition: App1.c:284
#define GET_FIELD(name, val)
Definition: App1.c:281
isf_SubscriptionSettings_t AccelerometerSettings_Sub6
Definition: App1_types.h:206
isf_SubscriptionSettings_t MagnetometerSettings_Sub8
Definition: App1_types.h:208
This structure enables an application to read from or write to the host.
Definition: isf_ci.h:221
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
void App1_task(os_task_param_t task_init_data)
Definition: App1.c:378
#define DATA_TYPE_SUB16
Definition: App1_types.h:107
#define App1_Analog19_DATA_READY_EVENT
Definition: App1_types.h:155
isf_SubscriptionSettings_t GyrometerSettings_Sub10
Definition: App1_types.h:210
#define App1_Pressure12_DATA_READY_EVENT
Definition: App1_types.h:141
isf_fifo_t AccelerometerDataFifo_Sub6
Definition: App1_types.h:259
isf_SubscriptionSettings_t PedometerSettings_Sub17
Definition: App1_types.h:217
#define DATA_FIFO_LEN_SUB1
Definition: App1_types.h:76
void App1_Exit()
isf_SubscriptionSettings_t AltitudeSettings_Sub15
Definition: App1_types.h:215
uint32 isf_swap4byte(uint32 n)
4 byte swapping method
Definition: isf_util.c:143
SensorInfo_t AccelerometerInfo_Sub1
Definition: App1_types.h:231
isf_fifo_t AccelerometerDataFifo_Sub3
Definition: App1_types.h:256
#define DATA_TYPE_SUB5
Definition: App1_types.h:85
#define DATA_TYPE_SUB6
Definition: App1_types.h:87
#define DATA_FIFO_LEN_SUB3
Definition: App1_types.h:80
isf_SubscriptionSettings_t GyrometerSettings_Sub11
Definition: App1_types.h:211
SensorInfo_t MagnetometerInfo_Sub8
Definition: App1_types.h:238
#define App1_Accelerometer4_DATA_READY_EVENT
Definition: App1_types.h:125
This structure contains host command information.
Definition: isf_ci.h:197
unsigned long int uint32
Definition: isf_types.h:78
DATA_TYPE_SUB9 rawMagnetometerData_Sub9[DATA_FIFO_LEN_SUB9]
Definition: App1_types.h:170
#define DATA_FIFO_LEN_SUB9
Definition: App1_types.h:92
This is user's event module. Put your event handler code here.
isf_SubscriptionSettings_t CustomSettings_Sub18
Definition: App1_types.h:218
DATA_TYPE_SUB17 rawPedometerData_Sub17[DATA_FIFO_LEN_SUB17]
Definition: App1_types.h:178
int32 shutdown_sensor(isf_SensorHandle_t *pSensorAdapterHandle)
DATA_TYPE_SUB13 rawTemperatureData_Sub13[DATA_FIFO_LEN_SUB13]
Definition: App1_types.h:174
isf_fifo_t OrientationDataFifo_Sub14
Definition: App1_types.h:267
isf_fifo_t PedometerDataFifo_Sub16
Definition: App1_types.h:269
#define DATA_FIFO_LEN_SUB4
Definition: App1_types.h:82
isf_fifo_t AnalogDataFifo_Sub19
Definition: App1_types.h:272
#define App1_TASK_PRIORITY
Definition: App1.c:240
SensorInfo_t CustomInfo_Sub18
Definition: App1_types.h:248
#define DATA_TYPE_SUB14
Definition: App1_types.h:103
The isf_sm_types.h contains the collection of type definitions used in the Sensor Manager Interface a...
isf_SensorHandle_t * gSensorHandleList[]
This is the external declaration of the DSA sensor handle list array containing the sensor adapters a...
ci_response_enum
These are the CI errors provided to the host.
Definition: isf_ci.h:119
The isf_accelerometer_types.h file contains the ISF data type definitions for use with the ISF generi...
SensorInfo_t PedometerInfo_Sub17
Definition: App1_types.h:247
isf_status_t isf_ci_stream_update_data(uint8 aDataSetID, uint16 aLength, uint16 aOffset, uint8 *apSrc)
This API updates the data of a dataset.
#define DATA_FIFO_LEN_SUB2
Definition: App1_types.h:78
DATA_TYPE_SUB15 rawAltitudeData_Sub15[DATA_FIFO_LEN_SUB15]
Definition: App1_types.h:176
DATA_TYPE_SUB3 rawAccelerometerData_Sub3[DATA_FIFO_LEN_SUB3]
Definition: App1_types.h:164
#define DATA_TYPE_SUB4
Definition: App1_types.h:83
#define DATA_TYPE_SUB9
Definition: App1_types.h:93
isf_SubscriptionSettings_t TemperatureSettings_Sub13
Definition: App1_types.h:213
OSA_TASK_DEFINE(App1, App1_TASK_STACK_SIZE)
#define DATA_TYPE_SUB12
Definition: App1_types.h:99
isf_fifo_status_t isf_fifo_el_traverse(isf_fifo_t *pFifo, void **pSamplePtr)
Routine to traverse a fifo To initiate the traversal set pSamplePtr to NULL. The function will set th...
Definition: isf_fifo.c:259
SensorInfo_t PedometerInfo_Sub16
Definition: App1_types.h:246
#define DATA_TYPE_SUB1
Definition: App1_types.h:77
isf_dsa_result_types_t sensorResultType
Definition: App1.c:333
#define App1_Magnetometer8_DATA_READY_EVENT
Definition: App1_types.h:133
signed char int8
Definition: isf_types.h:72