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 LPC 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 {
79 
80 /*!
81  * @brief This enumeration defines the ADS Flash storage status.
82  */
83 typedef enum
84 {
89 
90 /*!
91  * @brief This defines a record type to store the expected field values of the LPC device ID.
92  */
93 typedef struct
94 {
95  uint32_t mcuDeviceId; // MCU Specific Device ID
96  ADS_SupportedBoards_t board; // MCU Board corresponding to Device ID value.
97 } mcuDEVID_t;
98 
99 /*!
100  * @brief This defines a record type to store the communication channel info and WHO_AM_I address/value for various
101  * Sensor Shields.
102  */
103 typedef struct
104 {
105  ADS_Channel_t channel; // Channel type over which to attempt communications.
106  uint32_t slaveAddr; // I2C Slave Address or Chip-Select value.
107  uint32_t whoAmIAddr; // WHO_AM_I Register Address (Offset).
108  uint32_t whoAmIValue; // WHO_AM_I Register Value.
109  uint8_t whoAmIMask; // The Mask for Fixed who ami i bits for sensors with variants.
111 
112 /*!
113  * @brief This defines a record type to store ADS results string in Flash memory.
114  */
115 typedef struct
116 {
117  uint32_t cookie; // A unique 32-bit value unlikely to be randomly found in Flash.
118  uint32_t length; // Length of the ADS result string in bytes.
119  char ADSString[ADS_FLASH_STRING_LENGTH]; // The ADS results string.
121 
122 /******************************************************************************/
123 /*! @brief The function to register Application Name and initialte ADS.
124  * @details The API will read the Application Name from the user and return
125  * the result string with the ADS detection results. It will also update
126  * the FLASH with the new results.
127  * @param[in] pAppName - pointer to a buffer where the application name is placed.
128  * @param[in/out] boardString - pointer to a buffer to place the ADS board string.
129  * @param[in/out] shieldString - pointer to a buffer to place the ADS shield string.
130  * @param[in] bufferLength - Length of output buffers.
131  * @Constraints In case the combined string to be written to flash becomes greater than
132  * permissible, it will be truncated and may lead to unexpected results.
133  * @Return void
134  * @Reentrant No
135  */
136 void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength);
137 
138 #endif // AUTO_DETECTION_SERVICE_H_
ADS_Channel
This defines the allowed communications channels.
ADS_Status
This defines the return status.
char shieldString[ADS_MAX_STRING_LENGTH]
#define ADS_FLASH_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...
ADS_SupportedBoards_t board
void BOARD_RunADS(const char *appName, char *boardString, char *shieldString, size_t bufferLength)
The function to register Application Name and initialte ADS.
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.
This defines a record type to store the expected field values of the LPC device ID.