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