ISSDK  1.8
IoT Sensing Software Development Kit
auto_detection_service_kl25z.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file auto_detection_service_kl25z.c
11  * @brief The auto detection service file implements auto detection sequence
12  * for discovery of FRDM-KL25Z Board and Sensor Shield Board.
13  */
14 
15 #include <stdio.h>
16 #include <stdint.h>
17 
18 #include "diff_p.h"
19 #include "mma9553.h"
20 #include "mpl3115.h"
21 #include "mag3110.h"
22 #include "mma845x.h"
23 #include "mma865x.h"
24 #include "fxls8962.h"
25 #include "fxpq3115.h"
26 #include "fxos8700.h"
27 #include "mma8491q.h"
28 #include "fxas21002.h"
29 #include "fxlc95000.h"
30 #include "fxls8471q.h"
31 
32 #include "issdk_hal.h"
33 #include "gpio_driver.h"
34 #include "systick_utils.h"
35 #include "register_io_spi.h"
36 #include "register_io_i2c.h"
37 #include "auto_detection_shield.h"
38 #include "auto_detection_service.h"
39 
40 #include "fsl_flash.h"
41 
42 /*******************************************************************************
43  * Definitions
44  ******************************************************************************/
45 /*!
46 * @brief These variables are specific to SPI access to the FXLS8471 for ADS.
47 */
48 #define FXLS8471Q_SPI_CMD_LEN (2)
49 #define FXLS8471Q_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW
50 
51 /*!
52 * @brief These variables are specific to SPI access to the FXLS8962 for ADS.
53 */
54 #define FXLS8962_SPI_CMD_LEN (2)
55 #define FXLS8962_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW
56 
57 /*!
58 * @brief These variables are specific to SPI access to the DIFF_P for ADS.
59 */
60 #define DIFF_P_SPI_CMD_LEN (1)
61 #define DIFF_P_SS_ACTIVE_VALUE SPI_SS_ACTIVE_LOW
62 
63 /*!
64 * @brief These variables are specific to MMA8491Q which does not have a Who Am I register.
65 */
66 #define MMA8491Q_WHO_AM_I (MMA8491Q_STATUS)
67 #define MMA8491Q_WHO_AM_I_VALUE \
68  (MMA8491Q_STATUS_RESERVED_ZERO | MMA8491Q_STATUS_XDR_DRDY | MMA8491Q_STATUS_YDR_DRDY | MMA8491Q_STATUS_ZDR_DRDY | \
69  MMA8491Q_STATUS_ZYXDR_DRDY)
70 
71 #define ADS_QUERY_NUM (sizeof(ADS_SensorQueryList) / sizeof(sensorAccess_t))
72 #define ADS_NUM_BOARDS (sizeof(gADS_QueryMap) / ADS_QUERY_NUM)
73 #define SPI_MAX_MSG_SIZE (64)
74 
75 /*******************************************************************************
76 * Constants
77 ******************************************************************************/
78 /*! @brief The Read Version Info Command for FXLC95000. */
79 const uint8_t ReadVersionInfo_MMA9553[4] = {0x00, 0x00, 0x00, 0x0C};
80 
81 /*!
82 * @brief This constant data structure contains the expected valid MCU SDID combinations.
83 */
85  {0, 5, 1, 2, 2, ADS_RD_KL25_AGMP01}, // RD-KL25-AGMP01
86  {0, 5, 1, 2, 6, ADS_FRDM_KL25Z}, // FRDM-KL25Z
87  {0, 7, 1, 2, 5, ADS_FRDM_KL27Z}, // FRDM-KL27Z
88  {2, 2, 0, 1, 5, ADS_FRDM_K22F}, // FRDM-K22F
89  {6, 2, 0, 4, 8, ADS_FRDM_K64F}, // FRDM-K64F Note: SubFamily reads 2 instead of expected 4 (known errata)
90  {1, 5, 2, 0, 10, ADS_FRDM_KE15Z}, // FRDM-KE15Z
91  {0, 1, 5, 4, 4, ADS_FRDM_KW41Z}, // FRDM-KW41Z
92  //{0, 4, 5, 0, 8, ADS_FRDM_K32W042}, FRDM-K32W042
93 };
94 
95 /*!
96 * @brief This constant data structure contains the expected valid comm/sensor/who_am_i combinations.
97 */
101  {ADS_SPI_DEV, DIFF_P, DIFF_P_WHO_AM_I, DIFF_P_NPS3000VV_WHOAMI_VALUE, 0xFC},
111  {ADS_I2C_EXT, DIFF_P_I2C_ADDR, DIFF_P_WHO_AM_I, DIFF_P_NPS3000VV_WHOAMI_VALUE, 0xFC},
114 };
115 
116 /*!
117 * @brief These are the expected query signatures for the shield boards.
118 */
120  {
121  // FRDM-STBC-AGM01
122  ADS_FAIL, // FXLS8471
123  ADS_FAIL, // FXLS8962
124  ADS_FAIL, // DIFF-P
125  ADS_FAIL, // FXLS8962
126  ADS_OK, // FXAS21002
127  ADS_FAIL, // FXLC95000
128  ADS_OK, // FXOS8700
129  ADS_FAIL, // FXPQ3115
130  ADS_FAIL, // MAG3110
131  ADS_FAIL, // MMA8491
132  ADS_FAIL, // MMA865x
133  ADS_FAIL, // MMA9553
134  ADS_FAIL, // DIFF-P
135  ADS_FAIL, // MPL3115
136  ADS_NULL, // MMA845x
137  },
138  {
139  // FRDM-STBC-SA9500
140  ADS_FAIL, // FXLS8471
141  ADS_FAIL, // FXLS8962
142  ADS_FAIL, // DIFF-P
143  ADS_FAIL, // FXLS8962
144  ADS_FAIL, // FXAS21002
145  ADS_OK, // FXLC95000
146  ADS_FAIL, // FXOS8700
147  ADS_FAIL, // FXPQ3115
148  ADS_FAIL, // MAG3110
149  ADS_FAIL, // MMA8491
150  ADS_FAIL, // MMA865x
151  ADS_FAIL, // MMA9553
152  ADS_FAIL, // DIFF-P
153  ADS_FAIL, // MPL3115
154  ADS_NULL, // MMA845x
155  },
156  {
157  // FRDMSTBC-A8471
158  ADS_OK, // FXLS8471
159  ADS_FAIL, // FXLS8962
160  ADS_FAIL, // DIFF-P
161  ADS_FAIL, // FXLS8962
162  ADS_FAIL, // FXAS21002
163  ADS_FAIL, // FXLC95000
164  ADS_FAIL, // FXOS8700
165  ADS_FAIL, // FXPQ3115
166  ADS_FAIL, // MAG3110
167  ADS_FAIL, // MMA8491
168  ADS_FAIL, // MMA865x
169  ADS_FAIL, // MMA9553
170  ADS_FAIL, // DIFF-P
171  ADS_FAIL, // MPL3115
172  ADS_NULL, // MMA845x
173  },
174  {
175  // FRDMSTBC-A8491
176  ADS_FAIL, // FXLS8471
177  ADS_FAIL, // FXLS8962
178  ADS_FAIL, // DIFF-P
179  ADS_FAIL, // FXLS8962
180  ADS_FAIL, // FXAS21002
181  ADS_FAIL, // FXLC95000
182  ADS_FAIL, // FXOS8700
183  ADS_FAIL, // FXPQ3115
184  ADS_FAIL, // MAG3110
185  ADS_OK, // MMA8491
186  ADS_FAIL, // MMA865x
187  ADS_FAIL, // MMA9553
188  ADS_FAIL, // DIFF-P
189  ADS_FAIL, // MPL3115
190  ADS_NULL, // MMA845x
191  },
192  {
193  // FRDMSTBC-P3115
194  ADS_FAIL, // FXLS8471
195  ADS_FAIL, // FXLS8962
196  ADS_FAIL, // DIFF-P
197  ADS_FAIL, // FXLS8962
198  ADS_FAIL, // FXAS21002
199  ADS_FAIL, // FXLC95000
200  ADS_FAIL, // FXOS8700
201  ADS_FAIL, // FXPQ3115
202  ADS_FAIL, // MAG3110
203  ADS_FAIL, // MMA8491
204  ADS_FAIL, // MMA865x
205  ADS_FAIL, // MMA9553
206  ADS_FAIL, // DIFF-P
207  ADS_OK, // MPL3115
208  ADS_NULL, // MMA845x
209  },
210  {
211  // FRDMSTBC-DIFF-P SPI
212  ADS_FAIL, // FXLS8471
213  ADS_FAIL, // FXLS8962
214  ADS_OK, // DIFF-P
215  ADS_FAIL, // FXLS8962
216  ADS_FAIL, // FXAS21002
217  ADS_FAIL, // FXLC95000
218  ADS_FAIL, // FXOS8700
219  ADS_FAIL, // FXPQ3115
220  ADS_FAIL, // MAG3110
221  ADS_FAIL, // MMA8491
222  ADS_FAIL, // MMA865x
223  ADS_FAIL, // MMA9553
224  ADS_FAIL, // DIFF-P
225  ADS_FAIL, // MPL3115
226  ADS_NULL, // MMA845x
227  },
228  {
229  // FRDMSTBC-DIFF-P I2C
230  ADS_FAIL, // FXLS8471
231  ADS_FAIL, // FXLS8962
232  ADS_FAIL, // DIFF-P
233  ADS_FAIL, // FXLS8962
234  ADS_FAIL, // FXAS21002
235  ADS_FAIL, // FXLC95000
236  ADS_FAIL, // FXOS8700
237  ADS_FAIL, // FXPQ3115
238  ADS_FAIL, // MAG3110
239  ADS_FAIL, // MMA8491
240  ADS_FAIL, // MMA865x
241  ADS_FAIL, // MMA9553
242  ADS_OK, // DIFF-P
243  ADS_FAIL, // MPL3115
244  ADS_NULL, // MMA845x
245  },
246  {
247  // FRDMSTBC-B3115
248  ADS_FAIL, // FXLS8471
249  ADS_FAIL, // FXLS8962
250  ADS_FAIL, // DIFF-P
251  ADS_FAIL, // FXLS8962
252  ADS_FAIL, // FXAS21002
253  ADS_FAIL, // FXLC95000
254  ADS_FAIL, // FXOS8700
255  ADS_OK, // FXPQ3115
256  ADS_FAIL, // MAG3110
257  ADS_FAIL, // MMA8491
258  ADS_FAIL, // MMA865x
259  ADS_FAIL, // MMA9553
260  ADS_FAIL, // DIFF-P
261  ADS_FAIL, // MPL3115
262  ADS_NULL, // MMA845x
263  },
264  {
265  // FRDM-FXS-MULT2-B
266  ADS_OK, // FXLS8471
267  ADS_FAIL, // FXLS8962
268  ADS_FAIL, // DIFF-P
269  ADS_FAIL, // FXLS8962
270  ADS_OK, // FXAS21002
271  ADS_FAIL, // FXLC95000
272  ADS_OK, // FXOS8700
273  ADS_FAIL, // FXPQ3115
274  ADS_OK, // MAG3110
275  ADS_FAIL, // MMA8491
276  ADS_OK, // MMA865x
277  ADS_OK, // MMA9553
278  ADS_FAIL, // DIFF-P
279  ADS_OK, // MPL3115
280  ADS_NULL, // MMA845x
281  },
282  {
283  // FRDM-STBC-AGMP03 over SPI
284  ADS_FAIL, // FXLS8471
285  ADS_OK, // FXLS8962
286  ADS_FAIL, // DIFF-P
287  ADS_FAIL, // FXLS8962
288  ADS_FAIL, // FXAS21002
289  ADS_FAIL, // FXLC95000
290  ADS_FAIL, // FXOS8700
291  ADS_FAIL, // FXPQ3115
292  ADS_OK, // MAG3110
293  ADS_FAIL, // MMA8491
294  ADS_FAIL, // MMA865x
295  ADS_FAIL, // MMA9553
296  ADS_FAIL, // DIFF-P
297  ADS_OK, // MPL3115
298  ADS_NULL, // MMA845x
299  },
300  {
301  // FRDM-STBC-AGMP03 over I2C
302  ADS_FAIL, // FXLS8471
303  ADS_FAIL, // FXLS8962
304  ADS_FAIL, // DIFF-P
305  ADS_OK, // FXLS8962
306  ADS_OK, // FXAS21002
307  ADS_FAIL, // FXLC95000
308  ADS_FAIL, // FXOS8700
309  ADS_FAIL, // FXPQ3115
310  ADS_OK, // MAG3110
311  ADS_FAIL, // MMA8491
312  ADS_FAIL, // MMA865x
313  ADS_FAIL, // MMA9553
314  ADS_FAIL, // DIFF-P
315  ADS_OK, // MPL3115
316  ADS_NULL, // MMA845x
317  },
318  {
319  // FRDM-STBC-AGM04
320  ADS_FAIL, // FXLS8471
321  ADS_FAIL, // FXLS8962
322  ADS_FAIL, // DIFF-P
323  ADS_FAIL, // FXLS8962
324  ADS_OK, // FXAS21002
325  ADS_FAIL, // FXLC95000
326  ADS_FAIL, // FXOS8700
327  ADS_FAIL, // FXPQ3115
328  ADS_OK, // MAG3110
329  ADS_FAIL, // MMA8491
330  ADS_OK, // MMA865x
331  ADS_FAIL, // MMA9553
332  ADS_FAIL, // DIFF-P
333  ADS_FAIL, // MPL3115
334  ADS_NULL, // MMA845x
335  },
336  {
337  // ON BOARD SENSORS (MMA8451)
338  ADS_FAIL, // FXLS8471
339  ADS_FAIL, // FXLS8962
340  ADS_FAIL, // DIFF-P
341  ADS_FAIL, // FXLS8962
342  ADS_FAIL, // FXAS21002
343  ADS_FAIL, // FXLC95000
344  ADS_FAIL, // FXOS8700
345  ADS_FAIL, // FXPQ3115
346  ADS_FAIL, // MAG3110
347  ADS_FAIL, // MMA8491
348  ADS_FAIL, // MMA865x
349  ADS_FAIL, // MMA9553
350  ADS_FAIL, // DIFF-P
351  ADS_FAIL, // MPL3115
352  ADS_OK, // MMA845x
353  },
354  {
355  // RD-KL25-AGMP01
356  ADS_FAIL, // FXLS8471
357  ADS_FAIL, // FXLS8962
358  ADS_FAIL, // DIFF-P
359  ADS_FAIL, // FXLS8962
360  ADS_OK, // FXAS21002
361  ADS_FAIL, // FXLC95000
362  ADS_OK, // FXOS8700
363  ADS_FAIL, // FXPQ3115
364  ADS_FAIL, // MAG3110
365  ADS_FAIL, // MMA8491
366  ADS_FAIL, // MMA865x
367  ADS_FAIL, // MMA9553
368  ADS_FAIL, // DIFF-P
369  ADS_OK, // MPL3115
370  ADS_NULL, // MMA845x
371  },
372 };
373 
374 /*******************************************************************************
375  * Global Variables
376  ******************************************************************************/
377 /*!
378 * @brief This global contains the results from the sensor query.
379 */
381 
383  "FRDM-STBC-AGM01", "FRDM-STBC-SA9500", "FRDMSTBC-A8471", "FRDMSTBC-A8491",
384  "FRDMSTBC-P3115", "FRDMSTBI-DP300x", "FRDMSTBI-DP300x", "FRDMSTBI-B3115",
385  "FRDM-FXS-MULT2-B", "FRDM-STBC-AGMP03", "FRDM-STBC-AGMP03", "FRDM-STBC-AGM04",
386  "OnBoard", "OnBoard",
387 };
388 
389 /*!
390 * @brief These values hold the ARM CMSIS Driver interface pointers.
391 */
392 ARM_DRIVER_SPI *SPIdrv = &SPI_S_DRIVER;
393 ARM_DRIVER_I2C *I2CextDrv = &I2C_S1_DRIVER;
394 ARM_DRIVER_I2C *I2CintDrv = &I2C_BB_DRIVER;
396 
403 
404 /*******************************************************************************
405 * FXLS8471 SPI Specific Functions
406 *****************************************************************************/
407 void ADS_FXLS8471Q_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
408 {
409  spiCmdParams_t *pSlaveCmd = pCmdOut;
410 
411  uint8_t *pWBuff = spiRead_CmdBuffer;
412  uint8_t *pRBuff = spiRead_DataBuffer;
413 
414  /* Formatting for Read command of FXLS8471Q SENSOR. */
415  *(pWBuff) = offset & 0x7F; /* offset is the internal register address of the sensor at which write is performed. */
416  *(pWBuff + 1) = offset & 0x80;
417 
418  // Create the slave read command.
419  pSlaveCmd->size = size + FXLS8471Q_SPI_CMD_LEN;
420  pSlaveCmd->pWriteBuffer = pWBuff;
421  pSlaveCmd->pReadBuffer = pRBuff;
422 }
423 
424 void ADS_FXLS8471Q_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
425 {
426  spiCmdParams_t *pSlaveCmd = pCmdOut;
427 
428  uint8_t *pWBuff = spiWrite_CmdDataBuffer;
429  uint8_t *pRBuff = spiWrite_CmdDataBuffer + size + FXLS8471Q_SPI_CMD_LEN;
430 
431  /* Formatting for Write command of FXLS8471Q SENSOR. */
432  *(pWBuff) = offset | 0x80; /* offset is the internal register address of the sensor at which write is performed. */
433  *(pWBuff + 1) = offset & 0x80;
434 
435  /* Copy the slave write command */
436  memcpy(pWBuff + FXLS8471Q_SPI_CMD_LEN, pWritebuffer, size);
437 
438  /* Create the slave command. */
439  pSlaveCmd->size = size + FXLS8471Q_SPI_CMD_LEN;
440  pSlaveCmd->pWriteBuffer = pWBuff;
441  pSlaveCmd->pReadBuffer = pRBuff;
442 }
443 
445 {
448  spiParams_8471.pTargetSlavePinID = &FXLS8471_SPI_CS;
449  spiParams_8471.spiCmdLen = FXLS8471Q_SPI_CMD_LEN;
450  spiParams_8471.ssActiveValue = FXLS8471Q_SS_ACTIVE_VALUE;
451 
452  /* Initialize the Slave Select Pin. */
453  pGPIODriver->pin_init(&FXLS8471_SPI_CS, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
454  if (spiParams_8471.ssActiveValue == SPI_SS_ACTIVE_LOW)
455  {
456  pGPIODriver->set_pin(&FXLS8471_SPI_CS);
457  }
458  else
459  {
460  pGPIODriver->clr_pin(&FXLS8471_SPI_CS);
461  }
462 };
463 
464 ADS_Status_t ADS_FXLS8471Query(uint8_t whoAmiAddr, uint8_t whoAmi)
465 {
466  int32_t status;
467  uint8_t reg;
468  registerDeviceInfo_t deviceInfo = {
469  .deviceInstance = SPI_S_DEVICE_INDEX, .functionParam = NULL, .idleFunction = NULL};
470 
471  /*! Read and store the device's WHO_AM_I.*/
472  status = Register_SPI_Read(SPIdrv, &deviceInfo, &spiParams_8471, whoAmiAddr, 1, &reg);
473  if ((ARM_DRIVER_OK != status) || (whoAmi != reg))
474  {
475  return ADS_FAIL;
476  }
477 
478  return ADS_OK;
479 }
480 
481 /*******************************************************************************
482 * FXLS8962 SPI Specific Functions
483 *****************************************************************************/
484 void ADS_FXLS8962_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
485 {
486  spiCmdParams_t *pSlaveCmd = pCmdOut;
487 
488  uint8_t *pWBuff = spiRead_CmdBuffer;
489  uint8_t *pRBuff = spiRead_DataBuffer;
490 
491  /* Formatting for Read command of FXLS8962 SENSOR. */
492  *(pWBuff) = offset | 0x80; /* offset is the internal register address of the sensor at which write is performed. */
493  *(pWBuff + 1) = 0x00;
494 
495  /* Create the slave read command. */
496  pSlaveCmd->size = size + FXLS8962_SPI_CMD_LEN;
497  pSlaveCmd->pWriteBuffer = pWBuff;
498  pSlaveCmd->pReadBuffer = pRBuff;
499 }
500 
501 void ADS_FXLS8962_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
502 {
503  spiCmdParams_t *pSlaveCmd = pCmdOut;
504 
505  uint8_t *pWBuff = spiWrite_CmdDataBuffer;
506  uint8_t *pRBuff = spiWrite_CmdDataBuffer + size + FXLS8962_SPI_CMD_LEN;
507 
508  /* Formatting for Write command of FXLS8962 SENSOR. */
509  *(pWBuff) = offset & 0x7F; /* offset is the internal register address of the sensor at which write is performed. */
510  *(pWBuff + 1) = 0x00;
511 
512  /* Copy the slave write command */
513  memcpy(pWBuff + FXLS8962_SPI_CMD_LEN, pWritebuffer, size);
514 
515  /* Create the slave command. */
516  pSlaveCmd->size = size + FXLS8962_SPI_CMD_LEN;
517  pSlaveCmd->pWriteBuffer = pWBuff;
518  pSlaveCmd->pReadBuffer = pRBuff;
519 }
520 
522 { /*! Initialize the sensor handle. */
525  spiParams_8962.pTargetSlavePinID = &FXLS8962_CS;
526  spiParams_8962.spiCmdLen = FXLS8962_SPI_CMD_LEN;
527  spiParams_8962.ssActiveValue = FXLS8962_SS_ACTIVE_VALUE;
528 
529  /* Initialize the Slave Select Pin. */
530  pGPIODriver->pin_init(&FXLS8962_CS, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
531  if (spiParams_8962.ssActiveValue == SPI_SS_ACTIVE_LOW)
532  {
533  pGPIODriver->set_pin(&FXLS8962_CS);
534  }
535  else
536  {
537  pGPIODriver->clr_pin(&FXLS8962_CS);
538  }
539 };
540 
541 ADS_Status_t ADS_FXLS8962Query(uint8_t whoAmiAddr, uint8_t whoAmi)
542 {
543  int32_t status;
544  uint8_t reg;
545  registerDeviceInfo_t deviceInfo = {
546  .deviceInstance = SPI_S_DEVICE_INDEX, .functionParam = NULL, .idleFunction = NULL};
547 
548  /*! Read and store the device's WHO_AM_I.*/
549  status = Register_SPI_Read(SPIdrv, &deviceInfo, &spiParams_8962, whoAmiAddr, 1, &reg);
550  if ((ARM_DRIVER_OK != status) || (whoAmi != reg))
551  {
552  return ADS_FAIL;
553  }
554 
555  return ADS_OK;
556 }
557 
558 /*******************************************************************************
559 * DIFF-P SPI Specific Functions
560 *****************************************************************************/
561 void ADS_DIFF_P_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
562 {
563  spiCmdParams_t *pSlaveCmd = pCmdOut;
564 
565  uint8_t *pWBuff = spiRead_CmdBuffer;
566  uint8_t *pRBuff = spiRead_DataBuffer;
567 
568  /* Formatting for Read command of DIFF-P SENSOR. */
569  *(pWBuff) = offset & 0x7F; /* offset is the internal register address of the sensor at which write is performed. */
570 
571  // Create the slave read command.
572  pSlaveCmd->size = size + DIFF_P_SPI_CMD_LEN;
573  pSlaveCmd->pWriteBuffer = pWBuff;
574  pSlaveCmd->pReadBuffer = pRBuff;
575 }
576 
577 void ADS_DIFF_P_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
578 {
579  spiCmdParams_t *pSlaveCmd = pCmdOut;
580 
581  uint8_t *pWBuff = spiWrite_CmdDataBuffer;
582  uint8_t *pRBuff = spiWrite_CmdDataBuffer + size + DIFF_P_SPI_CMD_LEN;
583 
584  /* Formatting for Write command of DIFF-P SENSOR. */
585  *(pWBuff) = offset | 0x80; /* offset is the internal register address of the sensor at which write is performed. */
586 
587  /* Copy the slave write command */
588  memcpy(pWBuff + DIFF_P_SPI_CMD_LEN, pWritebuffer, size);
589 
590  /* Create the slave command. */
591  pSlaveCmd->size = size + DIFF_P_SPI_CMD_LEN;
592  pSlaveCmd->pWriteBuffer = pWBuff;
593  pSlaveCmd->pReadBuffer = pRBuff;
594 }
595 
597 {
600  spiParams_diff_p.pTargetSlavePinID = &DIFF_P_SPI_CS;
601  spiParams_diff_p.spiCmdLen = DIFF_P_SPI_CMD_LEN;
602  spiParams_diff_p.ssActiveValue = DIFF_P_SS_ACTIVE_VALUE;
603 
604  /* Initialize the Slave Select Pin. */
605  pGPIODriver->pin_init(&DIFF_P_SPI_CS, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
606  if (spiParams_diff_p.ssActiveValue == SPI_SS_ACTIVE_LOW)
607  {
608  pGPIODriver->set_pin(&DIFF_P_SPI_CS);
609  }
610  else
611  {
612  pGPIODriver->clr_pin(&DIFF_P_SPI_CS);
613  }
614 };
615 
616 ADS_Status_t ADS_DIFF_PQuery(uint8_t whoAmiAddr, uint8_t whoAmi)
617 {
618  int32_t status;
619  uint8_t reg;
620  registerDeviceInfo_t deviceInfo = {
621  .deviceInstance = SPI_S_DEVICE_INDEX, .functionParam = NULL, .idleFunction = NULL};
622 
623  /*! Read and store the device's WHO_AM_I.*/
624  status = Register_SPI_Read(SPIdrv, &deviceInfo, &spiParams_diff_p, whoAmiAddr, 1, &reg);
625  if ((ARM_DRIVER_OK != status) || (whoAmi != reg))
626  {
627  return ADS_FAIL;
628  }
629 
630  return ADS_OK;
631 }
632 
633 /*******************************************************************************
634 * FXLC95000 Specific Functions
635 *****************************************************************************/
637 {
638  int32_t status;
639  uint16_t partNumber;
640 
641  registerDeviceInfo_t deviceInfo = {
642  .deviceInstance = I2C_S1_DEVICE_INDEX, .functionParam = NULL, .idleFunction = NULL};
643 
644  /* ADS is required to confirm only the presence of FXLC95000 and not the contents of its FLASH.
645  * As such we will not send command to Boot FXLC95000 to Flash.
646  * We send the Get Device Info ROM CI command and validate response. */
647  Register_I2C_BlockWrite(I2CextDrv, &deviceInfo, FXLC95000_I2C_ADDR, 0, GetDeviceInfoCmd, sizeof(GetDeviceInfoCmd));
648  BOARD_DELAY_ms(1);
649 
650  /* Read the Device Info Result.
651  * A valid response COCO indicates command acceptance and by nature Sensor Identity. */
653  FXLC95000_PART_NUMBER_SIZE, (uint8_t *)&partNumber);
654  partNumber = (partNumber >> 8) | (partNumber << 8);
655  if (ARM_DRIVER_OK != status || partNumber != FXLC95000_PART_NUMBER)
656  {
657  return ADS_FAIL;
658  }
659  return ADS_OK;
660 };
661 
662 /*******************************************************************************
663 * MMA9553 Specific Functions
664 *****************************************************************************/
666 {
667  int32_t status;
668  uint8_t cmdRespHdr[MMA9553_HDR_SIZE] = {0};
669 
670  registerDeviceInfo_t deviceInfo = {
671  .deviceInstance = I2C_S1_DEVICE_INDEX, .functionParam = NULL, .idleFunction = NULL};
672 
673  /* We send the Read Version Info command and validate response. */
675  sizeof(ReadVersionInfo_MMA9553));
676  BOARD_DELAY_ms(1);
677 
678  /* Read the Device Info Result.
679  * A valid response COCO and length fields indicate command acceptance and by nature Sensor Identity. */
680  status = Register_I2C_Read(I2CextDrv, &deviceInfo, MMA9553_I2C_ADDR, 0, sizeof(cmdRespHdr), cmdRespHdr);
681  if (ARM_DRIVER_OK != status || (cmdRespHdr[1] & 0x80) != 0x80 || cmdRespHdr[2] != ReadVersionInfo_MMA9553[3] ||
682  cmdRespHdr[3] != ReadVersionInfo_MMA9553[3])
683  {
684  return ADS_FAIL;
685  }
686  return ADS_OK;
687 };
688 
689 /*******************************************************************************
690  * Functions
691  *****************************************************************************/
693 {
694  int32_t status;
695 
696  /*! Initialize the Internal I2C driver. */
697  status = I2CintDrv->Initialize(I2C_BB_SIGNAL_EVENT);
698  if (ARM_DRIVER_OK != status)
699  {
700  return ARM_DRIVER_ERROR;
701  }
702 
703  /*! Set the Internal I2C Power mode. */
704  status = I2CintDrv->PowerControl(ARM_POWER_FULL);
705  if (ARM_DRIVER_OK != status)
706  {
707  return ARM_DRIVER_ERROR;
708  }
709 
710  /*! Set the Internal I2C bus speed. */
711  status = I2CintDrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
712  if (ARM_DRIVER_OK != status)
713  {
714  return ARM_DRIVER_ERROR;
715  }
716 
717  /*! Initialize the External I2C driver. */
718  status = I2CextDrv->Initialize(I2C_S1_SIGNAL_EVENT);
719  if (ARM_DRIVER_OK != status)
720  {
721  return ARM_DRIVER_ERROR;
722  }
723 
724  /*! Set the External I2C Power mode. */
725  status = I2CextDrv->PowerControl(ARM_POWER_FULL);
726  if (ARM_DRIVER_OK != status)
727  {
728  return ARM_DRIVER_ERROR;
729  }
730 
731  /*! Set the External I2C bus speed. */
732  status = I2CextDrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
733  if (ARM_DRIVER_OK != status)
734  {
735  return ARM_DRIVER_ERROR;
736  }
737 
738  return status;
739 }
740 
742 {
743  int32_t status;
744 
745  /*! Initialize the SPI driver. */
746  status = SPIdrv->Initialize(SPI_S_SIGNAL_EVENT);
747  if (ARM_DRIVER_OK != status)
748  {
749  return ARM_DRIVER_ERROR;
750  }
751 
752  /*! Set the SPI Power mode. */
753  status = SPIdrv->PowerControl(ARM_POWER_FULL);
754  if (ARM_DRIVER_OK != status)
755  {
756  return ARM_DRIVER_ERROR;
757  }
758 
759  /*! Set the SPI Slave speed. */
760  status = SPIdrv->Control(ARM_SPI_MODE_MASTER | ARM_SPI_CPOL1_CPHA0, SPI_S_BAUDRATE);
761  if (ARM_DRIVER_OK != status)
762  {
763  return ARM_DRIVER_ERROR;
764  }
765 
766  return status;
767 }
768 
770 {
771  int32_t status;
772 
773  /*! De-Initialize the Internal I2C driver. */
774  status = I2CintDrv->Uninitialize();
775  if (ARM_DRIVER_OK != status)
776  {
777  return ARM_DRIVER_ERROR;
778  }
779 
780  /*! De-Initialize the External I2C driver. */
781  status = I2CextDrv->Uninitialize();
782  if (ARM_DRIVER_OK != status)
783  {
784  return ARM_DRIVER_ERROR;
785  }
786 
787  return status;
788 }
789 
791 {
792  int32_t status;
793 
794  /*! De-Initialize the SPI0 driver. */
795  status = SPIdrv->Uninitialize();
796  if (ARM_DRIVER_OK != status)
797  {
798  return ARM_DRIVER_ERROR;
799  }
800 
801  return status;
802 }
803 
804 // Private function to detect Shield.
805 int ADS_DetectShield(char *pShieldString, size_t bufferLength)
806 {
807  int32_t status;
808  uint8_t reg;
809  bool match;
810  uint32_t boardFound = ADS_NO_SHIELD_DETECTED;
811  registerDeviceInfo_t deviceInfo = {0};
812 
813  /* We init SPI bus to test for SPI Sensors. */
814  ADS_InitSPIBus();
815 
816  // Execute the SPI queries based on the ADS_SensorQueryList.
817  for (uint32_t i = 0; i < ADS_QUERY_NUM; i++)
818  {
819  if (ADS_SPI_DEV == ADS_SensorQueryList[i].channel)
820  {
822  if (FXLS8962 == ADS_SensorQueryList[i].slaveAddr)
823  {
825  gADS_QueryResults[i] =
826  ADS_FXLS8962Query(ADS_SensorQueryList[i].whoAmIAddr, ADS_SensorQueryList[i].whoAmIValue);
827  continue;
828  }
829  if (FXLS8471 == ADS_SensorQueryList[i].slaveAddr)
830  {
832  gADS_QueryResults[i] =
833  ADS_FXLS8471Query(ADS_SensorQueryList[i].whoAmIAddr, ADS_SensorQueryList[i].whoAmIValue);
834  continue;
835  }
836  if (DIFF_P == ADS_SensorQueryList[i].slaveAddr)
837  {
839  gADS_QueryResults[i] =
840  ADS_DIFF_PQuery(ADS_SensorQueryList[i].whoAmIAddr, ADS_SensorQueryList[i].whoAmIValue);
841  continue;
842  }
843  }
844  }
845 
846  /* We now disable SPI bus and init I2C buses to test for I2C sensors. */
849 
850  // Execute the Ext I2C queries based on the ADS_SensorQueryList.
851  for (uint32_t i = 0; i < ADS_QUERY_NUM; i++)
852  {
853  if (ADS_I2C_EXT == ADS_SensorQueryList[i].channel)
854  {
856  deviceInfo.deviceInstance = I2C_S1_DEVICE_INDEX;
857  if (FXLC95000 == ADS_SensorQueryList[i].slaveAddr)
858  {
860  continue;
861  }
862  if (MMA9553 == ADS_SensorQueryList[i].slaveAddr)
863  {
865  continue;
866  }
867  if (MMA8491Q_I2C_ADDRESS == ADS_SensorQueryList[i].slaveAddr)
868  { /* Set MMA8491Q EN Pin to enable I2C communication. */
869  CLOCK_EnableClock(MMA8491_EN.clockName);
870  pGPIODriver->pin_init(&MMA8491_EN, GPIO_DIRECTION_OUT, NULL, NULL, NULL);
871  pGPIODriver->set_pin(&MMA8491_EN);
872  BOARD_DELAY_ms(MMA8491Q_T_ON_TYPICAL); /* Wait for Bus to become active. */
874  }
875  status = Register_I2C_Read(I2CextDrv, &deviceInfo, ADS_SensorQueryList[i].slaveAddr,
876  ADS_SensorQueryList[i].whoAmIAddr, 1, &reg);
877  if ((ARM_DRIVER_OK != status) ||
878  ((ADS_SensorQueryList[i].whoAmIValue & ADS_SensorQueryList[i].whoAmIMask) !=
879  (reg & ADS_SensorQueryList[i].whoAmIMask)))
880  {
882  }
883  else
884  {
886  }
887  }
888  }
889 
890  // Execute the Int I2C queries based on the ADS_SensorQueryList.
891  for (uint32_t i = 0; i < ADS_QUERY_NUM; i++)
892  {
893  if (ADS_I2C_INT == ADS_SensorQueryList[i].channel)
894  {
896  deviceInfo.deviceInstance = I2C_BB_DEVICE_INDEX;
897  status = Register_I2C_Read(I2CintDrv, &deviceInfo, ADS_SensorQueryList[i].slaveAddr,
898  ADS_SensorQueryList[i].whoAmIAddr, 1, &reg);
899  if ((ARM_DRIVER_OK != status) || (ADS_SensorQueryList[i].whoAmIValue != reg))
900  {
902  }
903  else
904  {
906  }
907  }
908  }
909 
910  /* I2C Sensor verified, disable I2C buses. */
912 
913  // Analyze the responses and return the Sensor Shield or Reference name.
914  for (uint32_t board = 0; board < ADS_NUM_BOARDS; board++)
915  {
916  match = true;
917  for (uint32_t sensor = 0; sensor < ADS_QUERY_NUM; sensor++)
918  {
919  if (gADS_QueryMap[board][sensor] == ADS_NULL)
920  {
921  continue;
922  }
923  if (gADS_QueryMap[board][sensor] != gADS_QueryResults[sensor])
924  {
925  match = false;
926  break;
927  }
928  }
929  if (match)
930  {
931  boardFound = board;
932  break;
933  }
934  }
935 
936  // If a board was found, then put the proper string into the response.
937  if (boardFound != ADS_NO_SHIELD_DETECTED)
938  {
939  strncpy(pShieldString, ADS_ShieldList[boardFound], bufferLength);
940  status = ARM_DRIVER_OK;
941  }
942  else
943  {
944  status = ARM_DRIVER_ERROR;
945  }
946 
947  return status;
948 }
949 
950 // Private function to detect the MCU.
951 int ADS_DetectFRDM(char *pBoardString, size_t bufferLength)
952 {
953  int32_t status;
954 
955  // Declare the SDID Query structure
956  mcuSDID_t MCUInfo = {.mcuFamilyId = 0,
957  .mcuSubfamilyId = 0,
958  .mcuSeriesId = 0,
959  .mcuFamId = 0,
960  .mcuPinId = 0,
961  .board = ADS_NO_BOARD_DETECTED};
962 
963  if (pBoardString == NULL)
964  {
965  return ARM_DRIVER_ERROR_PARAMETER;
966  }
967 
968 // Use the #define Macros in <device>_feature.h to conditionally compile the queries to SDID fields..
969 #ifdef SIM_SDID_FAMILYID
970  MCUInfo.mcuFamilyId = ((SIM->SDID) & SIM_SDID_FAMILYID_MASK) >> SIM_SDID_FAMILYID_SHIFT;
971 #endif
972 
973 #ifdef SIM_SDID_SUBFAMID
974  MCUInfo.mcuSubfamilyId = ((SIM->SDID) & SIM_SDID_SUBFAMID_MASK) >> SIM_SDID_SUBFAMID_SHIFT;
975 #endif
976 
977 #ifdef SIM_SDID_SERIESID
978  MCUInfo.mcuSeriesId = ((SIM->SDID) & SIM_SDID_SERIESID_MASK) >> SIM_SDID_SERIESID_SHIFT;
979 #endif
980 
981 #ifdef SIM_SDID_FAMID
982  MCUInfo.mcuFamId = ((SIM->SDID) & SIM_SDID_FAMID_MASK) >> SIM_SDID_FAMID_SHIFT;
983 #endif
984 
985  MCUInfo.mcuPinId = ((SIM->SDID) & SIM_SDID_PINID_MASK) >> SIM_SDID_PINID_SHIFT;
986 
987  // Compare the values extracted to the static table and return detected board.
988  for (uint32_t i = 0; i < (sizeof(ADS_ValidSDIDValues) / sizeof(mcuSDID_t)); i++)
989  {
990  if ((MCUInfo.mcuFamilyId == ADS_ValidSDIDValues[i].mcuFamilyId) &&
991  (MCUInfo.mcuSubfamilyId == ADS_ValidSDIDValues[i].mcuSubfamilyId) &&
992  (MCUInfo.mcuSeriesId == ADS_ValidSDIDValues[i].mcuSeriesId) &&
993  (MCUInfo.mcuFamId == ADS_ValidSDIDValues[i].mcuFamId) &&
994  (MCUInfo.mcuPinId == ADS_ValidSDIDValues[i].mcuPinId))
995  {
996  MCUInfo.board = ADS_ValidSDIDValues[i].board;
997  break;
998  }
999  }
1000 
1001  status = ARM_DRIVER_OK;
1002  // Translate the result into the string.
1003  switch (MCUInfo.board)
1004  {
1005  case ADS_FRDM_KW41Z:
1006  strncpy(pBoardString, "FRDM-KW41Z", bufferLength);
1007  break;
1008  case ADS_FRDM_KE15Z:
1009  strncpy(pBoardString, "FRDM-KE15Z", bufferLength);
1010  break;
1011  case ADS_FRDM_KL25Z:
1012  strncpy(pBoardString, "FRDM-KL25Z", bufferLength);
1013  break;
1014  case ADS_FRDM_KL27Z:
1015  strncpy(pBoardString, "FRDM-KL27Z", bufferLength);
1016  break;
1017  case ADS_FRDM_K22F:
1018  strncpy(pBoardString, "FRDM-K22F", bufferLength);
1019  break;
1020  case ADS_FRDM_K64F:
1021  strncpy(pBoardString, "FRDM-K64F", bufferLength);
1022  break;
1023  case ADS_RD_KL25_AGMP01:
1024  strncpy(pBoardString, "RD-KL25-AGMP01", bufferLength);
1025  break;
1026  default:
1027  status = ARM_DRIVER_ERROR;
1028  break;
1029  }
1030 
1031  return status;
1032 }
1033 
1034 // Private function to compare flash contents.
1036 {
1038  uint32_t status;
1039 
1040  // Check that the ADS_COOKIE is as expected.
1041  if (pRecord->cookie != ADS_COOKIE_VALUE)
1042  {
1043  return ADS_NO_FLASH_RECORD; // Flash record is not valid.
1044  }
1045  else
1046  { // Compare the result string with the ADS stored results in Flash.
1047  status = strncmp((char *)pResultString, (char *)pRecord->ADSString, pRecord->length);
1048  if (status != 0)
1049  {
1050  return ADS_FLASH_RECORD_CHANGE;
1051  }
1052  else
1053  {
1055  }
1056  }
1057 }
1058 
1059 // Private function to update flash contents.
1060 ADS_Status_t ADS_FlashUpdate(char *pResultString)
1061 {
1062  status_t result;
1063  uint32_t pflashSectorSize = 0;
1064  ADS_Status_t retVal = ADS_FAIL;
1065  ADSFlashRecord_t flashRecord = {0};
1066  flash_config_t s_flashDriver;
1067 
1068  // Create the ADS Flash Record.
1069  flashRecord.cookie = ADS_COOKIE_VALUE;
1070  flashRecord.length = strlen((char const *)pResultString);
1071  memcpy(flashRecord.ADSString, pResultString, flashRecord.length);
1072 
1073  // Clean up Flash driver Structure.
1074  memset(&s_flashDriver, 0, sizeof(flash_config_t));
1075 
1076  // Setup flash driver structure for device and initialize variables.
1077  result = FLASH_Init(&s_flashDriver);
1078  if (kStatus_FLASH_Success == result)
1079  {
1080  // Get the Flash sector size.
1081  FLASH_GetProperty(&s_flashDriver, FLASH_SECTOR_SIZE_PROPERTY, &pflashSectorSize);
1082 
1083  // Erase the target sector.
1084  result = FLASH_Erase(&s_flashDriver, ADS_NVM_ADDR, pflashSectorSize, kFLASH_ApiEraseKey);
1085  if (kStatus_FLASH_Success == result)
1086  {
1087  // Write the ADS Record to the Flash.
1088  result = FLASH_Program(&s_flashDriver, ADS_NVM_ADDR, (uint8_t *)&flashRecord,
1089  sizeof(flashRecord)); // Note: Flash write needs to be 32-bit word aligned in length
1090  if (kStatus_FLASH_Success == result)
1091  {
1092  retVal = ADS_OK;
1093  }
1094  }
1095  }
1096 
1097  return retVal;
1098 }
1099 
1100 // API to register Application Name and trigger Board Shield detection.
1101 void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
1102 {
1103  int32_t position, status = ADS_OK;
1104  char finalString[ADS_FLASH_STRING_LENGTH] = {0};
1105 
1106  status = ADS_DetectFRDM(boardString, bufferLength);
1107  if (ARM_DRIVER_ERROR == status)
1108  {
1109  strncpy(boardString, "NotDetected", bufferLength);
1110  status = ADS_FAIL;
1111  }
1112 
1113  status = ADS_DetectShield(shieldString, bufferLength);
1114  if (ARM_DRIVER_ERROR == status)
1115  {
1116  strncpy(shieldString, "NotDetected", bufferLength);
1117  status = ADS_FAIL;
1118  }
1119 
1120  // Build the string with App Name and Shield Name to write to flash.
1121  strncpy(finalString, appName, ADS_FLASH_STRING_LENGTH);
1122  position = strlen(appName);
1123 
1124  finalString[position++] = ':';
1125 
1126  strncpy(&finalString[position], shieldString, ADS_FLASH_STRING_LENGTH - position);
1127  position += strlen(shieldString);
1128 
1129  /* Fill the remaining string with 0. */
1130  memset(&finalString[position], 0, ADS_FLASH_STRING_LENGTH - position);
1131 
1132  status = ADS_FlashCompare(finalString);
1133  if (ADS_FLASH_RECORD_NO_CHANGE != status)
1134  {
1135  ADS_FlashUpdate(finalString);
1136  strcpy(finalString, shieldString);
1137  snprintf(shieldString, bufferLength, "Changed:%s", finalString);
1138  }
1139 }
#define MMA9553_HDR_SIZE
Size of fixed header bytes in sensor commands.
Definition: mma9553.h:14
void(* set_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:46
int ADS_DeInitSPIBus()
uint32_t size
#define FXAS21002_WHO_AM_I_WHOAMI_PROD_VALUE
Definition: fxas21002.h:402
char ADSString[ADS_FLASH_STRING_LENGTH]
#define DIFF_P_SPI_CS
The mma845x.h contains the MMA845x sensor register definitions and its bit mask.
const sensorAccess_t ADS_SensorQueryList[]
This constant data structure contains the expected valid comm/sensor/who_am_i combinations.
#define FXLS8471_SPI_CS
#define MMA8451_WHO_AM_I_WHOAMI_VALUE
Definition: mma845x.h:482
#define I2C_BB_DEVICE_INDEX
Definition: frdm_k64f.h:80
ADS_FlashStatus_t ADS_FlashCompare(char *pResultString)
int ADS_DeInitI2CBuses()
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:102
#define I2C_BB_DRIVER
Definition: frdm_k64f.h:79
spiSlaveSpecificParams_t spiParams_diff_p
ADS_Status_t ADS_FXLC95000Query()
int32_t status
The fxls8471q.h file contains the register definitions for fxls8471q sensor driver.
#define MMA8491Q_WHO_AM_I_VALUE
int ADS_InitSPIBus()
#define I2C_S1_DEVICE_INDEX
Definition: frdm_k64f.h:66
int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
#define MAG3110_I2C_ADDR
void BOARD_DELAY_ms(uint32_t delay_ms)
Function to insert delays.
Definition: systick_utils.c:81
#define FXOS8700_WHO_AM_I_PROD_VALUE
Definition: fxos8700.h:146
char shieldString[ADS_MAX_STRING_LENGTH]
spiSlaveSpecificParams_t spiParams_8471
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...
#define MMA8491_EN
#define ADS_NO_WHO_AM_I
uint8_t spiRead_CmdBuffer[SPI_MAX_MSG_SIZE]
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
This structure defines the spi slave command format.
#define FXLC95000_PART_NUMBER_OFFSET
Offset of 2-Byte SA95000 Part Number in Device Info Response.
Definition: fxlc95000.h:30
Access structure of the GPIO Driver.
Definition: Driver_GPIO.h:38
#define MMA8491_I2C_ADDR
#define FXLC95000_I2C_ADDR
#define ADS_FLASH_STRING_LENGTH
#define SPI_SS_ACTIVE_LOW
ADS_FlashStatus_t
This enumeration defines the ADS Flash storage status.
This defines a record type to store ADS results string in Flash memory.
ARM_DRIVER_I2C * I2CextDrv
void ADS_DIFF_P_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
#define MMA8491Q_WHO_AM_I
These variables are specific to MMA8491Q which does not have a Who Am I register. ...
void ADS_InitSPI_FXLS8471()
#define FXLS8471Q_WHO_AM_I_WHOAMI_VALUE
Definition: fxls8471q.h:512
#define FXLS8962_SPI_CMD_LEN
These variables are specific to SPI access to the FXLS8962 for ADS.
void(* clr_pin)(pinID_t aPinId)
Definition: Driver_GPIO.h:47
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
#define SPI_S_BAUDRATE
Transfer baudrate - 500k.
Definition: frdm_k64f.h:88
#define DIFF_P_SPI_CMD_LEN
These variables are specific to SPI access to the DIFF_P for ADS.
#define SPI_S_DEVICE_INDEX
Definition: frdm_k64f.h:89
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
void ADS_DIFF_P_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
#define MMA8451_I2C_ADDR
This defines a record type to store the communication channel info and WHO_AM_I address/value for var...
#define MMA9553_I2C_ADDR
ADS_Status_t ADS_MMA9553Query()
uint8_t spiWrite_CmdDataBuffer[SPI_MAX_MSG_SIZE]
fpSpiReadPreprocessFn_t pReadPreprocessFN
The fxas21002.h contains the fxas21002 sensor register definitions and its bit mask.
The SPI Slave Transfer Command Params SDK2.0 Driver.
GENERIC_DRIVER_GPIO Driver_GPIO_KSDK
Definition: gpio_driver.c:177
#define FXAS21002_I2C_ADDR
#define ADS_NVM_ADDR
start of the next to last 4K (sector size) of the 1M flash
Definition: frdm_k64f.h:148
GENERIC_DRIVER_GPIO * pGPIODriver
#define MMA8491Q_T_ON_TYPICAL
Definition: mma8491q.h:29
ARM_DRIVER_I2C * I2CintDrv
#define FXLS8471Q_SS_ACTIVE_VALUE
#define MMA8491Q_I2C_ADDRESS
Definition: mma8491q.h:26
#define FLASH_SECTOR_SIZE_PROPERTY
Definition: frdm_k64f.h:149
ADS_Status_t ADS_FXLS8471Query(uint8_t whoAmiAddr, uint8_t whoAmi)
#define SPI_MAX_MSG_SIZE
This defines a record type to store the expected field values in the MCU SDID register word aligned...
#define ADS_NUM_BOARDS
#define I2C_S1_DRIVER
Definition: frdm_k64f.h:65
int ADS_InitI2CBuses()
int ADS_DetectFRDM(char *pBoardString, size_t bufferLength)
#define ADS_COOKIE_VALUE
ADS_Status_t ADS_DIFF_PQuery(uint8_t whoAmiAddr, uint8_t whoAmi)
const mcuSDID_t ADS_ValidSDIDValues[]
This constant data structure contains the expected valid MCU SDID combinations.
int ADS_DetectShield(char *pShieldString, size_t bufferLength)
#define ADS_NO_SHIELD_DETECTED
void ADS_FXLS8471Q_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
#define FXLS8962_SS_ACTIVE_VALUE
#define DIFF_P_I2C_ADDR
void ADS_InitSPI_DIFF_P()
spiSlaveSpecificParams_t spiParams_8962
#define I2C_S1_SIGNAL_EVENT
Definition: frdm_k64f.h:67
const ADS_Status_t gADS_QueryMap[][ADS_QUERY_NUM]
These are the expected query signatures for the shield boards.
void ADS_FXLS8962_SPI_ReadPreprocess(void *pCmdOut, uint32_t offset, uint32_t size)
void ADS_InitSPI_FXLS8962()
char ADS_ShieldList[][ADS_MAX_STRING_LENGTH]
ADS_SupportedBoards_t board
#define FXLS8471Q_SPI_CMD_LEN
These variables are specific to SPI access to the FXLS8471 for ADS.
int32_t Register_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to write a sensor register.
#define ADS_MAX_STRING_LENGTH
#define DIFF_P_SS_ACTIVE_VALUE
#define FXLC95000_PART_NUMBER_SIZE
The FXLC95000 Size of Part Number.
Definition: fxlc95000.h:33
ADS_Status_t ADS_FXLS8962Query(uint8_t whoAmiAddr, uint8_t whoAmi)
#define FXPQ3115_WHOAMI_VALUE
Definition: fxpq3115.h:65
uint8_t spiRead_DataBuffer[SPI_MAX_MSG_SIZE]
ARM_DRIVER_SPI * SPIdrv
These values hold the ARM CMSIS Driver interface pointers.
#define MMA8491Q_STATUS_RESERVED_MASK
Definition: mma8491q.h:70
#define MPL3115_WHOAMI_VALUE
Definition: mpl3115.h:65
char boardString[ADS_MAX_STRING_LENGTH]
#define FXLC95000_PART_NUMBER
The FXLC95000 2-byte packed BCD encoded Part Number (BCD for Last 4 characters).
Definition: fxlc95000.h:36
fpSpiWritePreprocessFn_t pWritePreprocessFN
The auto_detection_shield.h file describes the definitions for Sensor I2C and SPI parameters required...
void(* pin_init)(pinID_t aPinId, gpio_direction_t dir, void *apPinConfig, gpio_isr_handler_t aIsrHandler, void *apUserData)
Definition: Driver_GPIO.h:41
#define MMA8652_I2C_ADDR
ARM Systick Utilities.
#define MAG3110_WHOAMI_VALUE
Definition: mag3110.h:37
#define I2C_BB_SIGNAL_EVENT
Definition: frdm_k64f.h:81
#define FXPQ3115_I2C_ADDR
#define SPI_S_DRIVER
Definition: frdm_k64f.h:87
void ADS_FXLS8471Q_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
enum ADS_Status ADS_Status_t
This defines the return status.
void ADS_FXLS8962_SPI_WritePreprocess(void *pCmdOut, uint32_t offset, uint32_t size, void *pWritebuffer)
#define SPI_S_SIGNAL_EVENT
Definition: frdm_k64f.h:90
#define MPL3115_I2C_ADDR
This file contains the FXLS8962 Accelerometer register definitions, access macros, and device access functions.
const uint8_t ReadVersionInfo_MMA9553[4]
The Read Version Info Command for FXLC95000.
#define FXLS8962_I2C_ADDR
The fxos8700.h file contains the register definitions for FXOS8700 sensor driver. ...
#define FXLS8962_WHOAMI_VALUE
Definition: fxls8962.h:87
#define MMA8652_WHOAMI_VALUE
Definition: mma865x.h:65
#define FXLS8962_CS
#define FXOS8700_I2C_ADDR
int32_t Register_SPI_Read(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pReadParams, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
ADS_Status_t ADS_FlashUpdate(char *pResultString)
#define ADS_QUERY_NUM
ADS_Status_t gADS_QueryResults[ADS_QUERY_NUM]
This global contains the results from the sensor query.