ISSDK  1.8
IoT Sensing Software Development Kit
auto_detection_service.h
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.h
11  * @brief The auto_detection_service.h file describes the structures and definitions for a
12  * service that automatically detects the FRDM board and Sensor Shield.
13  */
14 
15 #ifndef AUTO_DETECTION_SERVICE_H_
16 #define AUTO_DETECTION_SERVICE_H_
17 
18 #include <stdio.h>
19 
20 /*******************************************************************************
21  * Definitions
22  ******************************************************************************/
23 #define ADS_NO_WHO_AM_I (0xFFFF) // Special value if sensor doesn't have WHO_AM_I register.
24 #define ADS_MAX_STRING_LENGTH (64) // Maximum length for sub-strings.
25 #define ADS_FLASH_STRING_LENGTH (128) // Maximum length of flash string.
26 #define ADS_NO_SHIELD_DETECTED (0xFFFFFFFF)
27 #define ADS_COOKIE_VALUE (0xDEADBEEF)
28 
29 /*!
30  * @brief This defines the return status.
31  */
32 typedef enum ADS_Status
33 {
34  ADS_OK, /* Sensor Detection status : "Found". */
35  ADS_FAIL, /* Sensor Detection status : "Not Found". */
36  ADS_NULL /* Sensor Detection status : "Dont Care". */
37 } ADS_Status_t;
38 
39 /*!
40  * @brief This defines the allowed communications channels.
41  */
42 typedef enum ADS_Channel
43 {
48 
49 /*!
50  * @brief This defines the allowed communications channels.
51  */
52 typedef enum ADS_Sensor
53 {
67 } ADS_Sensor_t;
68 
69 /*!
70  * @brief This enumeration defines the FRDM boards that ADS can detect.
71  */
72 typedef enum
73 {
83 
84 /*!
85  * @brief This enumeration defines the ADS Flash storage status.
86  */
87 typedef enum
88 {
93 
94 /*!
95  * @brief This defines a record type to store the expected field values in the MCU SDID register word aligned.
96  */
97 typedef struct
98 {
99  uint32_t mcuFamilyId; // MCU Specific Family ID
100  uint32_t mcuSubfamilyId; // MCU Specific Subfamily ID
101  uint32_t mcuSeriesId; // MCU Specific Series ID
102  uint32_t mcuFamId; // MCU Specific Family ID (separate field, not a typo).
103  uint32_t mcuPinId; // MCU Specific Pin ID
104  ADS_SupportedBoards_t board; // MCU Board corresponding to SDID values.
105 } mcuSDID_t;
106 
107 /*!
108  * @brief This defines a record type to store the communication channel info and WHO_AM_I address/value for various
109  * Sensor Shields.
110  */
111 typedef struct
112 {
113  ADS_Channel_t channel; // Channel type over which to attempt communications.
114  uint32_t slaveAddr; // I2C Slave Address or Chip-Select value.
115  uint32_t whoAmIAddr; // WHO_AM_I Register Address (Offset).
116  uint32_t whoAmIValue; // WHO_AM_I Register Value.
117  uint8_t whoAmIMask; // The Mask for Fixed who ami i bits for sensors with variants.
119 
120 /*!
121  * @brief This defines a record type to store ADS results string in Flash memory.
122  */
123 typedef struct
124 {
125  uint32_t cookie; // A unique 32-bit value unlikely to be randomly found in Flash.
126  uint32_t length; // Length of the ADS result string in bytes.
127  char ADSString[ADS_FLASH_STRING_LENGTH]; // The ADS results string.
129 
130 /******************************************************************************/
131 /*! @brief The function to register Application Name and initialte ADS.
132  * @details The API will read the Application Name from the user and return
133  * the result string with the ADS detection results. It will also update
134  * the FLASH with the new results.
135  * @param[in] pAppName - pointer to a buffer where the application name is placed.
136  * @param[in/out] boardString - pointer to a buffer to place the ADS board string.
137  * @param[in/out] shieldString - pointer to a buffer to place the ADS shield string.
138  * @param[in] bufferLength - Length of output buffers.
139  * @Constraints In case the combined string to be written to flash becomes greater than
140  * permissible, it will be truncated and may lead to unexpected results.
141  * @Return void
142  * @Reentrant No
143  */
144 void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength);
145 
146 #endif // AUTO_DETECTION_SERVICE_H_
ADS_Channel
This defines the allowed communications channels.
ADS_Status
This defines the return status.
#define ADS_FLASH_STRING_LENGTH
char shieldString[ADS_MAX_STRING_LENGTH]
enum ADS_Sensor ADS_Sensor_t
This defines the allowed communications channels.
ADS_FlashStatus_t
This enumeration defines the ADS Flash storage status.
This defines a record type to store ADS results string in Flash memory.
This defines a record type to store the communication channel info and WHO_AM_I address/value for var...
This defines a record type to store the expected field values in the MCU SDID register word aligned...
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
ADS_SupportedBoards_t board
char boardString[ADS_MAX_STRING_LENGTH]
enum ADS_Channel ADS_Channel_t
This defines the allowed communications channels.
enum ADS_Status ADS_Status_t
This defines the return status.
ADS_Sensor
This defines the allowed communications channels.
ADS_SupportedBoards_t
This enumeration defines the FRDM boards that ADS can detect.