Analog Devices / ADMX2001
Committer:
nsheth
Date:
Tue Nov 09 10:26:59 2021 +0000
Revision:
11:071709f5f7d4
Parent:
10:49537b1dbbd7
Refactoring and formatting

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nsheth 9:f286301109fb 1 /* Copyright (c) 2021 Analog Devices, Inc. All rights reserved.
nsheth 9:f286301109fb 2
nsheth 9:f286301109fb 3 Redistribution and use in source and binary forms, with or without modification,
nsheth 9:f286301109fb 4 are permitted provided that the following conditions are met:
nsheth 9:f286301109fb 5 - Redistributions of source code must retain the above copyright notice,
nsheth 9:f286301109fb 6 this list of conditions and the following disclaimer.
nsheth 9:f286301109fb 7 - Redistributions in binary form must reproduce the above copyright notice,
nsheth 9:f286301109fb 8 this list of conditions and the following disclaimer in the documentation
nsheth 9:f286301109fb 9 and/or other materials provided with the distribution.
nsheth 9:f286301109fb 10 - Modified versions of the software must be conspicuously marked as such.
nsheth 9:f286301109fb 11 - This software is licensed solely and exclusively for use with processors/products
nsheth 9:f286301109fb 12 manufactured by or for Analog Devices, Inc.
nsheth 9:f286301109fb 13 - This software may not be combined or merged with other code in any manner
nsheth 9:f286301109fb 14 that would cause the software to become subject to terms and conditions which
nsheth 9:f286301109fb 15 differ from those listed here.
nsheth 9:f286301109fb 16 - Neither the name of Analog Devices, Inc. nor the names of its contributors
nsheth 9:f286301109fb 17 may be used to endorse or promote products derived from this software without
nsheth 9:f286301109fb 18 specific prior written permission.
nsheth 9:f286301109fb 19 - The use of this software may or may not infringe the patent rights of one or
nsheth 9:f286301109fb 20 more patent holders. This license does not release you from the requirement
nsheth 9:f286301109fb 21 that you obtain separate licenses from these patent holders to use this software.
nsheth 9:f286301109fb 22
nsheth 9:f286301109fb 23 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND
nsheth 9:f286301109fb 24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
nsheth 9:f286301109fb 25 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
nsheth 9:f286301109fb 26 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
nsheth 9:f286301109fb 27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
nsheth 9:f286301109fb 28 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
nsheth 9:f286301109fb 29 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
nsheth 9:f286301109fb 30 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nsheth 9:f286301109fb 31 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
nsheth 9:f286301109fb 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
nsheth 9:f286301109fb 33 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nsheth 9:f286301109fb 34
nsheth 9:f286301109fb 35 2021-01-10-7CBSD SLA
nsheth 9:f286301109fb 36 */
nsheth 10:49537b1dbbd7 37
nsheth 3:81d1980d45aa 38 /**
nsheth 9:f286301109fb 39 * @file ADMX2001_commands.h
nsheth 3:81d1980d45aa 40 * @brief This file contains Macros for the SPI Commands
nsheth 3:81d1980d45aa 41 */
nsheth 3:81d1980d45aa 42
nsheth 3:81d1980d45aa 43 #ifndef __ADMX200X_COMMANDS_H__
nsheth 3:81d1980d45aa 44 #define __ADMX200X_COMMANDS_H__
nsheth 3:81d1980d45aa 45
nsheth 3:81d1980d45aa 46 /** Bit mask to indicate read or write */
nsheth 3:81d1980d45aa 47 #define CMD_READ_BITM 0x80
nsheth 3:81d1980d45aa 48
nsheth 10:49537b1dbbd7 49 /** Length of a command */
nsheth 3:81d1980d45aa 50 #define ADMX200X_CMD_LENGTH 7
nsheth 3:81d1980d45aa 51
nsheth 3:81d1980d45aa 52 /** Basic commands */
nsheth 3:81d1980d45aa 53 /** Read status */
nsheth 3:81d1980d45aa 54 #define CMD_STATUS_READ 0x00U
nsheth 3:81d1980d45aa 55 /** Read result */
nsheth 3:81d1980d45aa 56 #define CMD_RESULT_READ 0x01
nsheth 3:81d1980d45aa 57 /** Clear error */
nsheth 3:81d1980d45aa 58 #define CMD_CLEAR_ERROR 0x02
nsheth 3:81d1980d45aa 59 /** Read fifo */
nsheth 3:81d1980d45aa 60 #define CMD_FIFO_READ 0x03
nsheth 10:49537b1dbbd7 61 /** Command to calibrate */
nsheth 3:81d1980d45aa 62 #define CMD_CALIBRATE 0x04
nsheth 10:49537b1dbbd7 63 /** Command to read compensation value */
nsheth 3:81d1980d45aa 64 #define CMD_COMPENSATION 0x5
nsheth 10:49537b1dbbd7 65 /** Command to read calibration coefficient */
nsheth 3:81d1980d45aa 66 #define CMD_CAL_READ 0x06
nsheth 10:49537b1dbbd7 67 /** Command to store calibration coefficient */
nsheth 3:81d1980d45aa 68 #define CMD_STORE_CAL 0x08
nsheth 10:49537b1dbbd7 69 /** Command to store calibration coefficient */
nsheth 3:81d1980d45aa 70 #define CMD_RESET_CAL 0x09
nsheth 3:81d1980d45aa 71 /** Command to swithc on or off error check */
nsheth 3:81d1980d45aa 72 #define CMD_ERR_CHECK 0xa
nsheth 3:81d1980d45aa 73 /** Command to swithc on or off error check */
nsheth 3:81d1980d45aa 74 #define CMD_SELF_TEST 0xb
nsheth 10:49537b1dbbd7 75 /** Command to read calibration coefficient */
nsheth 3:81d1980d45aa 76 #define CMD_COMP_READ 0xc
nsheth 10:49537b1dbbd7 77 /** Command to store calibration coefficient */
nsheth 3:81d1980d45aa 78 #define CMD_STORE_COMP 0xd
nsheth 3:81d1980d45aa 79 /** Command to read temperature */
nsheth 3:81d1980d45aa 80 #define CMD_TEMPERATURE 0xe
nsheth 3:81d1980d45aa 81 /** Command Z */
nsheth 3:81d1980d45aa 82 #define CMD_Z 0xf
nsheth 3:81d1980d45aa 83 /** Read sweep points */
nsheth 3:81d1980d45aa 84 #define CMD_READ_SWEEP_POINTS 0x11
nsheth 3:81d1980d45aa 85 /** Reset */
nsheth 3:81d1980d45aa 86 #define CMD_RESET 0x12
nsheth 3:81d1980d45aa 87 /** Current gain table */
nsheth 3:81d1980d45aa 88 #define CMD_CURRENT_GAIN_TABLE 0x13
nsheth 3:81d1980d45aa 89 /** Voltage gain table */
nsheth 3:81d1980d45aa 90 #define CMD_VOLTAGE_GAIN_TABLE 0x14
nsheth 3:81d1980d45aa 91 /** Version Details */
nsheth 3:81d1980d45aa 92 #define CMD_VERSION 0x15
nsheth 10:49537b1dbbd7 93 /** Command to read or write spi regsiters */
nsheth 3:81d1980d45aa 94 #define CMD_IP_REGISTERS 0x16
nsheth 10:49537b1dbbd7 95 /** Initiates the measurement */
nsheth 3:81d1980d45aa 96 #define CMD_INITIATE (0x17)
nsheth 10:49537b1dbbd7 97 /** Triggers the measurement */
nsheth 3:81d1980d45aa 98 #define CMD_TRIGGER (0x18)
nsheth 10:49537b1dbbd7 99 /** Fetch the last measurement */
nsheth 3:81d1980d45aa 100 #define CMD_FETCH (0x19)
nsheth 10:49537b1dbbd7 101 /** Aborts the measurement */
nsheth 3:81d1980d45aa 102 #define CMD_ABORT (0x1a)
nsheth 3:81d1980d45aa 103 /** Calibration commit command */
nsheth 3:81d1980d45aa 104 #define CMD_CAL_COMMIT (0x1b)
nsheth 10:49537b1dbbd7 105 /** Calibration commit password set */
nsheth 3:81d1980d45aa 106 #define CMD_SET_PASSWORD (0x1c)
nsheth 10:49537b1dbbd7 107 /** Calibration commit get password */
nsheth 3:81d1980d45aa 108 #define CMD_GET_PASSWORD (0x1d)
nsheth 3:81d1980d45aa 109 /** Command to read or write spi regsiters with address more than uint16 */
nsheth 3:81d1980d45aa 110 #define CMD_IP_REGISTERS_U32 (0x1e)
nsheth 3:81d1980d45aa 111
nsheth 3:81d1980d45aa 112 /** Base of attribute commands */
nsheth 3:81d1980d45aa 113 #define CMD_ATTR_BASE (0x20)
nsheth 10:49537b1dbbd7 114 /** lcr frequecny */
nsheth 3:81d1980d45aa 115 #define CMD_FREQUENCY (CMD_ATTR_BASE + 3)
nsheth 10:49537b1dbbd7 116 /** lcr integration time */
nsheth 3:81d1980d45aa 117 #define CMD_INTEGRATION (CMD_ATTR_BASE + 4)
nsheth 10:49537b1dbbd7 118 /** dds magnitude */
nsheth 3:81d1980d45aa 119 #define CMD_MAGNITUDE (CMD_ATTR_BASE + 5)
nsheth 10:49537b1dbbd7 120 /** dds offset */
nsheth 3:81d1980d45aa 121 #define CMD_OFFSET (CMD_ATTR_BASE + 6)
nsheth 10:49537b1dbbd7 122 /** dds gain */
nsheth 3:81d1980d45aa 123 #define CMD_DDS_GAIN (CMD_ATTR_BASE + 7)
nsheth 10:49537b1dbbd7 124 /** lcr voltage gain */
nsheth 3:81d1980d45aa 125 #define CMD_VOLTAGE_GAIN (CMD_ATTR_BASE + 8)
nsheth 10:49537b1dbbd7 126 /** lcr current gain */
nsheth 3:81d1980d45aa 127 #define CMD_CURRENT_GAIN (CMD_ATTR_BASE + 9)
nsheth 10:49537b1dbbd7 128 /** lcr average */
nsheth 3:81d1980d45aa 129 #define CMD_AVERAGE (CMD_ATTR_BASE + 10)
nsheth 10:49537b1dbbd7 130 /** lcr measurement delay */
nsheth 3:81d1980d45aa 131 #define CMD_MDELAY (CMD_ATTR_BASE + 11)
nsheth 10:49537b1dbbd7 132 /** lcr trigger delay */
nsheth 3:81d1980d45aa 133 #define CMD_TDELAY (CMD_ATTR_BASE + 12)
nsheth 10:49537b1dbbd7 134 /** lcr trigger count */
nsheth 3:81d1980d45aa 135 #define CMD_TCOUNT (CMD_ATTR_BASE + 13)
nsheth 10:49537b1dbbd7 136 /** Sweep Start */
nsheth 3:81d1980d45aa 137 #define CMD_SWEEP_START (CMD_ATTR_BASE + 16)
nsheth 3:81d1980d45aa 138 /** Sweep End*/
nsheth 3:81d1980d45aa 139 #define CMD_SWEEP_END (CMD_ATTR_BASE + 17)
nsheth 10:49537b1dbbd7 140 /** Sweep Type */
nsheth 3:81d1980d45aa 141 #define CMD_SWEEP_TYPE (CMD_ATTR_BASE + 18)
nsheth 3:81d1980d45aa 142 /** lcr sweep scale log or linear */
nsheth 3:81d1980d45aa 143 #define CMD_SWEEP_SCALE (CMD_ATTR_BASE + 19)
nsheth 10:49537b1dbbd7 144 /** lcr cycles */
nsheth 3:81d1980d45aa 145 #define CMD_CYCLES (CMD_ATTR_BASE + 20)
nsheth 10:49537b1dbbd7 146 /** lcr celsius */
nsheth 3:81d1980d45aa 147 #define CMD_CELSIUS (CMD_ATTR_BASE + 27)
nsheth 10:49537b1dbbd7 148 /** lcr radians */
nsheth 3:81d1980d45aa 149 #define CMD_RADIANS (CMD_ATTR_BASE + 28)
nsheth 10:49537b1dbbd7 150 /** lcr lock */
nsheth 3:81d1980d45aa 151 #define CMD_LOCK (CMD_ATTR_BASE + 29)
nsheth 10:49537b1dbbd7 152 /** lcr display */
nsheth 3:81d1980d45aa 153 #define CMD_DISPLAY (CMD_ATTR_BASE + 33)
nsheth 10:49537b1dbbd7 154 /** lcr sample count */
nsheth 3:81d1980d45aa 155 #define CMD_COUNT (CMD_ATTR_BASE + 34)
nsheth 10:49537b1dbbd7 156 /** lcr correction mode */
nsheth 3:81d1980d45aa 157 #define CMD_CORRECTION_MODE (CMD_ATTR_BASE + 35)
nsheth 10:49537b1dbbd7 158 /** Check ADC and FIFO overflow */
nsheth 3:81d1980d45aa 159 #define CMD_OVERFLOW_CHECK (CMD_ATTR_BASE + 36)
nsheth 3:81d1980d45aa 160 /** DC resistance mode */
nsheth 3:81d1980d45aa 161 #define CMD_RESISTANCE_MODE (CMD_ATTR_BASE + 37)
nsheth 3:81d1980d45aa 162 /** Enable Auto range gain for ADC channels */
nsheth 3:81d1980d45aa 163 #define CMD_ENABLE_AUTORANGE (CMD_ATTR_BASE + 38)
nsheth 3:81d1980d45aa 164 /** Minimum sample clocks */
nsheth 3:81d1980d45aa 165 #define CMD_SAMPLE_CLOCKS (CMD_ATTR_BASE + 39)
nsheth 3:81d1980d45aa 166 /** Check echo mode is enabled or disabled */
nsheth 3:81d1980d45aa 167 #define CMD_ECHO_MODE (CMD_ATTR_BASE + 40)
nsheth 3:81d1980d45aa 168 /** Sets and checks boards revision */
nsheth 3:81d1980d45aa 169 #define CMD_BOARD_REV (CMD_ATTR_BASE + 41)
nsheth 3:81d1980d45aa 170 /** Trigger mode */
nsheth 3:81d1980d45aa 171 #define CMD_TRIGGER_MODE (CMD_ATTR_BASE + 42)
nsheth 10:49537b1dbbd7 172 /** State of behaviour model - only read allowed */
nsheth 3:81d1980d45aa 173 #define CMD_STATE ((CMD_ATTR_BASE + 45) | CMD_READ_BITM)
nsheth 3:81d1980d45aa 174 /** Actual measurement count value */
nsheth 3:81d1980d45aa 175 #define CMD_ACTUAL_COUNT (CMD_ATTR_BASE + 47)
nsheth 3:81d1980d45aa 176 /** Check if vector display mode is enabled */
nsheth 3:81d1980d45aa 177 #define CMD_SELF_TEST_STATUS (CMD_ATTR_BASE + 49)
nsheth 10:49537b1dbbd7 178 /** Unique ID - addr0 - lower 32 , addr 1 upper 32 */
nsheth 3:81d1980d45aa 179 #define CMD_UNIQUE_ID (CMD_ATTR_BASE + 50)
nsheth 3:81d1980d45aa 180 /** Warning Message Type */
nsheth 3:81d1980d45aa 181 #define CMD_WARNING_TYPE (CMD_ATTR_BASE + 51)
nsheth 3:81d1980d45aa 182
nsheth 10:49537b1dbbd7 183 /** Not defined or unsupported command */
nsheth 3:81d1980d45aa 184 #define CMD_NOT_DEFINED 0xFF
nsheth 3:81d1980d45aa 185
nsheth 3:81d1980d45aa 186 /** Bit mask for measure done bit */
nsheth 3:81d1980d45aa 187 #define ADMX200X_STATUS_MEASURE_DONE_BITM 0x80000000
nsheth 3:81d1980d45aa 188 /** Bit mask for done field bits */
nsheth 3:81d1980d45aa 189 #define ADMX200X_STATUS_DONE_BITM 0x40000000
nsheth 3:81d1980d45aa 190 /** Bit mask for status field bits */
nsheth 3:81d1980d45aa 191 #define ADMX200X_STATUS_ERROR_BITM 0x20000000
nsheth 3:81d1980d45aa 192 /** Bit mask for warning field bits */
nsheth 3:81d1980d45aa 193 #define ADMX200X_STATUS_WARN_BITM 0x10000000
nsheth 3:81d1980d45aa 194 /** Bit mask for fifo error */
nsheth 3:81d1980d45aa 195 #define ADMX200X_STATUS_FIFO_ERROR_BITM 0x08000000
nsheth 3:81d1980d45aa 196 /** Bit mask for fifo depth field bits */
nsheth 3:81d1980d45aa 197 #define ADMX200X_STATUS_FIFO_DEPTH_BITM 0x03FF0000
nsheth 3:81d1980d45aa 198 /** Bit mask for command result code field bits */
nsheth 3:81d1980d45aa 199 #define ADMX200X_STATUS_CODE_BITM 0x0000FFFF
nsheth 3:81d1980d45aa 200
nsheth 10:49537b1dbbd7 201 /** Success */
nsheth 3:81d1980d45aa 202 #define ADMX_STATUS_SUCCESS 0
nsheth 10:49537b1dbbd7 203 /** Failed */
nsheth 3:81d1980d45aa 204 #define ADMX_STATUS_FAILED 1
nsheth 10:49537b1dbbd7 205 /** Timeout */
nsheth 3:81d1980d45aa 206 #define ADMX_STATUS_TIMEOUT 2
nsheth 3:81d1980d45aa 207 /** Invalid attribute */
nsheth 3:81d1980d45aa 208 #define ADMX_STATUS_INVALID_ATTRIBUTE 3
nsheth 3:81d1980d45aa 209 /** Attribute value out of range */
nsheth 3:81d1980d45aa 210 #define ADMX_STATUS_ATTR_OUT_OF_RANGE 4
nsheth 10:49537b1dbbd7 211 /** Invalid address of tcommand */
nsheth 3:81d1980d45aa 212 #define ADMX_STATUS_INVALID_ADDRESS 5
nsheth 3:81d1980d45aa 213 /** Uncommitted calibration coeffs */
nsheth 3:81d1980d45aa 214 #define ADMX_STATUS_UNCOMMITED_CAL 6
nsheth 3:81d1980d45aa 215 /** Invalid current gain*/
nsheth 3:81d1980d45aa 216 #define ADMX_STATUS_INVALID_CURRENT_GAIN 7
nsheth 3:81d1980d45aa 217 /** Invalid display mode*/
nsheth 3:81d1980d45aa 218 #define ADMX_STATUS_INVALID_DISPLAY_MODE 8
nsheth 3:81d1980d45aa 219 /** Sweep type not valid */
nsheth 3:81d1980d45aa 220 #define ADMX_STATUS_INVALID_SWEEP_TYPE 9
nsheth 3:81d1980d45aa 221 /** Sweep type not valid in DC mode */
nsheth 3:81d1980d45aa 222 #define ADMX_STATUS_INVALID_DC_SWEEP_TYPE 9
nsheth 3:81d1980d45aa 223 /** Invalid sweep range */
nsheth 3:81d1980d45aa 224 #define ADMX_STATUS_INVALID_SWEEP_RANGE 10
nsheth 3:81d1980d45aa 225 /** Invalid calibration coeff type */
nsheth 3:81d1980d45aa 226 #define ADMX_STATUS_INVALID_CAL_COEFF_TYPE 11
nsheth 3:81d1980d45aa 227 /** System is not ready to take trigger */
nsheth 3:81d1980d45aa 228 #define ADMX_STATUS_TRIGGER_OVERFLOW 12
nsheth 3:81d1980d45aa 229 /** Invalid calibration type */
nsheth 3:81d1980d45aa 230 #define ADMX_STATUS_INVALID_CAL_TYPE 13
nsheth 3:81d1980d45aa 231 /** Invalid calibration gains */
nsheth 3:81d1980d45aa 232 #define ADMX_STATUS_INVALID_GAIN 14
nsheth 10:49537b1dbbd7 233 /** WArning Auto range got disabled in this command */
nsheth 3:81d1980d45aa 234 #define ADMX_STATUS_AUTO_RANGE_DISABLED 15
nsheth 3:81d1980d45aa 235 /** Calibration faild */
nsheth 3:81d1980d45aa 236 #define ADMX_STATUS_CAL_FAILED 15
nsheth 3:81d1980d45aa 237 /** Compensation failed */
nsheth 3:81d1980d45aa 238 #define ADMX_STATUS_COMP_FAILED 15
nsheth 3:81d1980d45aa 239 /** Invalid command for the state */
nsheth 3:81d1980d45aa 240 #define ADMX_STATUS_INVALID_COMMAND_STATE 16
nsheth 3:81d1980d45aa 241 /** Log of zero error */
nsheth 3:81d1980d45aa 242 #define ADMX_STATUS_LOG_ZERO_ERROR 32
nsheth 3:81d1980d45aa 243 /** Sign change for log error */
nsheth 3:81d1980d45aa 244 #define ADMX_STATUS_LOG_SIGN_ERROR 64
nsheth 3:81d1980d45aa 245 /** Voltage ADC saturated error */
nsheth 3:81d1980d45aa 246 #define ADMX_STATUS_VOLT_ADC_ERROR 128
nsheth 3:81d1980d45aa 247 /** Current ADC saturated error */
nsheth 3:81d1980d45aa 248 #define ADMX_STATUS_CURR_ADC_ERROR 256
nsheth 3:81d1980d45aa 249 /** FIFO over/under flow error */
nsheth 3:81d1980d45aa 250 #define ADMX_STATUS_FIFO_ERROR 512
nsheth 3:81d1980d45aa 251 /** Sweep count maximum value exceeded */
nsheth 3:81d1980d45aa 252 #define ADMX_STATUS_COUNT_EXCEEDED 1024
nsheth 3:81d1980d45aa 253
nsheth 3:81d1980d45aa 254 #endif /* __ADMX200X_COMMANDS_H__ */