AdiSense1000_V21 MBED API

Fork of AdiSense1000 by PoC_Team

Committer:
kevin1990
Date:
Tue Dec 05 19:08:53 2017 +0000
Revision:
16:e4f2689363bb
v1.0_RC2 Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kevin1990 16:e4f2689363bb 1 /*!
kevin1990 16:e4f2689363bb 2 ******************************************************************************
kevin1990 16:e4f2689363bb 3 * @file: adi_sense_lut_data_types.h
kevin1990 16:e4f2689363bb 4 * @brief: Look-Up Table data-type definitions for ADI Sense API.
kevin1990 16:e4f2689363bb 5 *-----------------------------------------------------------------------------
kevin1990 16:e4f2689363bb 6 */
kevin1990 16:e4f2689363bb 7
kevin1990 16:e4f2689363bb 8 /*
kevin1990 16:e4f2689363bb 9 Copyright (c) 2017 Analog Devices, Inc.
kevin1990 16:e4f2689363bb 10
kevin1990 16:e4f2689363bb 11 All rights reserved.
kevin1990 16:e4f2689363bb 12
kevin1990 16:e4f2689363bb 13 Redistribution and use in source and binary forms, with or without modification,
kevin1990 16:e4f2689363bb 14 are permitted provided that the following conditions are met:
kevin1990 16:e4f2689363bb 15 - Redistributions of source code must retain the above copyright notice,
kevin1990 16:e4f2689363bb 16 this list of conditions and the following disclaimer.
kevin1990 16:e4f2689363bb 17 - Redistributions in binary form must reproduce the above copyright notice,
kevin1990 16:e4f2689363bb 18 this list of conditions and the following disclaimer in the documentation
kevin1990 16:e4f2689363bb 19 and/or other materials provided with the distribution.
kevin1990 16:e4f2689363bb 20 - Modified versions of the software must be conspicuously marked as such.
kevin1990 16:e4f2689363bb 21 - This software is licensed solely and exclusively for use with processors
kevin1990 16:e4f2689363bb 22 manufactured by or for Analog Devices, Inc.
kevin1990 16:e4f2689363bb 23 - This software may not be combined or merged with other code in any manner
kevin1990 16:e4f2689363bb 24 that would cause the software to become subject to terms and conditions
kevin1990 16:e4f2689363bb 25 which differ from those listed here.
kevin1990 16:e4f2689363bb 26 - Neither the name of Analog Devices, Inc. nor the names of its
kevin1990 16:e4f2689363bb 27 contributors may be used to endorse or promote products derived
kevin1990 16:e4f2689363bb 28 from this software without specific prior written permission.
kevin1990 16:e4f2689363bb 29 - The use of this software may or may not infringe the patent rights of one
kevin1990 16:e4f2689363bb 30 or more patent holders. This license does not release you from the
kevin1990 16:e4f2689363bb 31 requirement that you obtain separate licenses from these patent holders
kevin1990 16:e4f2689363bb 32 to use this software.
kevin1990 16:e4f2689363bb 33
kevin1990 16:e4f2689363bb 34 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY
kevin1990 16:e4f2689363bb 35 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
kevin1990 16:e4f2689363bb 36 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
kevin1990 16:e4f2689363bb 37 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
kevin1990 16:e4f2689363bb 38 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
kevin1990 16:e4f2689363bb 39 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
kevin1990 16:e4f2689363bb 40 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
kevin1990 16:e4f2689363bb 41 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
kevin1990 16:e4f2689363bb 42 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
kevin1990 16:e4f2689363bb 43 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
kevin1990 16:e4f2689363bb 44 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kevin1990 16:e4f2689363bb 45 */
kevin1990 16:e4f2689363bb 46
kevin1990 16:e4f2689363bb 47 #ifndef __ADI_SENSE_1000_LUT_DATA_H__
kevin1990 16:e4f2689363bb 48 #define __ADI_SENSE_1000_LUT_DATA_H__
kevin1990 16:e4f2689363bb 49
kevin1990 16:e4f2689363bb 50 #include "adi_sense_types.h"
kevin1990 16:e4f2689363bb 51 #include "adi_sense_1000_sensor_types.h"
kevin1990 16:e4f2689363bb 52
kevin1990 16:e4f2689363bb 53 /*! @addtogroup ADI_Sense_1000_Api ADI Sense 1000 Host Library API
kevin1990 16:e4f2689363bb 54 * @{
kevin1990 16:e4f2689363bb 55 */
kevin1990 16:e4f2689363bb 56
kevin1990 16:e4f2689363bb 57 #ifdef __cplusplus
kevin1990 16:e4f2689363bb 58 extern "C" {
kevin1990 16:e4f2689363bb 59 #endif
kevin1990 16:e4f2689363bb 60
kevin1990 16:e4f2689363bb 61 /*! LUT data validation signature */
kevin1990 16:e4f2689363bb 62 #define ADI_SENSE_LUT_SIGNATURE 0x4C555473
kevin1990 16:e4f2689363bb 63
kevin1990 16:e4f2689363bb 64 /*! LUT data CRC-16-CCITT seed value */
kevin1990 16:e4f2689363bb 65 #define ADI_SENSE_LUT_CRC_SEED 0x4153
kevin1990 16:e4f2689363bb 66
kevin1990 16:e4f2689363bb 67 /*! LUT maximum allowed size */
kevin1990 16:e4f2689363bb 68 #define ADI_SENSE_LUT_MAX_SIZE 12288U
kevin1990 16:e4f2689363bb 69
kevin1990 16:e4f2689363bb 70 /*! Linearisation look-up table / co-efficient list geometry */
kevin1990 16:e4f2689363bb 71 typedef enum {
kevin1990 16:e4f2689363bb 72 ADI_SENSE_1000_LUT_GEOMETRY_RESERVED = 0x00,
kevin1990 16:e4f2689363bb 73 /**< reserved - for internal use only */
kevin1990 16:e4f2689363bb 74 ADI_SENSE_1000_LUT_GEOMETRY_COEFFS = 0x01,
kevin1990 16:e4f2689363bb 75 /**< 1-dimensional equation coefficient list */
kevin1990 16:e4f2689363bb 76 ADI_SENSE_1000_LUT_GEOMETRY_NES_1D = 0x02,
kevin1990 16:e4f2689363bb 77 /**< 1-dimensional not-equally-spaced look-up table */
kevin1990 16:e4f2689363bb 78 ADI_SENSE_1000_LUT_GEOMETRY_NES_2D = 0x03,
kevin1990 16:e4f2689363bb 79 /**< 2-dimensional not-equally-spaced look-up table */
kevin1990 16:e4f2689363bb 80 ADI_SENSE_1000_LUT_GEOMETRY_ES_1D = 0x04,
kevin1990 16:e4f2689363bb 81 /**< 1-dimensional equally-spaced look-up table */
kevin1990 16:e4f2689363bb 82 ADI_SENSE_1000_LUT_GEOMETRY_ES_2D = 0x05,
kevin1990 16:e4f2689363bb 83 /**< 2-dimensional equally-spaced look-up table */
kevin1990 16:e4f2689363bb 84 } ADI_SENSE_1000_LUT_GEOMETRY;
kevin1990 16:e4f2689363bb 85
kevin1990 16:e4f2689363bb 86 /*! Linearisation equation type */
kevin1990 16:e4f2689363bb 87 typedef enum {
kevin1990 16:e4f2689363bb 88 ADI_SENSE_1000_LUT_EQUATION_POLYN,
kevin1990 16:e4f2689363bb 89 /**< Polynomial equation, typically used for Thermocouple and RTD
kevin1990 16:e4f2689363bb 90 * linearisation */
kevin1990 16:e4f2689363bb 91 ADI_SENSE_1000_LUT_EQUATION_POLYNEXP,
kevin1990 16:e4f2689363bb 92 /**< Polynomial + exponential equation, typically used for Thermocouple
kevin1990 16:e4f2689363bb 93 * inverse linearisation */
kevin1990 16:e4f2689363bb 94 ADI_SENSE_1000_LUT_EQUATION_QUADRATIC,
kevin1990 16:e4f2689363bb 95 /**< Quadratic linearisation equation, typically used for RTD
kevin1990 16:e4f2689363bb 96 * linearisation */
kevin1990 16:e4f2689363bb 97 ADI_SENSE_1000_LUT_EQUATION_STEINHART,
kevin1990 16:e4f2689363bb 98 /**< Steinhart-Hart equation, typically used for Thermistor
kevin1990 16:e4f2689363bb 99 * linearisation */
kevin1990 16:e4f2689363bb 100 ADI_SENSE_1000_LUT_EQUATION_LOGARITHMIC,
kevin1990 16:e4f2689363bb 101 /**< Beta-based logarithmic equation, typically used for Thermistor
kevin1990 16:e4f2689363bb 102 * linearisation */
kevin1990 16:e4f2689363bb 103 ADI_SENSE_1000_LUT_EQUATION_EXPONENTIAL,
kevin1990 16:e4f2689363bb 104 /**< Exponential equation */
kevin1990 16:e4f2689363bb 105 ADI_SENSE_1000_LUT_EQUATION_BIVARIATE_POLYN,
kevin1990 16:e4f2689363bb 106 /**< Bi-variate polynomial equation, typically used for bridge pressure
kevin1990 16:e4f2689363bb 107 * sensor linearisation
kevin1990 16:e4f2689363bb 108 * @note 2nd-degree is the maximum currently supported
kevin1990 16:e4f2689363bb 109 */
kevin1990 16:e4f2689363bb 110 ADI_SENSE_1000_LUT_EQUATION_COUNT,
kevin1990 16:e4f2689363bb 111 /**< Enum count value - for internal use only */
kevin1990 16:e4f2689363bb 112 ADI_SENSE_1000_LUT_EQUATION_LUT,
kevin1990 16:e4f2689363bb 113 /**< Hard-coded Look-Up Table - for internal use only */
kevin1990 16:e4f2689363bb 114 } ADI_SENSE_1000_LUT_EQUATION;
kevin1990 16:e4f2689363bb 115
kevin1990 16:e4f2689363bb 116 typedef enum {
kevin1990 16:e4f2689363bb 117 ADI_SENSE_1000_LUT_TC_DIRECTION_FORWARD,
kevin1990 16:e4f2689363bb 118 /**< Thermocouple forward (mV to Celsius) linearisation
kevin1990 16:e4f2689363bb 119 * Use this value by default for non-thermocouple sensors */
kevin1990 16:e4f2689363bb 120 ADI_SENSE_1000_LUT_TC_DIRECTION_BACKWARD,
kevin1990 16:e4f2689363bb 121 /**< Thermocouple inverse (Celsius to mV) linearisation */
kevin1990 16:e4f2689363bb 122 ADI_SENSE_1000_LUT_TC_DIRECTION_COUNT,
kevin1990 16:e4f2689363bb 123 /**< Enum count value - for internal use only */
kevin1990 16:e4f2689363bb 124 } ADI_SENSE_1000_LUT_TC_DIRECTION;
kevin1990 16:e4f2689363bb 125
kevin1990 16:e4f2689363bb 126 /*! Linearisation data vector format */
kevin1990 16:e4f2689363bb 127 typedef enum {
kevin1990 16:e4f2689363bb 128 ADI_SENSE_1000_LUT_DATA_TYPE_RESERVED = 0,
kevin1990 16:e4f2689363bb 129 /**< Reserved - for internal use only */
kevin1990 16:e4f2689363bb 130 ADI_SENSE_1000_LUT_DATA_TYPE_FLOAT32 = 1,
kevin1990 16:e4f2689363bb 131 /**< Single-precision 32-bit floating-point */
kevin1990 16:e4f2689363bb 132 ADI_SENSE_1000_LUT_DATA_TYPE_FLOAT64 = 2,
kevin1990 16:e4f2689363bb 133 /**< Double-precision 64-bit floating-point */
kevin1990 16:e4f2689363bb 134 } ADI_SENSE_1000_LUT_DATA_TYPE;
kevin1990 16:e4f2689363bb 135
kevin1990 16:e4f2689363bb 136 /*! Struct for a list of coefficients to be used in an equation */
kevin1990 16:e4f2689363bb 137 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 138 uint32_t nCoeffs;
kevin1990 16:e4f2689363bb 139 /**< number of coefficients */
kevin1990 16:e4f2689363bb 140 float32_t rangeMin;
kevin1990 16:e4f2689363bb 141 /**< look-up table range - minimum */
kevin1990 16:e4f2689363bb 142 float32_t rangeMax;
kevin1990 16:e4f2689363bb 143 /**< look-up table range - maximum */
kevin1990 16:e4f2689363bb 144 float64_t coeffs[];
kevin1990 16:e4f2689363bb 145 /**< C99 flexible array: sorted by ascending exponent in polynomials */
kevin1990 16:e4f2689363bb 146 } ADI_SENSE_1000_LUT_COEFF_LIST;
kevin1990 16:e4f2689363bb 147
kevin1990 16:e4f2689363bb 148 /*! Struct for a 1-dimensional equally-spaced look-up table */
kevin1990 16:e4f2689363bb 149 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 150 uint32_t nElements;
kevin1990 16:e4f2689363bb 151 /**< number of elements. */
kevin1990 16:e4f2689363bb 152 float32_t initInputValue;
kevin1990 16:e4f2689363bb 153 /**< initial input value, corresponding to first table element */
kevin1990 16:e4f2689363bb 154 float32_t inputValueIncrement;
kevin1990 16:e4f2689363bb 155 /**< interval between successive input values */
kevin1990 16:e4f2689363bb 156 float32_t lut[];
kevin1990 16:e4f2689363bb 157 /**< C99 flexible array */
kevin1990 16:e4f2689363bb 158 } ADI_SENSE_1000_LUT_1D_ES;
kevin1990 16:e4f2689363bb 159
kevin1990 16:e4f2689363bb 160 /*! Struct for a 1-dimensional not-equally-spaced look-up table */
kevin1990 16:e4f2689363bb 161 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 162 uint32_t nElements;
kevin1990 16:e4f2689363bb 163 /**< number of elements of each array. */
kevin1990 16:e4f2689363bb 164 float32_t lut[];
kevin1990 16:e4f2689363bb 165 /**< C99 flexible array, first X's array then Y's array*/
kevin1990 16:e4f2689363bb 166 } ADI_SENSE_1000_LUT_1D_NES;
kevin1990 16:e4f2689363bb 167
kevin1990 16:e4f2689363bb 168 /*! Struct for a 2-dimensional equally-spaced look-up table */
kevin1990 16:e4f2689363bb 169 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 170 uint16_t nElementsX;
kevin1990 16:e4f2689363bb 171 /**< number of elements for input X. */
kevin1990 16:e4f2689363bb 172 uint16_t nElementsY;
kevin1990 16:e4f2689363bb 173 /**< number of elements for input Y. */
kevin1990 16:e4f2689363bb 174 float32_t initInputValueX;
kevin1990 16:e4f2689363bb 175 /**< initial X input value */
kevin1990 16:e4f2689363bb 176 float32_t inputValueIncrementX;
kevin1990 16:e4f2689363bb 177 /**< interval between successive X input values */
kevin1990 16:e4f2689363bb 178 float32_t initInputValueY;
kevin1990 16:e4f2689363bb 179 /**< initial Y input value */
kevin1990 16:e4f2689363bb 180 float32_t inputValueIncrementY;
kevin1990 16:e4f2689363bb 181 /**< interval between successive Y input values */
kevin1990 16:e4f2689363bb 182 float32_t lut[];
kevin1990 16:e4f2689363bb 183 /**< C99 flexible array, Z matrix[y][x] */
kevin1990 16:e4f2689363bb 184 } ADI_SENSE_1000_LUT_2D_ES;
kevin1990 16:e4f2689363bb 185
kevin1990 16:e4f2689363bb 186 /*! Struct for a 2-dimensional not-equally-spaced look-up table */
kevin1990 16:e4f2689363bb 187 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 188 uint16_t nElementsX;
kevin1990 16:e4f2689363bb 189 /**< number of elements in array X. */
kevin1990 16:e4f2689363bb 190 uint16_t nElementsY;
kevin1990 16:e4f2689363bb 191 /**< number of elements in array Y. */
kevin1990 16:e4f2689363bb 192 float32_t lut[];
kevin1990 16:e4f2689363bb 193 /**< C99 flexible array, Order: X's array, Y's array, Z matrix[y][x] */
kevin1990 16:e4f2689363bb 194 } ADI_SENSE_1000_LUT_2D_NES;
kevin1990 16:e4f2689363bb 195
kevin1990 16:e4f2689363bb 196 /*! Struct for a 2-dimensional list of coefficients to be used in a
kevin1990 16:e4f2689363bb 197 * bi-variate polynomial equation */
kevin1990 16:e4f2689363bb 198 typedef struct __attribute__((packed, aligned(4))){
kevin1990 16:e4f2689363bb 199 uint32_t maxDegree;
kevin1990 16:e4f2689363bb 200 /**< number of coefficients */
kevin1990 16:e4f2689363bb 201 float32_t rangeMinX;
kevin1990 16:e4f2689363bb 202 /**< look-up table range - minimum X input value */
kevin1990 16:e4f2689363bb 203 float32_t rangeMaxX;
kevin1990 16:e4f2689363bb 204 /**< look-up table range - maximum X input value */
kevin1990 16:e4f2689363bb 205 float32_t rangeMinY;
kevin1990 16:e4f2689363bb 206 /**< look-up table range - minimum Y input value */
kevin1990 16:e4f2689363bb 207 float32_t rangeMaxY;
kevin1990 16:e4f2689363bb 208 /**< look-up table range - maximum Y input value */
kevin1990 16:e4f2689363bb 209 float64_t coeffs[];
kevin1990 16:e4f2689363bb 210 /**< C99 flexible array: sorted by ascending X degree then sorted by
kevin1990 16:e4f2689363bb 211 * ascending Y exponent */
kevin1990 16:e4f2689363bb 212 } ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST;
kevin1990 16:e4f2689363bb 213
kevin1990 16:e4f2689363bb 214 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 215 * a @ref ADI_SENSE_1000_LUT_COEFF_LIST table */
kevin1990 16:e4f2689363bb 216 #define ADI_SENSE_1000_LUT_COEFF_LIST_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 217 ((_t).nCoeffs)
kevin1990 16:e4f2689363bb 218
kevin1990 16:e4f2689363bb 219 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 220 * a @ref ADI_SENSE_1000_LUT_1D_ES table */
kevin1990 16:e4f2689363bb 221 #define ADI_SENSE_1000_LUT_1D_ES_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 222 ((_t).nElements)
kevin1990 16:e4f2689363bb 223
kevin1990 16:e4f2689363bb 224 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 225 * a @ref ADI_SENSE_1000_LUT_1D_NES table */
kevin1990 16:e4f2689363bb 226 #define ADI_SENSE_1000_LUT_1D_NES_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 227 ((_t).nElements * 2)
kevin1990 16:e4f2689363bb 228
kevin1990 16:e4f2689363bb 229 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 230 * a @ref ADI_SENSE_1000_LUT_2D_ES table */
kevin1990 16:e4f2689363bb 231 #define ADI_SENSE_1000_LUT_2D_ES_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 232 ((_t).nElementsX * (_t).nElementsX)
kevin1990 16:e4f2689363bb 233
kevin1990 16:e4f2689363bb 234 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 235 * a @ref ADI_SENSE_1000_LUT_2D_NES table */
kevin1990 16:e4f2689363bb 236 #define ADI_SENSE_1000_LUT_2D_NES_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 237 ((_t).nElementsX + (_t).nElementsY + ((_t).nElementsX * (_t).nElementsY))
kevin1990 16:e4f2689363bb 238
kevin1990 16:e4f2689363bb 239 /*! Macro to calculate the number of elements in
kevin1990 16:e4f2689363bb 240 * a @ref ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST table */
kevin1990 16:e4f2689363bb 241 #define ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST_NELEMENTS(_t) \
kevin1990 16:e4f2689363bb 242 (((_t).maxDegree + 1) * ((_t).maxDegree + 2) / 2)
kevin1990 16:e4f2689363bb 243
kevin1990 16:e4f2689363bb 244 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 245 * a @ref ADI_SENSE_1000_LUT_COEFF_LIST table */
kevin1990 16:e4f2689363bb 246 #define ADI_SENSE_1000_LUT_COEFF_LIST_SIZE(_t) \
kevin1990 16:e4f2689363bb 247 (sizeof(_t) + (sizeof(float64_t) * ADI_SENSE_1000_LUT_COEFF_LIST_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 248
kevin1990 16:e4f2689363bb 249 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 250 * a @ref ADI_SENSE_1000_LUT_1D_ES table */
kevin1990 16:e4f2689363bb 251 #define ADI_SENSE_1000_LUT_1D_ES_SIZE(_t) \
kevin1990 16:e4f2689363bb 252 (sizeof(_t) + (sizeof(float32_t) * ADI_SENSE_1000_LUT_1D_ES_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 253
kevin1990 16:e4f2689363bb 254 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 255 * a @ref ADI_SENSE_1000_LUT_1D_NES table */
kevin1990 16:e4f2689363bb 256 #define ADI_SENSE_1000_LUT_1D_NES_SIZE(_t) \
kevin1990 16:e4f2689363bb 257 (sizeof(_t) + (sizeof(float32_t) * ADI_SENSE_1000_LUT_1D_NES_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 258
kevin1990 16:e4f2689363bb 259 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 260 * a @ref ADI_SENSE_1000_LUT_2D_ES table */
kevin1990 16:e4f2689363bb 261 #define ADI_SENSE_1000_LUT_2D_ES_SIZE(_t) \
kevin1990 16:e4f2689363bb 262 (sizeof(_t) + (sizeof(float32_t) * ADI_SENSE_1000_LUT_2D_ES_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 263
kevin1990 16:e4f2689363bb 264 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 265 * a @ref ADI_SENSE_1000_LUT_2D_NES table */
kevin1990 16:e4f2689363bb 266 #define ADI_SENSE_1000_LUT_2D_NES_SIZE(_t) \
kevin1990 16:e4f2689363bb 267 (sizeof(_t) + (sizeof(float32_t) * ADI_SENSE_1000_LUT_2D_NES_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 268
kevin1990 16:e4f2689363bb 269 /*! Macro to calculate the storage size in bytes of
kevin1990 16:e4f2689363bb 270 * a @ref ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST table */
kevin1990 16:e4f2689363bb 271 #define ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST_SIZE(_t) \
kevin1990 16:e4f2689363bb 272 (sizeof(_t) + (sizeof(float64_t) * ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST_NELEMENTS(_t)))
kevin1990 16:e4f2689363bb 273
kevin1990 16:e4f2689363bb 274 /*! Look-Up Table descriptor */
kevin1990 16:e4f2689363bb 275 typedef union __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 276 struct {
kevin1990 16:e4f2689363bb 277 ADI_SENSE_1000_LUT_GEOMETRY geometry : 6;
kevin1990 16:e4f2689363bb 278 /**< Table geometry */
kevin1990 16:e4f2689363bb 279 ADI_SENSE_1000_LUT_EQUATION equation : 6;
kevin1990 16:e4f2689363bb 280 /**< Equation type */
kevin1990 16:e4f2689363bb 281 ADI_SENSE_1000_LUT_TC_DIRECTION dir : 4;
kevin1990 16:e4f2689363bb 282 /**< Thermocouple linearisation direction */
kevin1990 16:e4f2689363bb 283 ADI_SENSE_1000_ADC_SENSOR_TYPE sensor : 12;
kevin1990 16:e4f2689363bb 284 /**< Sensor Type ID */
kevin1990 16:e4f2689363bb 285 ADI_SENSE_1000_LUT_DATA_TYPE dataType : 4;
kevin1990 16:e4f2689363bb 286 /**< Table vector data type */
kevin1990 16:e4f2689363bb 287 uint16_t length;
kevin1990 16:e4f2689363bb 288 /**< Length in bytes of table data section
kevin1990 16:e4f2689363bb 289 * (excluding this header) */
kevin1990 16:e4f2689363bb 290 uint16_t crc16;
kevin1990 16:e4f2689363bb 291 /**< CRC-16-CCITT of the data */
kevin1990 16:e4f2689363bb 292 };
kevin1990 16:e4f2689363bb 293 uint64_t value64;
kevin1990 16:e4f2689363bb 294 } ADI_SENSE_1000_LUT_DESCRIPTOR;
kevin1990 16:e4f2689363bb 295
kevin1990 16:e4f2689363bb 296 /*! Look-Up Table geometry-specific data structures */
kevin1990 16:e4f2689363bb 297 typedef union {
kevin1990 16:e4f2689363bb 298 ADI_SENSE_1000_LUT_COEFF_LIST coeffList;
kevin1990 16:e4f2689363bb 299 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_COEFFS geometry
kevin1990 16:e4f2689363bb 300 * except where equation is ADI_SENSE_1000_LUT_EQUATION_BIVARIATE_POLYN */
kevin1990 16:e4f2689363bb 301 ADI_SENSE_1000_LUT_1D_ES lut1dEs;
kevin1990 16:e4f2689363bb 302 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_ES_1D geometry */
kevin1990 16:e4f2689363bb 303 ADI_SENSE_1000_LUT_1D_NES lut1dNes;
kevin1990 16:e4f2689363bb 304 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_NES_1D geometry */
kevin1990 16:e4f2689363bb 305 ADI_SENSE_1000_LUT_2D_ES lut2dEs;
kevin1990 16:e4f2689363bb 306 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_ES_2D geometry */
kevin1990 16:e4f2689363bb 307 ADI_SENSE_1000_LUT_2D_NES lut2dNes;
kevin1990 16:e4f2689363bb 308 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_NES_2D geometry */
kevin1990 16:e4f2689363bb 309 ADI_SENSE_1000_LUT_2D_POLYN_COEFF_LIST coeffList2d;
kevin1990 16:e4f2689363bb 310 /**< Data format for tables with ADI_SENSE_1000_LUT_GEOMETRY_COEFFS geometry
kevin1990 16:e4f2689363bb 311 * and ADI_SENSE_1000_LUT_EQUATION_BIVARIATE_POLYN equation */
kevin1990 16:e4f2689363bb 312 } ADI_SENSE_1000_LUT_TABLE_DATA;
kevin1990 16:e4f2689363bb 313
kevin1990 16:e4f2689363bb 314 /*! Look-Up Table structure */
kevin1990 16:e4f2689363bb 315 typedef struct __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 316 ADI_SENSE_1000_LUT_DESCRIPTOR descriptor;
kevin1990 16:e4f2689363bb 317 /**< Look-Up Table descriptor */
kevin1990 16:e4f2689363bb 318 ADI_SENSE_1000_LUT_TABLE_DATA data;
kevin1990 16:e4f2689363bb 319 /**< Look-Up Table data */
kevin1990 16:e4f2689363bb 320 } ADI_SENSE_1000_LUT_TABLE;
kevin1990 16:e4f2689363bb 321
kevin1990 16:e4f2689363bb 322 /*! LUT data format versions */
kevin1990 16:e4f2689363bb 323 typedef struct __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 324 uint8_t major; /*!< Major version number */
kevin1990 16:e4f2689363bb 325 uint8_t minor; /*!< Minor version number */
kevin1990 16:e4f2689363bb 326 } ADI_SENSE_1000_LUT_VERSION;
kevin1990 16:e4f2689363bb 327
kevin1990 16:e4f2689363bb 328 /*! LUT data header structure */
kevin1990 16:e4f2689363bb 329 typedef struct __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 330 uint32_t signature;
kevin1990 16:e4f2689363bb 331 /**< Hard-coded signature value (@ref ADI_SENSE_LUT_SIGNATURE) */
kevin1990 16:e4f2689363bb 332 ADI_SENSE_1000_LUT_VERSION version;
kevin1990 16:e4f2689363bb 333 /**< LUT data format version (@ref ADI_SENSE_LUT_VERSION) */
kevin1990 16:e4f2689363bb 334 uint16_t numTables;
kevin1990 16:e4f2689363bb 335 /**< Total number of tables */
kevin1990 16:e4f2689363bb 336 uint32_t totalLength;
kevin1990 16:e4f2689363bb 337 /**< Total length (in bytes) of all table descriptors and data
kevin1990 16:e4f2689363bb 338 * (excluding this header)
kevin1990 16:e4f2689363bb 339 * This, plus the header length, must not exceed ADI_SENSE_LUT_MAX_SIZE
kevin1990 16:e4f2689363bb 340 */
kevin1990 16:e4f2689363bb 341 } ADI_SENSE_1000_LUT_HEADER;
kevin1990 16:e4f2689363bb 342
kevin1990 16:e4f2689363bb 343 /*! LUT data top-level structure */
kevin1990 16:e4f2689363bb 344 typedef struct __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 345 ADI_SENSE_1000_LUT_HEADER header;
kevin1990 16:e4f2689363bb 346 /*!< LUT data top-level header structure */
kevin1990 16:e4f2689363bb 347 ADI_SENSE_1000_LUT_TABLE tables[];
kevin1990 16:e4f2689363bb 348 /*!< Variable-length array of one-or-more look-up table structures */
kevin1990 16:e4f2689363bb 349 } ADI_SENSE_1000_LUT;
kevin1990 16:e4f2689363bb 350
kevin1990 16:e4f2689363bb 351 /*! Alternative top-level structure for raw LUT data representation
kevin1990 16:e4f2689363bb 352 *
kevin1990 16:e4f2689363bb 353 * @note This is intended to be used for encapsulating the storage of static
kevin1990 16:e4f2689363bb 354 * LUT data declarations in C files. The rawTableData can be cast
kevin1990 16:e4f2689363bb 355 * to the ADI_SENSE_LUT type for further parsing/processing.
kevin1990 16:e4f2689363bb 356 */
kevin1990 16:e4f2689363bb 357 typedef struct __attribute__((packed, aligned(4))) {
kevin1990 16:e4f2689363bb 358 ADI_SENSE_1000_LUT_HEADER header;
kevin1990 16:e4f2689363bb 359 /*!< LUT data top-level header structure */
kevin1990 16:e4f2689363bb 360 uint8_t rawTableData[];
kevin1990 16:e4f2689363bb 361 /*!< Variable-length byte array of look-up tables in raw binary format */
kevin1990 16:e4f2689363bb 362 } ADI_SENSE_1000_LUT_RAW;
kevin1990 16:e4f2689363bb 363
kevin1990 16:e4f2689363bb 364 #ifdef __cplusplus
kevin1990 16:e4f2689363bb 365 }
kevin1990 16:e4f2689363bb 366 #endif
kevin1990 16:e4f2689363bb 367
kevin1990 16:e4f2689363bb 368 /*!
kevin1990 16:e4f2689363bb 369 * @}
kevin1990 16:e4f2689363bb 370 */
kevin1990 16:e4f2689363bb 371
kevin1990 16:e4f2689363bb 372 #endif /* __ADI_SENSE_1000_LUT_DATA_H__ */
kevin1990 16:e4f2689363bb 373