ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
BasicApp1_Functions.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** Filename : BasicApp1_Functions.c
3 ** Project : ISF2P2_K64F_MQX_PROJ
4 ** Processor : MK64FN1M0VLL12
5 ** Component : Events
6 ** Version : Driver 01.00
7 ** Compiler : GNU C Compiler
8 ** Date/Time : 2016-10-06, 13:38, # CodeGen: 0
9 ** Abstract :
10 ** This is user's event module.
11 ** Put your event handler code here.
12 ** Settings :
13 ** Contents :
14 ** BasicApp1_Initialization - void BasicApp1_Initialization(void);
15 ** BasicApp1_CI_Callback - void BasicApp1_CI_Callback(void);
16 ** BasicApp1_OnAnySensor_Data_Ready - void BasicApp1_OnAnySensor_Data_Ready(void);
17 **
18 ** ###################################################################*/
19 /*!
20 ** @file BasicApp1_Functions.c
21 ** @version 01.00
22 ** @brief
23 ** This is user's event module.
24 ** Put your event handler code here.
25 */
26 /*!
27 ** @addtogroup BasicApp1_Functions_module BasicApp1_Functions module documentation
28 ** @{
29 */
30 /* MODULE BasicApp1_Functions */
31 
32 #include "Cpu.h"
33 #include "Events.h"
34 #include "rtos_main_task.h"
35 #include "os_tasks.h"
36 #include "App1_Functions.h"
37 #include "BasicApp1_Functions.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 
46 /* User includes (#include below this line is not maintained by Processor Expert) */
47 
48 /*
49 ** ===================================================================
50 ** Event : BasicApp1_Initialization (module BasicApp1_Functions)
51 **
52 ** Component : BasicApp1 [ISF_KSDK_BasicApp]
53 ** @brief
54 ** Parameters :
55 ** NAME - DESCRIPTION
56 ** @return
57 ** Returns : Nothing
58 ** ===================================================================
59 */
61 {
62 /******Write your code here*******/
63 }
64 #include "BasicApp1_types.h"
65 
66 
67 /* App Info Structure returned by the CI_CMD_READ_APP_VERSION command */
68 static const BasicApp1_app_info_t gsBasicApp1_AppInfo = {
70  .version_info = 0x0100,
71  .numBytes = sizeof(BasicApp1_APP_DATA),
72  .appData = BasicApp1_APP_DATA
73 };
74 
75 /*
76 ** ===================================================================
77 ** Event : BasicApp1_CI_Callback (module BasicApp1_Functions)
78 **
79 ** Component : BasicApp1 [ISF_KSDK_BasicApp]
80 ** @brief
81 **
82 ** Parameters :
83 ** NAME - DESCRIPTION
84 ** @param
85 ** void* p_HostPacket -
86 ** @param
87 ** void* p_AppPacket -
88 ** @param
89 ** uint8_t response -
90 ** @return
91 ** Returns : Nothing
92 ** ===================================================================
93 */
94 void BasicApp1_CI_Callback(void* p_HostPacket, void* p_AppPacket, uint8_t *response)
95 {
96  ci_host_cmd_packet_t *pHostPacket = p_HostPacket;
97  ci_app_resp_packet_t *pAppPacket = p_AppPacket;
98 
99  // Helper pointers to application configuration and data structures.
102 
103  // Handle each valid host command.
104  switch(pHostPacket->cmd) {
105 
106  // Read data from the host output buffer.
108  // Check if the command accesses bytes outside the valid range.
109  if (pHostPacket->byte_cnt > sizeof(gBasicApp1DataBuffers.outputData))
110  {
111  *response = CI_INVALID_COUNT;
112  }
113  if (pHostPacket->offset + pHostPacket->byte_cnt >
115  {
116  *response = CI_ERROR_COMMAND;
117  }
118  // Lock the output buffer, update the data to the CI, then unlock the buffer.
119  OSA_SemaWait(&gBasicApp1DataBuffers.outputDataLock, OSA_WAIT_FOREVER);
120  pAppPacket->bytes_xfer = isf_ci_app_write(pHostPacket->appId,
121  pHostPacket->byte_cnt, (uint8*)pData + pHostPacket->offset);
122  OSA_SemaPost(&gBasicApp1DataBuffers.outputDataLock);
123  break;
124 
125  // Read or write the application configuration structure.
126  case CI_CMD_READ_CONFIG:
127  // Fall through
128 
129  case CI_CMD_WRITE_CONFIG:
130  // Check if the command accesses bytes outside the valid range.
131  if (pHostPacket->byte_cnt > sizeof(*gBasicApp1DataBuffers.configData))
132  *response = CI_INVALID_COUNT;
133  if (pHostPacket->offset + pHostPacket->byte_cnt >
135  *response = CI_ERROR_COMMAND;
136  if (CI_CMD_READ_CONFIG == pHostPacket->cmd)
137  {
138  // Write the requested (READ) information to the host interface.
139  pAppPacket->bytes_xfer = (uint8)isf_ci_app_write
140  (pHostPacket->appId, (uint32)pHostPacket->byte_cnt,
141  pConfig + pHostPacket->offset);
142  }
143  else
144  {
145  // Read the new data from the host.
146  pAppPacket->bytes_xfer = (uint8)isf_ci_app_read
147  (pHostPacket->appId, (uint32)pHostPacket->byte_cnt,
148  pConfig + pHostPacket->offset);
149  /******Write your code here*******/
150  }
151  break;
152  // Host writing SREC FLASH Bytes.
154  // Check if the command accesses bytes outside the valid range.
155  if (pHostPacket->byte_cnt > CI_MAX_FLASH_BYTES)
156  *response = CI_INVALID_COUNT;
157 
158  // Call f/n to send command to target Sensor.
159  {
160  uint8 pData[CI_MAX_FLASH_BYTES];
161 
162  pAppPacket->bytes_xfer = (uint8)isf_ci_app_read(pHostPacket->appId, (uint32)pHostPacket->byte_cnt, pData);
163  if(0 != BasicApp1_FlashSensor(pHostPacket->byte_cnt, pData))
164  *response = CI_ERROR_COMMAND;
165  }
166 
167  // Read ISF Embedded Application Version Info.
168  case CI_CMD_READ_VERSION:
169  // Write the ISF Application information to the host interface.
170  pAppPacket->bytes_xfer = isf_ci_app_write(pHostPacket->appId, sizeof(gsBasicApp1_AppInfo), (uint8*)&gsBasicApp1_AppInfo);
171  break;
172 
173  default:
174  *response = CI_ERROR_COMMAND;
175  break;
176  }
177 
178  *response = CI_ERROR_NONE;
179 }
180 
181 /*
182 ** ===================================================================
183 ** Event : BasicApp1_OnAnySensor_Data_Ready (module BasicApp1_Functions)
184 **
185 ** Component : BasicApp1 [ISF_KSDK_BasicApp]
186 ** @brief
187 **
188 ** Parameters :
189 ** NAME - DESCRIPTION
190 ** @param
191 ** uint8_t sensorIdx -
192 ** @param
193 ** uint32_t signalledEvents -
194 ** @param
195 ** void* pAppSensorData -
196 ** @param
197 ** void* pAppDataBuffers -
198 ** @return
199 ** Returns : Nothing
200 ** ===================================================================
201 */
202 void BasicApp1_OnAnySensor_Data_Ready(uint8_t sensorIdx, uint32_t signalledEvents, void* *pAppSensorData, void* pAppDataBuffers)
203 {
204  DATA_TYPE_SUB0 *rawAccelerometerData_Sub0 = (DATA_TYPE_SUB0 *) pSensorData[0];
205  DATA_TYPE_SUB1 *rawAccelerometerData_Sub1 = (DATA_TYPE_SUB1 *) pSensorData[1];
206  DATA_TYPE_SUB2 *rawAccelerometerData_Sub2 = (DATA_TYPE_SUB2 *) pSensorData[2];
207  DATA_TYPE_SUB3 *rawAccelerometerData_Sub3 = (DATA_TYPE_SUB3 *) pSensorData[3];
208  DATA_TYPE_SUB4 *rawAccelerometerData_Sub4 = (DATA_TYPE_SUB4 *) pSensorData[4];
209  DATA_TYPE_SUB5 *rawAccelerometerData_Sub5 = (DATA_TYPE_SUB5 *) pSensorData[5];
210  DATA_TYPE_SUB6 *rawAccelerometerData_Sub6 = (DATA_TYPE_SUB6 *) pSensorData[6];
211  DATA_TYPE_SUB7 *rawAccelerometerData_Sub7 = (DATA_TYPE_SUB7 *) pSensorData[7];
212  DATA_TYPE_SUB8 *rawMagnetometerData_Sub8 = (DATA_TYPE_SUB8 *) pSensorData[8];
213  DATA_TYPE_SUB9 *rawMagnetometerData_Sub9 = (DATA_TYPE_SUB9 *) pSensorData[9];
214  DATA_TYPE_SUB10 *rawGyrometerData_Sub10 = (DATA_TYPE_SUB10 *) pSensorData[10];
215  DATA_TYPE_SUB11 *rawGyrometerData_Sub11 = (DATA_TYPE_SUB11 *) pSensorData[11];
216  DATA_TYPE_SUB12 *rawPressureData_Sub12 = (DATA_TYPE_SUB12 *) pSensorData[12];
217  DATA_TYPE_SUB13 *rawTemperatureData_Sub13 = (DATA_TYPE_SUB13 *) pSensorData[13];
218  DATA_TYPE_SUB14 *rawOrientationData_Sub14 = (DATA_TYPE_SUB14 *) pSensorData[14];
219  DATA_TYPE_SUB15 *rawAltitudeData_Sub15 = (DATA_TYPE_SUB15 *) pSensorData[15];
220  DATA_TYPE_SUB16 *rawPedometerData_Sub16 = (DATA_TYPE_SUB16 *) pSensorData[16];
221  DATA_TYPE_SUB17 *rawPedometerData_Sub17 = (DATA_TYPE_SUB17 *) pSensorData[17];
222  DATA_TYPE_SUB18 *rawCustomData_Sub18 = (DATA_TYPE_SUB18 *) pSensorData[18];
223  DATA_TYPE_SUB19 *rawAnalogData_Sub19 = (DATA_TYPE_SUB19 *) pSensorData[19];
224 
225  switch(sensorIdx)
226  {
228  /****** Write your code here *******/
229  /****** To preserve user changes, code in this file is not updated during code re-generation. */
230  /****** Please compare your code with the sample code for this function provided in the templates file. */
231  break;
233  /****** Write your code here *******/
234  /****** To preserve user changes, code in this file is not updated during code re-generation. */
235  /****** Please compare your code with the sample code for this function provided in the templates file. */
236  break;
238  /****** Write your code here *******/
239  /****** To preserve user changes, code in this file is not updated during code re-generation. */
240  /****** Please compare your code with the sample code for this function provided in the templates file. */
241  break;
243  /****** Write your code here *******/
244  /****** To preserve user changes, code in this file is not updated during code re-generation. */
245  /****** Please compare your code with the sample code for this function provided in the templates file. */
246  break;
248  /****** Write your code here *******/
249  /****** To preserve user changes, code in this file is not updated during code re-generation. */
250  /****** Please compare your code with the sample code for this function provided in the templates file. */
251  break;
253  /****** Write your code here *******/
254  /****** To preserve user changes, code in this file is not updated during code re-generation. */
255  /****** Please compare your code with the sample code for this function provided in the templates file. */
256  break;
258  /****** Write your code here *******/
259  /****** To preserve user changes, code in this file is not updated during code re-generation. */
260  /****** Please compare your code with the sample code for this function provided in the templates file. */
261  break;
263  /****** Write your code here *******/
264  /****** To preserve user changes, code in this file is not updated during code re-generation. */
265  /****** Please compare your code with the sample code for this function provided in the templates file. */
266  break;
268  /****** Write your code here *******/
269  /****** To preserve user changes, code in this file is not updated during code re-generation. */
270  /****** Please compare your code with the sample code for this function provided in the templates file. */
271  break;
273  /****** Write your code here *******/
274  /****** To preserve user changes, code in this file is not updated during code re-generation. */
275  /****** Please compare your code with the sample code for this function provided in the templates file. */
276  break;
278  /****** Write your code here *******/
279  /****** To preserve user changes, code in this file is not updated during code re-generation. */
280  /****** Please compare your code with the sample code for this function provided in the templates file. */
281  break;
283  /****** Write your code here *******/
284  /****** To preserve user changes, code in this file is not updated during code re-generation. */
285  /****** Please compare your code with the sample code for this function provided in the templates file. */
286  break;
288  /****** Write your code here *******/
289  /****** To preserve user changes, code in this file is not updated during code re-generation. */
290  /****** Please compare your code with the sample code for this function provided in the templates file. */
291  break;
293  /****** Write your code here *******/
294  /****** To preserve user changes, code in this file is not updated during code re-generation. */
295  /****** Please compare your code with the sample code for this function provided in the templates file. */
296  break;
298  /****** Write your code here *******/
299  /****** To preserve user changes, code in this file is not updated during code re-generation. */
300  /****** Please compare your code with the sample code for this function provided in the templates file. */
301  break;
303  /****** Write your code here *******/
304  /****** To preserve user changes, code in this file is not updated during code re-generation. */
305  /****** Please compare your code with the sample code for this function provided in the templates file. */
306  break;
308  /****** Write your code here *******/
309  /****** To preserve user changes, code in this file is not updated during code re-generation. */
310  /****** Please compare your code with the sample code for this function provided in the templates file. */
311  break;
313  /****** Write your code here *******/
314  /****** To preserve user changes, code in this file is not updated during code re-generation. */
315  /****** Please compare your code with the sample code for this function provided in the templates file. */
316  break;
317  case SENSOR_IDX_Custom18:
318  /****** Write your code here *******/
319  /****** To preserve user changes, code in this file is not updated during code re-generation. */
320  /****** Please compare your code with the sample code for this function provided in the templates file. */
321  break;
322  case SENSOR_IDX_Analog19:
323  /****** Write your code here *******/
324  /****** To preserve user changes, code in this file is not updated during code re-generation. */
325  /****** Please compare your code with the sample code for this function provided in the templates file. */
326  break;
327  default:
328  break;
329  }
330 }
331 
332 /* END BasicApp1_Functions */
333 
334 #ifdef __cplusplus
335 } /* extern "C" */
336 #endif
337 
338 /*!
339 ** @}
340 */
341 /*
342 ** ###################################################################
343 **
344 ** This file was created by Processor Expert 10.5 [05.21]
345 ** for the Freescale Kinetis series of microcontrollers.
346 **
347 ** ###################################################################
348 */
#define SENSOR_IDX_Custom18
unsigned char uint8
Definition: isf_types.h:76
#define SENSOR_IDX_Accelerometer0
#define SENSOR_IDX_Magnetometer8
#define CI_MAX_FLASH_BYTES
Definition: isf_ci.h:180
This is user's event module. Put your event handler code here.
#define DATA_TYPE_SUB8
Definition: App1_types.h:91
#define SENSOR_IDX_Analog19
void BasicApp1_Initialization()
#define DATA_TYPE_SUB19
Definition: App1_types.h:113
#define DATA_TYPE_SUB15
Definition: App1_types.h:105
#define DATA_TYPE_SUB0
Definition: App1_types.h:75
#define SENSOR_IDX_Pedometer16
#define SENSOR_IDX_Accelerometer4
#define DATA_TYPE_SUB17
Definition: App1_types.h:109
void * pSensorData[]
Definition: BasicApp1.c:408
This is user's event module. Put your event handler code here.
#define DATA_TYPE_SUB2
Definition: App1_types.h:79
#define DATA_TYPE_SUB13
Definition: App1_types.h:101
#define SENSOR_IDX_Magnetometer9
int8 BasicApp1_FlashSensor(uint8 numBytes, uint8 *pFlashData)
Definition: BasicApp1.c:711
#define SENSOR_IDX_Temperature13
#define DATA_TYPE_SUB18
Definition: App1_types.h:111
#define DATA_TYPE_SUB11
Definition: App1_types.h:97
BasicApp1DataBuffers_t gBasicApp1DataBuffers
Definition: BasicApp1.c:260
void BasicApp1_CI_Callback(void *p_HostPacket, void *p_AppPacket, uint8_t *response)
#define SENSOR_IDX_Accelerometer2
#define SENSOR_IDX_Pedometer17
#define DATA_TYPE_SUB10
Definition: App1_types.h:95
#define DATA_TYPE_SUB7
Definition: App1_types.h:89
#define SENSOR_IDX_Accelerometer7
#define SENSOR_IDX_Pressure12
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 is user's event module. Put your event handler code here.
#define SENSOR_IDX_Accelerometer6
#define SENSOR_IDX_Orientation14
#define DATA_TYPE_SUB3
Definition: App1_types.h:81
This structure enables an application to read from or write to the host.
Definition: isf_ci.h:221
#define DATA_TYPE_SUB16
Definition: App1_types.h:107
This is user's event module. Put your event handler code here.
#define SENSOR_IDX_Accelerometer5
#define DATA_TYPE_SUB5
Definition: App1_types.h:85
#define DATA_TYPE_SUB6
Definition: App1_types.h:87
uint8 appType
ISF Embedded Application type.
This structure contains host command information.
Definition: isf_ci.h:197
unsigned long int uint32
Definition: isf_types.h:78
This is user's event module. Put your event handler code here.
#define BasicApp1_APP_DATA
#define SENSOR_IDX_Accelerometer3
#define DATA_TYPE_SUB14
Definition: App1_types.h:103
#define SENSOR_IDX_Gyrometer10
#define SENSOR_IDX_Altitude15
void BasicApp1_OnAnySensor_Data_Ready(uint8_t sensorIdx, uint32_t signalledEvents, void **pAppSensorData, void *pAppDataBuffers)
ISF Application Type for Basic Application.
Definition: isf.h:53
#define SENSOR_IDX_Accelerometer1
#define DATA_TYPE_SUB4
Definition: App1_types.h:83
#define DATA_TYPE_SUB9
Definition: App1_types.h:93
#define SENSOR_IDX_Gyrometer11
#define DATA_TYPE_SUB12
Definition: App1_types.h:99
#define DATA_TYPE_SUB1
Definition: App1_types.h:77