ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Committer:
Dan O'Donovan
Date:
Mon Mar 26 20:28:05 2018 +0100
Branch:
v2.0
Revision:
27:567abf893938
Parent:
26:12d0204be712
Child:
29:57edca10d78c
Adding host library and example code for v1.1 release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
danodonovan 26:12d0204be712 1 /*
danodonovan 26:12d0204be712 2 Copyright 2017 (c) Analog Devices, Inc.
danodonovan 26:12d0204be712 3
danodonovan 26:12d0204be712 4 All rights reserved.
danodonovan 26:12d0204be712 5
danodonovan 26:12d0204be712 6 Redistribution and use in source and binary forms, with or without
danodonovan 26:12d0204be712 7 modification, are permitted provided that the following conditions are met:
danodonovan 26:12d0204be712 8 - Redistributions of source code must retain the above copyright
danodonovan 26:12d0204be712 9 notice, this list of conditions and the following disclaimer.
danodonovan 26:12d0204be712 10 - Redistributions in binary form must reproduce the above copyright
danodonovan 26:12d0204be712 11 notice, this list of conditions and the following disclaimer in
danodonovan 26:12d0204be712 12 the documentation and/or other materials provided with the
danodonovan 26:12d0204be712 13 distribution.
danodonovan 26:12d0204be712 14 - Neither the name of Analog Devices, Inc. nor the names of its
danodonovan 26:12d0204be712 15 contributors may be used to endorse or promote products derived
danodonovan 26:12d0204be712 16 from this software without specific prior written permission.
danodonovan 26:12d0204be712 17 - The use of this software may or may not infringe the patent rights
danodonovan 26:12d0204be712 18 of one or more patent holders. This license does not release you
danodonovan 26:12d0204be712 19 from the requirement that you obtain separate licenses from these
danodonovan 26:12d0204be712 20 patent holders to use this software.
danodonovan 26:12d0204be712 21 - Use of the software either in source or binary form, must be run
danodonovan 26:12d0204be712 22 on or directly connected to an Analog Devices Inc. component.
danodonovan 26:12d0204be712 23
danodonovan 26:12d0204be712 24 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
danodonovan 26:12d0204be712 25 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
danodonovan 26:12d0204be712 26 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
danodonovan 26:12d0204be712 27 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
danodonovan 26:12d0204be712 28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
danodonovan 26:12d0204be712 29 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
danodonovan 26:12d0204be712 30 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
danodonovan 26:12d0204be712 31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
danodonovan 26:12d0204be712 32 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
danodonovan 26:12d0204be712 33 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
danodonovan 26:12d0204be712 34 */
danodonovan 26:12d0204be712 35
Dan O'Donovan 27:567abf893938 36 /*!
Dan O'Donovan 27:567abf893938 37 ******************************************************************************
Dan O'Donovan 27:567abf893938 38 * @file: adi_sense_api.h
Dan O'Donovan 27:567abf893938 39 * @brief: ADISENSE Host Library Application Programming Interface (API)
Dan O'Donovan 27:567abf893938 40 *-----------------------------------------------------------------------------
Dan O'Donovan 27:567abf893938 41 */
Dan O'Donovan 27:567abf893938 42
danodonovan 26:12d0204be712 43 #ifndef __ADI_SENSE_API_H__
danodonovan 26:12d0204be712 44 #define __ADI_SENSE_API_H__
danodonovan 26:12d0204be712 45
danodonovan 26:12d0204be712 46 #include "inc/adi_sense_types.h"
danodonovan 26:12d0204be712 47 #include "inc/adi_sense_config_types.h"
danodonovan 26:12d0204be712 48 #include "inc/adi_sense_platform.h"
danodonovan 26:12d0204be712 49 #include "inc/adi_sense_gpio.h"
danodonovan 26:12d0204be712 50 #include "inc/adi_sense_spi.h"
danodonovan 26:12d0204be712 51 #include "inc/adi_sense_log.h"
danodonovan 26:12d0204be712 52 #include "inc/adi_sense_time.h"
danodonovan 26:12d0204be712 53
danodonovan 26:12d0204be712 54 /*! @defgroup ADISENSE_Api ADISENSE Host Library API
danodonovan 26:12d0204be712 55 * Host library API common to the ADISENSE product family.
danodonovan 26:12d0204be712 56 * @{
danodonovan 26:12d0204be712 57 */
danodonovan 26:12d0204be712 58
danodonovan 26:12d0204be712 59 #ifdef __cplusplus
danodonovan 26:12d0204be712 60 extern "C" {
danodonovan 26:12d0204be712 61 #endif
danodonovan 26:12d0204be712 62
danodonovan 26:12d0204be712 63 /*! The maximum number of channels supported by this API
danodonovan 26:12d0204be712 64 * @note Specific ADISENSE products may implement a lower number of channels */
danodonovan 26:12d0204be712 65 #define ADI_SENSE_MAX_CHANNELS 16
danodonovan 26:12d0204be712 66
danodonovan 26:12d0204be712 67 /*! A handle used in all API functions to identify the ADISENSE device. */
danodonovan 26:12d0204be712 68 typedef void* ADI_SENSE_DEVICE_HANDLE;
danodonovan 26:12d0204be712 69
danodonovan 26:12d0204be712 70 /*! Supported connection types for communication with the ADISENSE device. */
danodonovan 26:12d0204be712 71 typedef enum {
danodonovan 26:12d0204be712 72 ADI_SENSE_CONNECTION_TYPE_SPI = 1,
danodonovan 26:12d0204be712 73 /*!< Serial Peripheral Interface (SPI) connection type */
danodonovan 26:12d0204be712 74 } ADI_SENSE_CONNECTION_TYPE;
danodonovan 26:12d0204be712 75
danodonovan 26:12d0204be712 76 /*! Connection details for communication with a ADISENSE device instance. */
danodonovan 26:12d0204be712 77 typedef struct {
danodonovan 26:12d0204be712 78 ADI_SENSE_CONNECTION_TYPE type;
danodonovan 26:12d0204be712 79 /*!< Connection type selection */
danodonovan 26:12d0204be712 80 ADI_SENSE_PLATFORM_SPI_CONFIG spi;
danodonovan 26:12d0204be712 81 /*!< SPI connection parameters, required if SPI connection type is used */
danodonovan 26:12d0204be712 82 ADI_SENSE_PLATFORM_GPIO_CONFIG gpio;
danodonovan 26:12d0204be712 83 /*!< GPIO connection parameters, for device reset and status I/O signals */
danodonovan 26:12d0204be712 84 } ADI_SENSE_CONNECTION;
danodonovan 26:12d0204be712 85
danodonovan 26:12d0204be712 86 /*! Bit masks (flags) for the different device status indicators. */
danodonovan 26:12d0204be712 87 typedef enum {
danodonovan 26:12d0204be712 88 ADI_SENSE_DEVICE_STATUS_BUSY = (1 << 0),
danodonovan 26:12d0204be712 89 /*!< Indicates that a command is currently running on the device */
danodonovan 26:12d0204be712 90 ADI_SENSE_DEVICE_STATUS_DATAREADY = (1 << 1),
danodonovan 26:12d0204be712 91 /*!< Indicates the availability of measurement data for retrieval */
danodonovan 26:12d0204be712 92 ADI_SENSE_DEVICE_STATUS_ERROR = (1 << 2),
danodonovan 26:12d0204be712 93 /*!< Indicates that an error condition has been detected by the device */
danodonovan 26:12d0204be712 94 ADI_SENSE_DEVICE_STATUS_ALERT = (1 << 3),
danodonovan 26:12d0204be712 95 /*!< Indicates that an alert condition has been detected by the device */
danodonovan 26:12d0204be712 96 ADI_SENSE_DEVICE_STATUS_FIFO_ERROR = (1 << 4),
danodonovan 26:12d0204be712 97 /*!< Indicates that a FIFO error condition has been detected by the device */
danodonovan 26:12d0204be712 98 ADI_SENSE_DEVICE_STATUS_CONFIG_ERROR = (1 << 5),
danodonovan 26:12d0204be712 99 /*!< Indicates that a configuration error condition has been detected by the device */
danodonovan 26:12d0204be712 100 ADI_SENSE_DEVICE_STATUS_LUT_ERROR = (1 << 6),
danodonovan 26:12d0204be712 101 /*!< Indicates that a look-up table error condition has been detected by the device */
danodonovan 26:12d0204be712 102 } ADI_SENSE_DEVICE_STATUS_FLAGS;
danodonovan 26:12d0204be712 103
danodonovan 26:12d0204be712 104 /*! Bit masks (flags) for the different diagnostics status indicators. */
danodonovan 26:12d0204be712 105 typedef enum {
danodonovan 26:12d0204be712 106 ADI_SENSE_DIAGNOSTICS_STATUS_CHECKSUM_ERROR = (1 << 0),
danodonovan 26:12d0204be712 107 /*!< Indicates Error on Internal Checksum Calculations */
danodonovan 26:12d0204be712 108 ADI_SENSE_DIAGNOSTICS_STATUS_COMMS_ERROR = (1 << 1),
danodonovan 26:12d0204be712 109 /*!< Indicates Error on Internal Device Communications */
danodonovan 26:12d0204be712 110 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_MONITOR_ERROR = (1 << 2),
danodonovan 26:12d0204be712 111 /*!< Indicates Low Voltage on Internal Supply Voltages */
danodonovan 26:12d0204be712 112 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_CAP_ERROR = (1 << 3),
danodonovan 26:12d0204be712 113 /*!< Indicates Fault on Internal Supply Regulator Capacitor */
danodonovan 26:12d0204be712 114 ADI_SENSE_DIAGNOSTICS_STATUS_AINM_UV_ERROR = (1 << 4),
danodonovan 26:12d0204be712 115 /*!< Indicates Under-Voltage Error on Negative Analog Input */
danodonovan 26:12d0204be712 116 ADI_SENSE_DIAGNOSTICS_STATUS_AINM_OV_ERROR = (1 << 5),
danodonovan 26:12d0204be712 117 /*!< Indicates Over-Voltage Error on Negative Analog Input */
danodonovan 26:12d0204be712 118 ADI_SENSE_DIAGNOSTICS_STATUS_AINP_UV_ERROR = (1 << 6),
danodonovan 26:12d0204be712 119 /*!< Indicates Under-Voltage Error on Positive Analog Input */
danodonovan 26:12d0204be712 120 ADI_SENSE_DIAGNOSTICS_STATUS_AINP_OV_ERROR = (1 << 7),
danodonovan 26:12d0204be712 121 /*!< Indicates Over-Voltage Error on Positive Analog Input */
danodonovan 26:12d0204be712 122 ADI_SENSE_DIAGNOSTICS_STATUS_CONVERSION_ERROR = (1 << 8),
danodonovan 26:12d0204be712 123 /*!< Indicates Error During Internal ADC Conversions */
danodonovan 26:12d0204be712 124 ADI_SENSE_DIAGNOSTICS_STATUS_CALIBRATION_ERROR = (1 << 9),
danodonovan 26:12d0204be712 125 /*!< Indicates Error During Internal Device Calibrations */
danodonovan 26:12d0204be712 126 } ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS;
danodonovan 26:12d0204be712 127
danodonovan 26:12d0204be712 128 /*! Bit masks (flags) for the different channel alert indicators. */
danodonovan 26:12d0204be712 129 typedef enum {
danodonovan 26:12d0204be712 130 ADI_SENSE_CHANNEL_ALERT_TIMEOUT = (1 << 0),
danodonovan 26:12d0204be712 131 /*!< Indicates timeout condition detected on the channel */
danodonovan 26:12d0204be712 132 ADI_SENSE_CHANNEL_ALERT_UNDER_RANGE = (1 << 1),
danodonovan 26:12d0204be712 133 /*!< Indicates raw sample under valid input range, possibly clamped */
danodonovan 26:12d0204be712 134 ADI_SENSE_CHANNEL_ALERT_OVER_RANGE = (1 << 2),
danodonovan 26:12d0204be712 135 /*!< Indicates raw sample over valid input range, possibly clamped */
danodonovan 26:12d0204be712 136 ADI_SENSE_CHANNEL_ALERT_LOW_LIMIT = (1 << 3),
danodonovan 26:12d0204be712 137 /*!< Indicates measurement result was below configured minimum threshold */
danodonovan 26:12d0204be712 138 ADI_SENSE_CHANNEL_ALERT_HIGH_LIMIT = (1 << 4),
danodonovan 26:12d0204be712 139 /*!< Indicates measurement result was above configured maximum threshold */
danodonovan 26:12d0204be712 140 ADI_SENSE_CHANNEL_ALERT_SENSOR_OPEN = (1 << 5),
danodonovan 26:12d0204be712 141 /*!< Indicates open circuit or mis-wire condition detected on the channel */
danodonovan 26:12d0204be712 142 ADI_SENSE_CHANNEL_ALERT_REF_DETECT = (1 << 6),
danodonovan 26:12d0204be712 143 /*!< Indicates reference-detect error condition detected on the channel */
danodonovan 26:12d0204be712 144 ADI_SENSE_CHANNEL_ALERT_CONFIG_ERR = (1 << 7),
danodonovan 26:12d0204be712 145 /*!< Indicates configuration error condition detected on the channel */
danodonovan 26:12d0204be712 146 ADI_SENSE_CHANNEL_ALERT_LUT_ERR = (1 << 8),
danodonovan 26:12d0204be712 147 /*!< Indicates look-up table error condition detected on the channel */
danodonovan 26:12d0204be712 148 ADI_SENSE_CHANNEL_ALERT_SENSOR_NOT_READY = (1 << 9),
danodonovan 26:12d0204be712 149 /*!< Indicates digital sensor not-ready error condition detected on the channel */
danodonovan 26:12d0204be712 150 ADI_SENSE_CHANNEL_ALERT_COMP_NOT_READY = (1 << 10),
danodonovan 26:12d0204be712 151 /*!< Indicates compensation channel not-ready error condition detected on the channel */
danodonovan 26:12d0204be712 152 ADI_SENSE_CHANNEL_ALERT_UNDER_VOLTAGE = (1 << 11),
danodonovan 26:12d0204be712 153 /*!< Indicates under-voltage condition detected on the channel */
danodonovan 26:12d0204be712 154 ADI_SENSE_CHANNEL_ALERT_OVER_VOLTAGE = (1 << 12),
danodonovan 26:12d0204be712 155 /*!< Indicates over-voltage condition detected on the channel */
danodonovan 26:12d0204be712 156 ADI_SENSE_CHANNEL_ALERT_LUT_UNDER_RANGE = (1 << 13),
danodonovan 26:12d0204be712 157 /*!< Indicates raw sample was under the available LUT/equation range */
danodonovan 26:12d0204be712 158 ADI_SENSE_CHANNEL_ALERT_LUT_OVER_RANGE = (1 << 14),
danodonovan 26:12d0204be712 159 /*!< Indicates raw sample was over the available LUT/equation range */
danodonovan 26:12d0204be712 160 } ADI_SENSE_CHANNEL_ALERT_FLAGS;
danodonovan 26:12d0204be712 161
danodonovan 26:12d0204be712 162 /*! Status details retreived from the ADISENSE device. */
danodonovan 26:12d0204be712 163 typedef struct {
danodonovan 26:12d0204be712 164 ADI_SENSE_DEVICE_STATUS_FLAGS deviceStatus;
danodonovan 26:12d0204be712 165 /*!< General summary status information from the device */
danodonovan 26:12d0204be712 166 ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS diagnosticsStatus;
danodonovan 26:12d0204be712 167 /*!< Diagnostic error status information from the device */
danodonovan 26:12d0204be712 168 ADI_SENSE_CHANNEL_ALERT_FLAGS channelAlerts[ADI_SENSE_MAX_CHANNELS];
danodonovan 26:12d0204be712 169 /*!< Per-channel alert status information from the device */
danodonovan 26:12d0204be712 170 uint32_t errorCode;
danodonovan 26:12d0204be712 171 /*!< Code identifying the last error signalled by the device */
danodonovan 26:12d0204be712 172 uint32_t alertCode;
danodonovan 26:12d0204be712 173 /*!< Code identifying the last alert signalled by the device */
danodonovan 26:12d0204be712 174 uint32_t channelAlertCodes[ADI_SENSE_MAX_CHANNELS];
danodonovan 26:12d0204be712 175 /*!< Per-channel code identifying the last alert signalled for each channel */
danodonovan 26:12d0204be712 176 } ADI_SENSE_STATUS;
danodonovan 26:12d0204be712 177
danodonovan 26:12d0204be712 178 /*! Data sample details retreived from the ADISENSE device. */
danodonovan 26:12d0204be712 179 typedef struct {
danodonovan 26:12d0204be712 180 ADI_SENSE_DEVICE_STATUS_FLAGS status;
danodonovan 26:12d0204be712 181 /*!< Device summary status snapshot when the sample was recorded */
danodonovan 26:12d0204be712 182 uint32_t channelId;
danodonovan 26:12d0204be712 183 /*!< The measurement channel from which this sample was obtained */
danodonovan 26:12d0204be712 184 uint32_t rawValue;
danodonovan 26:12d0204be712 185 /*!< The raw (unprocessed) value obtained directly from the measurement
danodonovan 26:12d0204be712 186 * channel, if available
danodonovan 26:12d0204be712 187 */
danodonovan 26:12d0204be712 188 float32_t processedValue;
danodonovan 26:12d0204be712 189 /*!< The processed value obtained from the measurement channel, as a final
danodonovan 26:12d0204be712 190 * measurement value, following calibration and linearisation correction,
danodonovan 26:12d0204be712 191 * and conversion into an appropriate unit of measurement.
danodonovan 26:12d0204be712 192 */
danodonovan 26:12d0204be712 193 } ADI_SENSE_DATA_SAMPLE;
danodonovan 26:12d0204be712 194
danodonovan 26:12d0204be712 195 /*! Measurement mode options for the ADISENSE device.
danodonovan 26:12d0204be712 196 * @ref adi_sense_StartMeasurement
danodonovan 26:12d0204be712 197 */
danodonovan 26:12d0204be712 198 typedef enum {
danodonovan 26:12d0204be712 199 ADI_SENSE_MEASUREMENT_MODE_HEALTHCHECK = 1,
danodonovan 26:12d0204be712 200 /*!< In this mode, a special health-check measurement cycle is executed,
danodonovan 26:12d0204be712 201 * carrying out a single conversion per channel with measurement
danodonovan 26:12d0204be712 202 * diagnostics enabled, intended for use as a system health check. */
danodonovan 26:12d0204be712 203 ADI_SENSE_MEASUREMENT_MODE_NORMAL,
danodonovan 26:12d0204be712 204 /*!< In this mode, normal measurement cycle(s) are executed and data samples
danodonovan 26:12d0204be712 205 * are returned with raw measurement values included. */
danodonovan 26:12d0204be712 206 ADI_SENSE_MEASUREMENT_MODE_OMIT_RAW,
danodonovan 26:12d0204be712 207 /*!< In this mode, normal measurement cycle(s) are executed and data samples
danodonovan 26:12d0204be712 208 * are returned with raw measurement values omitted for efficiency. */
Dan O'Donovan 27:567abf893938 209 ADI_SENSE_MEASUREMENT_MODE_FFT,
Dan O'Donovan 27:567abf893938 210 /*!< In this mode, FFT mode measurement cycle(s) are executed and data
Dan O'Donovan 27:567abf893938 211 * samples are returned based on FFT-specific configuration parameters. */
danodonovan 26:12d0204be712 212 } ADI_SENSE_MEASUREMENT_MODE;
danodonovan 26:12d0204be712 213
danodonovan 26:12d0204be712 214
danodonovan 26:12d0204be712 215 /******************************************************************************
danodonovan 26:12d0204be712 216 * ADISENSE High-Level API function prototypes
danodonovan 26:12d0204be712 217 *****************************************************************************/
danodonovan 26:12d0204be712 218
danodonovan 26:12d0204be712 219 /*!
danodonovan 26:12d0204be712 220 * @brief Open ADISENSE device handle and set up communication interface.
danodonovan 26:12d0204be712 221 *
danodonovan 26:12d0204be712 222 * @param[in] nDeviceIndex Zero-based index number identifying this device
danodonovan 26:12d0204be712 223 * instance. Note that this will be used to
danodonovan 26:12d0204be712 224 * retrieve a specific device configuration for
danodonovan 26:12d0204be712 225 * this device (see @ref adi_sense_SetConfig
danodonovan 26:12d0204be712 226 * and @ref ADI_SENSE_CONFIG)
danodonovan 26:12d0204be712 227 * @param[in] pConnectionInfo Host-specific connection details (e.g. SPI, GPIO)
danodonovan 26:12d0204be712 228 * @param[out] phDevice Pointer to return an ADISENSE device handle
danodonovan 26:12d0204be712 229 *
danodonovan 26:12d0204be712 230 * @return Status
danodonovan 26:12d0204be712 231 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 232 * - #ADI_SENSE_NO_MEM Failed to allocate memory resources.
danodonovan 26:12d0204be712 233 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid device index specified
danodonovan 26:12d0204be712 234 *
danodonovan 26:12d0204be712 235 * @details Configure and initialise the Log interface and the SPI/GPIO
danodonovan 26:12d0204be712 236 * communication interface to the ADISense module.
danodonovan 26:12d0204be712 237 */
danodonovan 26:12d0204be712 238 ADI_SENSE_RESULT adi_sense_Open(
danodonovan 26:12d0204be712 239 unsigned const nDeviceIndex,
danodonovan 26:12d0204be712 240 ADI_SENSE_CONNECTION * const pConnectionInfo,
danodonovan 26:12d0204be712 241 ADI_SENSE_DEVICE_HANDLE * const phDevice);
danodonovan 26:12d0204be712 242
danodonovan 26:12d0204be712 243 /*!
danodonovan 26:12d0204be712 244 * @brief Close ADISENSE device context and free resources.
danodonovan 26:12d0204be712 245 *
danodonovan 26:12d0204be712 246 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 247 *
danodonovan 26:12d0204be712 248 * @return Status
danodonovan 26:12d0204be712 249 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 250 */
danodonovan 26:12d0204be712 251 ADI_SENSE_RESULT adi_sense_Close(
danodonovan 26:12d0204be712 252 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 253
danodonovan 26:12d0204be712 254 /*!
danodonovan 26:12d0204be712 255 * @brief Get the current state of the specified GPIO input signal.
danodonovan 26:12d0204be712 256 *
danodonovan 26:12d0204be712 257 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 258 * @param[in] ePinId GPIO pin to query
danodonovan 26:12d0204be712 259 * @param[out] pbAsserted Pointer to return the state of the status signal GPIO pin
danodonovan 26:12d0204be712 260 *
danodonovan 26:12d0204be712 261 * @return Status
danodonovan 26:12d0204be712 262 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 263 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
danodonovan 26:12d0204be712 264 *
danodonovan 26:12d0204be712 265 * @details Sets *pbAsserted to true if the status signal is asserted, or false
danodonovan 26:12d0204be712 266 * otherwise.
danodonovan 26:12d0204be712 267 */
danodonovan 26:12d0204be712 268 ADI_SENSE_RESULT adi_sense_GetGpioState(
danodonovan 26:12d0204be712 269 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 270 ADI_SENSE_GPIO_PIN const ePinId,
danodonovan 26:12d0204be712 271 bool_t * const pbAsserted);
danodonovan 26:12d0204be712 272
danodonovan 26:12d0204be712 273 /*!
danodonovan 26:12d0204be712 274 * @brief Register an application-defined callback function for GPIO interrupts
danodonovan 26:12d0204be712 275 *
danodonovan 26:12d0204be712 276 * @param[in] hDevice ADISENSE context handle (@ref adi_sense_Open)
danodonovan 26:12d0204be712 277 * @param[in] ePinId GPIO pin on which to enable/disable interrupts
danodonovan 26:12d0204be712 278 * @param[in] callbackFunction Function to be called when an interrupt occurs.
danodonovan 26:12d0204be712 279 * Specify NULL here to disable interrupts.
danodonovan 26:12d0204be712 280 * @param[in] pCallbackParam Optional opaque parameter passed to the callback
danodonovan 26:12d0204be712 281 *
danodonovan 26:12d0204be712 282 * @return Status
danodonovan 26:12d0204be712 283 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 284 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
danodonovan 26:12d0204be712 285 */
danodonovan 26:12d0204be712 286 ADI_SENSE_RESULT adi_sense_RegisterGpioCallback(
danodonovan 26:12d0204be712 287 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 288 ADI_SENSE_GPIO_PIN const ePinId,
danodonovan 26:12d0204be712 289 ADI_SENSE_GPIO_CALLBACK const callbackFunction,
danodonovan 26:12d0204be712 290 void * const pCallbackParam);
danodonovan 26:12d0204be712 291
danodonovan 26:12d0204be712 292 /*!
danodonovan 26:12d0204be712 293 * @brief Reset the ADISENSE device.
danodonovan 26:12d0204be712 294 *
danodonovan 26:12d0204be712 295 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 296 *
danodonovan 26:12d0204be712 297 * @return Status
danodonovan 26:12d0204be712 298 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 299 *
danodonovan 26:12d0204be712 300 * @details Trigger a hardware-reset of the ADISENSE device.
danodonovan 26:12d0204be712 301 *
danodonovan 26:12d0204be712 302 * @note The device may require several seconds before it is ready for use
danodonovan 26:12d0204be712 303 * again. @ref adi_sense_GetDeviceReadyState may be used to check if
danodonovan 26:12d0204be712 304 * the device is ready.
danodonovan 26:12d0204be712 305 */
danodonovan 26:12d0204be712 306 ADI_SENSE_RESULT adi_sense_Reset(
danodonovan 26:12d0204be712 307 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 308
danodonovan 26:12d0204be712 309 /*!
danodonovan 26:12d0204be712 310 * @brief Check if the device is ready, following power-up or a reset.
danodonovan 26:12d0204be712 311 *
danodonovan 26:12d0204be712 312 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 313 * @param[out] pbReady Pointer to return true if the device is ready, or false
danodonovan 26:12d0204be712 314 * otherwise
danodonovan 26:12d0204be712 315 *
danodonovan 26:12d0204be712 316 * @return Status
danodonovan 26:12d0204be712 317 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 318 *
danodonovan 26:12d0204be712 319 * @details This function attempts to read a fixed-value device register via
danodonovan 26:12d0204be712 320 * the communication interface.
danodonovan 26:12d0204be712 321 */
danodonovan 26:12d0204be712 322 ADI_SENSE_RESULT adi_sense_GetDeviceReadyState(
danodonovan 26:12d0204be712 323 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 324 bool_t * const pbReady);
danodonovan 26:12d0204be712 325
danodonovan 26:12d0204be712 326 /*!
danodonovan 26:12d0204be712 327 * @brief Obtain the product ID from the device.
danodonovan 26:12d0204be712 328 *
danodonovan 26:12d0204be712 329 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 330 * @param[out] pProductId Pointer to return the product ID value
danodonovan 26:12d0204be712 331 *
danodonovan 26:12d0204be712 332 * @return Status
danodonovan 26:12d0204be712 333 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 334 *
danodonovan 26:12d0204be712 335 * @details Reads the product ID registers on the device and returns the value.
danodonovan 26:12d0204be712 336 */
danodonovan 26:12d0204be712 337 ADI_SENSE_RESULT adi_sense_GetProductID(
danodonovan 26:12d0204be712 338 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 339 ADI_SENSE_PRODUCT_ID * const pProductId);
danodonovan 26:12d0204be712 340
danodonovan 26:12d0204be712 341 /*!
danodonovan 26:12d0204be712 342 * @brief Write full configuration settings to the device registers.
danodonovan 26:12d0204be712 343 *
danodonovan 26:12d0204be712 344 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 345 * @param[out] pConfig Pointer to the configuration data structure
danodonovan 26:12d0204be712 346 *
danodonovan 26:12d0204be712 347 * @return Status
danodonovan 26:12d0204be712 348 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 349 *
danodonovan 26:12d0204be712 350 * @details Translates configuration details provided into device-specific
danodonovan 26:12d0204be712 351 * register settings and updates device configuration registers.
danodonovan 26:12d0204be712 352 *
danodonovan 26:12d0204be712 353 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
danodonovan 26:12d0204be712 354 */
danodonovan 26:12d0204be712 355 ADI_SENSE_RESULT adi_sense_SetConfig(
danodonovan 26:12d0204be712 356 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 357 ADI_SENSE_CONFIG * const pConfig);
danodonovan 26:12d0204be712 358
danodonovan 26:12d0204be712 359 /*!
danodonovan 26:12d0204be712 360 * @brief Apply the configuration settings currently stored in device registers
danodonovan 26:12d0204be712 361 *
danodonovan 26:12d0204be712 362 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 363 *
danodonovan 26:12d0204be712 364 * @return Status
danodonovan 26:12d0204be712 365 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 366 *
danodonovan 26:12d0204be712 367 * @details Instructs the ADISENSE device to reload and apply configuration
danodonovan 26:12d0204be712 368 * from the device configuration registers. Changes to configuration
danodonovan 26:12d0204be712 369 * registers are ignored by the device until this function is called.
danodonovan 26:12d0204be712 370 *
danodonovan 26:12d0204be712 371 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 372 */
danodonovan 26:12d0204be712 373 ADI_SENSE_RESULT adi_sense_ApplyConfigUpdates(
danodonovan 26:12d0204be712 374 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 375
danodonovan 26:12d0204be712 376 /*!
danodonovan 26:12d0204be712 377 * @brief Store the configuration settings to persistent memory on the device.
danodonovan 26:12d0204be712 378 *
danodonovan 26:12d0204be712 379 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 380 *
danodonovan 26:12d0204be712 381 * @return Status
danodonovan 26:12d0204be712 382 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 383 *
danodonovan 26:12d0204be712 384 * @details Instructs the ADISENSE device to save the current contents of its
danodonovan 26:12d0204be712 385 * device configuration registers to non-volatile memory.
danodonovan 26:12d0204be712 386 *
danodonovan 26:12d0204be712 387 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 388 * @note Do not power down the device while this command is running.
danodonovan 26:12d0204be712 389 */
danodonovan 26:12d0204be712 390 ADI_SENSE_RESULT adi_sense_SaveConfig(
danodonovan 26:12d0204be712 391 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 392
danodonovan 26:12d0204be712 393 /*!
danodonovan 26:12d0204be712 394 * @brief Restore configuration settings from persistent memory on the device.
danodonovan 26:12d0204be712 395 *
danodonovan 26:12d0204be712 396 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 397 *
danodonovan 26:12d0204be712 398 * @return Status
danodonovan 26:12d0204be712 399 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 400 *
danodonovan 26:12d0204be712 401 * @details Instructs the ADISENSE device to restore the contents of its
danodonovan 26:12d0204be712 402 * device configuration registers from non-volatile memory.
danodonovan 26:12d0204be712 403 *
danodonovan 26:12d0204be712 404 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 405 */
danodonovan 26:12d0204be712 406 ADI_SENSE_RESULT adi_sense_RestoreConfig(
danodonovan 26:12d0204be712 407 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 408
danodonovan 26:12d0204be712 409 /*!
danodonovan 26:12d0204be712 410 * @brief Store the LUT data to persistent memory on the device.
danodonovan 26:12d0204be712 411 *
danodonovan 26:12d0204be712 412 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 413 *
danodonovan 26:12d0204be712 414 * @return Status
danodonovan 26:12d0204be712 415 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 416 *
danodonovan 26:12d0204be712 417 * @details Instructs the ADISENSE device to save the current contents of its
danodonovan 26:12d0204be712 418 * LUT data buffer, set using @ref adi_sense_SetLutData, to
danodonovan 26:12d0204be712 419 * non-volatile memory.
danodonovan 26:12d0204be712 420 *
danodonovan 26:12d0204be712 421 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 422 * @note Do not power down the device while this command is running.
danodonovan 26:12d0204be712 423 */
danodonovan 26:12d0204be712 424 ADI_SENSE_RESULT adi_sense_SaveLutData(
danodonovan 26:12d0204be712 425 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 426
danodonovan 26:12d0204be712 427 /*!
danodonovan 26:12d0204be712 428 * @brief Restore LUT data from persistent memory on the device.
danodonovan 26:12d0204be712 429 *
danodonovan 26:12d0204be712 430 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 431 *
danodonovan 26:12d0204be712 432 * @return Status
danodonovan 26:12d0204be712 433 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 434 *
danodonovan 26:12d0204be712 435 * @details Instructs the ADISENSE device to restore the contents of its
danodonovan 26:12d0204be712 436 * LUT data, previously stored with @ref adi_sense_SaveLutData, from
danodonovan 26:12d0204be712 437 * non-volatile memory.
danodonovan 26:12d0204be712 438 *
danodonovan 26:12d0204be712 439 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 440 */
danodonovan 26:12d0204be712 441 ADI_SENSE_RESULT adi_sense_RestoreLutData(
danodonovan 26:12d0204be712 442 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 443
danodonovan 26:12d0204be712 444 /*!
danodonovan 26:12d0204be712 445 * @brief Start the measurement cycles on the device.
danodonovan 26:12d0204be712 446 *
danodonovan 26:12d0204be712 447 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 448 * @param[in] eMeasurementMode Allows a choice of special modes for the
danodonovan 26:12d0204be712 449 * measurement. See @ref ADI_SENSE_MEASUREMENT_MODE
danodonovan 26:12d0204be712 450 * for further information.
danodonovan 26:12d0204be712 451 *
danodonovan 26:12d0204be712 452 * @return Status
danodonovan 26:12d0204be712 453 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 454 *
danodonovan 26:12d0204be712 455 * @details Instructs the ADISENSE device to start executing measurement cycles
danodonovan 26:12d0204be712 456 * according to the current applied configuration settings. The
danodonovan 26:12d0204be712 457 * DATAREADY status signal will be asserted whenever new measurement
danodonovan 26:12d0204be712 458 * data is published, according to selected settings.
danodonovan 26:12d0204be712 459 * Measurement cycles may be stopped by calling @ref
danodonovan 26:12d0204be712 460 * adi_sense_StopMeasurement.
danodonovan 26:12d0204be712 461 *
danodonovan 26:12d0204be712 462 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 463 */
danodonovan 26:12d0204be712 464 ADI_SENSE_RESULT adi_sense_StartMeasurement(
danodonovan 26:12d0204be712 465 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 466 ADI_SENSE_MEASUREMENT_MODE const eMeasurementMode);
danodonovan 26:12d0204be712 467
danodonovan 26:12d0204be712 468 /*!
danodonovan 26:12d0204be712 469 * @brief Stop the measurement cycles on the device.
danodonovan 26:12d0204be712 470 *
danodonovan 26:12d0204be712 471 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 472 *
danodonovan 26:12d0204be712 473 * @return Status
danodonovan 26:12d0204be712 474 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 475 *
danodonovan 26:12d0204be712 476 * @details Instructs the ADISENSE device to stop executing measurement cycles.
danodonovan 26:12d0204be712 477 * The command may be delayed until the current conversion, if any, has
danodonovan 26:12d0204be712 478 * been completed and published.
danodonovan 26:12d0204be712 479 *
danodonovan 26:12d0204be712 480 * @note To be used only if a measurement command is currently running.
danodonovan 26:12d0204be712 481 */
danodonovan 26:12d0204be712 482 ADI_SENSE_RESULT adi_sense_StopMeasurement(
danodonovan 26:12d0204be712 483 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 484
danodonovan 26:12d0204be712 485 /*!
danodonovan 26:12d0204be712 486 * @brief Run built-in diagnostic checks on the device.
danodonovan 26:12d0204be712 487 *
danodonovan 26:12d0204be712 488 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 489 *
danodonovan 26:12d0204be712 490 * @return Status
danodonovan 26:12d0204be712 491 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 492 *
danodonovan 26:12d0204be712 493 * @details Instructs the ADISENSE device to execute its built-in diagnostic
danodonovan 26:12d0204be712 494 * tests, on any enabled measurement channels, according to the current
danodonovan 26:12d0204be712 495 * applied configuration settings. Device status registers will be
danodonovan 26:12d0204be712 496 * updated to indicate if any errors were detected by the diagnostics.
danodonovan 26:12d0204be712 497 *
danodonovan 26:12d0204be712 498 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 499 */
danodonovan 26:12d0204be712 500 ADI_SENSE_RESULT adi_sense_RunDiagnostics(
danodonovan 26:12d0204be712 501 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 502
danodonovan 26:12d0204be712 503 /*!
danodonovan 26:12d0204be712 504 * @brief Run built-in calibration on the device.
danodonovan 26:12d0204be712 505 *
danodonovan 26:12d0204be712 506 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 507 *
danodonovan 26:12d0204be712 508 * @return Status
danodonovan 26:12d0204be712 509 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 510 *
danodonovan 26:12d0204be712 511 * @details Instructs the ADISENSE device to execute its self-calibration
danodonovan 26:12d0204be712 512 * routines, on any enabled measurement channels, according to the
danodonovan 26:12d0204be712 513 * current applied configuration settings. Device status registers
danodonovan 26:12d0204be712 514 * will be updated to indicate if any errors were detected.
danodonovan 26:12d0204be712 515 *
danodonovan 26:12d0204be712 516 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 517 */
danodonovan 26:12d0204be712 518 ADI_SENSE_RESULT adi_sense_RunCalibration(
danodonovan 26:12d0204be712 519 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 520
danodonovan 26:12d0204be712 521 /*!
danodonovan 26:12d0204be712 522 * @brief Read the current status from the device registers.
danodonovan 26:12d0204be712 523 *
danodonovan 26:12d0204be712 524 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 525 * @param[out] pStatus Pointer to return the status summary obtained from the
danodonovan 26:12d0204be712 526 * device.
danodonovan 26:12d0204be712 527 *
danodonovan 26:12d0204be712 528 * @return Status
danodonovan 26:12d0204be712 529 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 530 *
danodonovan 26:12d0204be712 531 * @details Reads the status registers and extracts the relevant information
danodonovan 26:12d0204be712 532 * to return to the caller.
danodonovan 26:12d0204be712 533 *
danodonovan 26:12d0204be712 534 * @note This may be called at any time, assuming the device is ready.
danodonovan 26:12d0204be712 535 */
danodonovan 26:12d0204be712 536 ADI_SENSE_RESULT adi_sense_GetStatus(
danodonovan 26:12d0204be712 537 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 538 ADI_SENSE_STATUS * const pStatus);
danodonovan 26:12d0204be712 539
danodonovan 26:12d0204be712 540 /*!
danodonovan 26:12d0204be712 541 * @brief Read measurement data samples from the device registers.
danodonovan 26:12d0204be712 542 *
danodonovan 26:12d0204be712 543 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 544 * @param[in] eMeasurementMode Must be set to the same value used for @ref
danodonovan 26:12d0204be712 545 * adi_sense_StartMeasurement().
danodonovan 26:12d0204be712 546 * @param[out] pSamples Pointer to return a set of requested data samples.
Dan O'Donovan 27:567abf893938 547 * @param[in] nBytesPerSample The size, in bytes, of each sample.
danodonovan 26:12d0204be712 548 * @param[in] nRequested Number of requested data samples.
danodonovan 26:12d0204be712 549 * @param[out] pnReturned Number of valid data samples successfully retrieved.
danodonovan 26:12d0204be712 550 *
danodonovan 26:12d0204be712 551 * @return Status
danodonovan 26:12d0204be712 552 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 553 *
danodonovan 26:12d0204be712 554 * @details Reads the status registers and extracts the relevant information
danodonovan 26:12d0204be712 555 * to return to the caller.
danodonovan 26:12d0204be712 556 *
danodonovan 26:12d0204be712 557 * @note This is intended to be called only when the DATAREADY status signal
danodonovan 26:12d0204be712 558 * is asserted.
danodonovan 26:12d0204be712 559 */
danodonovan 26:12d0204be712 560 ADI_SENSE_RESULT adi_sense_GetData(
danodonovan 26:12d0204be712 561 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 562 ADI_SENSE_MEASUREMENT_MODE const eMeasurementMode,
danodonovan 26:12d0204be712 563 ADI_SENSE_DATA_SAMPLE * const pSamples,
Dan O'Donovan 27:567abf893938 564 uint8_t const nBytesPerSample,
danodonovan 26:12d0204be712 565 uint32_t const nRequested,
danodonovan 26:12d0204be712 566 uint32_t * const pnReturned);
danodonovan 26:12d0204be712 567
danodonovan 26:12d0204be712 568 /*!
danodonovan 26:12d0204be712 569 * @brief Check if a command is currently running on the device.
danodonovan 26:12d0204be712 570 *
danodonovan 26:12d0204be712 571 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 572 * @param[out] pbCommandRunning Pointer to return the command running status
danodonovan 26:12d0204be712 573 *
danodonovan 26:12d0204be712 574 * @return Status
danodonovan 26:12d0204be712 575 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 576 *
danodonovan 26:12d0204be712 577 * @details Reads the device status register to check if a command is running.
danodonovan 26:12d0204be712 578 */
danodonovan 26:12d0204be712 579 ADI_SENSE_RESULT adi_sense_GetCommandRunningState(
danodonovan 26:12d0204be712 580 ADI_SENSE_DEVICE_HANDLE hDevice,
danodonovan 26:12d0204be712 581 bool_t *pbCommandRunning);
danodonovan 26:12d0204be712 582
danodonovan 26:12d0204be712 583 #ifdef __cplusplus
danodonovan 26:12d0204be712 584 }
danodonovan 26:12d0204be712 585 #endif
danodonovan 26:12d0204be712 586
danodonovan 26:12d0204be712 587 /*!
danodonovan 26:12d0204be712 588 * @}
danodonovan 26:12d0204be712 589 */
danodonovan 26:12d0204be712 590
danodonovan 26:12d0204be712 591 #endif /* __ADI_SENSE_API_H__ */