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