ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Committer:
kevin1990
Date:
Fri Oct 20 15:58:01 2017 +0000
Revision:
7:4dbae381f693
v0.3 release (New Host api)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kevin1990 7:4dbae381f693 1 /*!
kevin1990 7:4dbae381f693 2 ******************************************************************************
kevin1990 7:4dbae381f693 3 * @file: adi_sense_api.h
kevin1990 7:4dbae381f693 4 * @brief: ADI Sense Host Library Application Programming Interface (API)
kevin1990 7:4dbae381f693 5 *-----------------------------------------------------------------------------
kevin1990 7:4dbae381f693 6 */
kevin1990 7:4dbae381f693 7
kevin1990 7:4dbae381f693 8 /*
kevin1990 7:4dbae381f693 9 Copyright (c) 2017 Emutex Ltd. / Analog Devices, Inc.
kevin1990 7:4dbae381f693 10
kevin1990 7:4dbae381f693 11 All rights reserved.
kevin1990 7:4dbae381f693 12
kevin1990 7:4dbae381f693 13 Redistribution and use in source and binary forms, with or without modification,
kevin1990 7:4dbae381f693 14 are permitted provided that the following conditions are met:
kevin1990 7:4dbae381f693 15 - Redistributions of source code must retain the above copyright notice,
kevin1990 7:4dbae381f693 16 this list of conditions and the following disclaimer.
kevin1990 7:4dbae381f693 17 - Redistributions in binary form must reproduce the above copyright notice,
kevin1990 7:4dbae381f693 18 this list of conditions and the following disclaimer in the documentation
kevin1990 7:4dbae381f693 19 and/or other materials provided with the distribution.
kevin1990 7:4dbae381f693 20 - Modified versions of the software must be conspicuously marked as such.
kevin1990 7:4dbae381f693 21 - This software is licensed solely and exclusively for use with processors
kevin1990 7:4dbae381f693 22 manufactured by or for Analog Devices, Inc.
kevin1990 7:4dbae381f693 23 - This software may not be combined or merged with other code in any manner
kevin1990 7:4dbae381f693 24 that would cause the software to become subject to terms and conditions
kevin1990 7:4dbae381f693 25 which differ from those listed here.
kevin1990 7:4dbae381f693 26 - Neither the name of Analog Devices, Inc. nor the names of its
kevin1990 7:4dbae381f693 27 contributors may be used to endorse or promote products derived
kevin1990 7:4dbae381f693 28 from this software without specific prior written permission.
kevin1990 7:4dbae381f693 29 - The use of this software may or may not infringe the patent rights of one
kevin1990 7:4dbae381f693 30 or more patent holders. This license does not release you from the
kevin1990 7:4dbae381f693 31 requirement that you obtain separate licenses from these patent holders
kevin1990 7:4dbae381f693 32 to use this software.
kevin1990 7:4dbae381f693 33
kevin1990 7:4dbae381f693 34 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND ANY
kevin1990 7:4dbae381f693 35 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
kevin1990 7:4dbae381f693 36 TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
kevin1990 7:4dbae381f693 37 NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
kevin1990 7:4dbae381f693 38 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES
kevin1990 7:4dbae381f693 39 (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL
kevin1990 7:4dbae381f693 40 PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
kevin1990 7:4dbae381f693 41 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
kevin1990 7:4dbae381f693 42 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
kevin1990 7:4dbae381f693 43 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
kevin1990 7:4dbae381f693 44 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kevin1990 7:4dbae381f693 45 */
kevin1990 7:4dbae381f693 46
kevin1990 7:4dbae381f693 47 #ifndef __ADI_SENSE_API_H__
kevin1990 7:4dbae381f693 48 #define __ADI_SENSE_API_H__
kevin1990 7:4dbae381f693 49
kevin1990 7:4dbae381f693 50 #include "inc/adi_sense_types.h"
kevin1990 7:4dbae381f693 51 #include "inc/adi_sense_config_types.h"
kevin1990 7:4dbae381f693 52 #include "inc/adi_sense_dsp_data_types.h"
kevin1990 7:4dbae381f693 53 #include "inc/adi_sense_platform.h"
kevin1990 7:4dbae381f693 54 #include "inc/adi_sense_gpio.h"
kevin1990 7:4dbae381f693 55 #include "inc/adi_sense_spi.h"
kevin1990 7:4dbae381f693 56 #include "inc/adi_sense_log.h"
kevin1990 7:4dbae381f693 57 #include "inc/adi_sense_time.h"
kevin1990 7:4dbae381f693 58
kevin1990 7:4dbae381f693 59 /*! @addtogroup ADI_Sense_Api ADI Sense Host Library API
kevin1990 7:4dbae381f693 60 * @{
kevin1990 7:4dbae381f693 61 */
kevin1990 7:4dbae381f693 62
kevin1990 7:4dbae381f693 63 #ifdef __cplusplus
kevin1990 7:4dbae381f693 64 extern "C" {
kevin1990 7:4dbae381f693 65 #endif
kevin1990 7:4dbae381f693 66
kevin1990 7:4dbae381f693 67 /*! A handle used in all API functions to identify the ADI Sense device. */
kevin1990 7:4dbae381f693 68 typedef void* ADI_SENSE_DEVICE_HANDLE;
kevin1990 7:4dbae381f693 69
kevin1990 7:4dbae381f693 70 /*! Supported connection types for communication with the ADI Sense device. */
kevin1990 7:4dbae381f693 71 typedef enum {
kevin1990 7:4dbae381f693 72 ADI_SENSE_CONNECTION_TYPE_SPI = 1,
kevin1990 7:4dbae381f693 73 /*!< Serial Peripheral Interface (SPI) connection type */
kevin1990 7:4dbae381f693 74 } ADI_SENSE_CONNECTION_TYPE;
kevin1990 7:4dbae381f693 75
kevin1990 7:4dbae381f693 76 /*! Connection details for communication with a ADI Sense device instance. */
kevin1990 7:4dbae381f693 77 typedef struct {
kevin1990 7:4dbae381f693 78 ADI_SENSE_CONNECTION_TYPE type;
kevin1990 7:4dbae381f693 79 /*!< Connection type selection */
kevin1990 7:4dbae381f693 80 ADI_SENSE_PLATFORM_SPI_CONFIG spi;
kevin1990 7:4dbae381f693 81 /*!< SPI connection parameters, required if SPI connection type is used */
kevin1990 7:4dbae381f693 82 ADI_SENSE_PLATFORM_GPIO_CONFIG gpio;
kevin1990 7:4dbae381f693 83 /*!< GPIO connection parameters, for device reset and status I/O signals */
kevin1990 7:4dbae381f693 84 } ADI_SENSE_CONNECTION;
kevin1990 7:4dbae381f693 85
kevin1990 7:4dbae381f693 86 /*! Bit masks (flags) for the different device status indicators. */
kevin1990 7:4dbae381f693 87 typedef enum {
kevin1990 7:4dbae381f693 88 ADI_SENSE_DEVICE_STATUS_BUSY = (1 << 0),
kevin1990 7:4dbae381f693 89 /*!< Indicates that a command is currently running on the device */
kevin1990 7:4dbae381f693 90 ADI_SENSE_DEVICE_STATUS_DATAREADY = (1 << 1),
kevin1990 7:4dbae381f693 91 /*!< Indicates the availability of measurement data for retrieval */
kevin1990 7:4dbae381f693 92 ADI_SENSE_DEVICE_STATUS_ERROR = (1 << 2),
kevin1990 7:4dbae381f693 93 /*!< Indicates that an error condition has been detected by the device */
kevin1990 7:4dbae381f693 94 ADI_SENSE_DEVICE_STATUS_ALERT = (1 << 3),
kevin1990 7:4dbae381f693 95 /*!< Indicates that an alert condition has been detected by the device */
kevin1990 7:4dbae381f693 96 } ADI_SENSE_DEVICE_STATUS_FLAGS;
kevin1990 7:4dbae381f693 97
kevin1990 7:4dbae381f693 98 /*! Bit masks (flags) for the different diagnostics status indicators. */
kevin1990 7:4dbae381f693 99 typedef enum {
kevin1990 7:4dbae381f693 100 ADI_SENSE_DIAGNOSTICS_STATUS_CHECKSUM_ERROR = (1 << 0),
kevin1990 7:4dbae381f693 101 /*!< Indicates Error on Internal Checksum Calculations */
kevin1990 7:4dbae381f693 102 ADI_SENSE_DIAGNOSTICS_STATUS_COMMS_ERROR = (1 << 1),
kevin1990 7:4dbae381f693 103 /*!< Indicates Error on Internal Device Communications */
kevin1990 7:4dbae381f693 104 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_MONITOR_ERROR = (1 << 2),
kevin1990 7:4dbae381f693 105 /*!< Indicates Low Voltage on Internal Supply Voltages */
kevin1990 7:4dbae381f693 106 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_CAP_ERROR = (1 << 3),
kevin1990 7:4dbae381f693 107 /*!< Indicates Fault on Internal Supply Regulator Capacitor */
kevin1990 7:4dbae381f693 108 ADI_SENSE_DIAGNOSTICS_STATUS_AINM_UV_ERROR = (1 << 4),
kevin1990 7:4dbae381f693 109 /*!< Indicates Under-Voltage Error on Negative Analog Input */
kevin1990 7:4dbae381f693 110 ADI_SENSE_DIAGNOSTICS_STATUS_AINM_OV_ERROR = (1 << 5),
kevin1990 7:4dbae381f693 111 /*!< Indicates Over-Voltage Error on Negative Analog Input */
kevin1990 7:4dbae381f693 112 ADI_SENSE_DIAGNOSTICS_STATUS_AINP_UV_ERROR = (1 << 6),
kevin1990 7:4dbae381f693 113 /*!< Indicates Under-Voltage Error on Positive Analog Input */
kevin1990 7:4dbae381f693 114 ADI_SENSE_DIAGNOSTICS_STATUS_AINP_OV_ERROR = (1 << 7),
kevin1990 7:4dbae381f693 115 /*!< Indicates Over-Voltage Error on Positive Analog Input */
kevin1990 7:4dbae381f693 116 ADI_SENSE_DIAGNOSTICS_STATUS_CONVERSION_ERROR = (1 << 8),
kevin1990 7:4dbae381f693 117 /*!< Indicates Error During Internal ADC Conversions */
kevin1990 7:4dbae381f693 118 ADI_SENSE_DIAGNOSTICS_STATUS_CALIBRATION_ERROR = (1 << 9),
kevin1990 7:4dbae381f693 119 /*!< Indicates Error During Internal Device Calibrations */
kevin1990 7:4dbae381f693 120 } ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS;
kevin1990 7:4dbae381f693 121
kevin1990 7:4dbae381f693 122 /*! Bit masks (flags) for the different channel alert indicators. */
kevin1990 7:4dbae381f693 123 typedef enum {
kevin1990 7:4dbae381f693 124 ADI_SENSE_CHANNEL_ALERT_TIMEOUT = (1 << 0),
kevin1990 7:4dbae381f693 125 /*!< Indicates timeout condition detected on the channel */
kevin1990 7:4dbae381f693 126 ADI_SENSE_CHANNEL_ALERT_UNDER_RANGE = (1 << 1),
kevin1990 7:4dbae381f693 127 /*!< Indicates under-voltage condition detected on the channel */
kevin1990 7:4dbae381f693 128 ADI_SENSE_CHANNEL_ALERT_OVER_RANGE = (1 << 2),
kevin1990 7:4dbae381f693 129 /*!< Indicates over-voltage condition detected on the channel */
kevin1990 7:4dbae381f693 130 ADI_SENSE_CHANNEL_ALERT_LOW_LIMIT = (1 << 3),
kevin1990 7:4dbae381f693 131 /*!< Indicates measurement result was below configured minimum threshold */
kevin1990 7:4dbae381f693 132 ADI_SENSE_CHANNEL_ALERT_HIGH_LIMIT = (1 << 4),
kevin1990 7:4dbae381f693 133 /*!< Indicates measurement result was above configured maximum threshold */
kevin1990 7:4dbae381f693 134 ADI_SENSE_CHANNEL_ALERT_SENSOR_OPEN = (1 << 5),
kevin1990 7:4dbae381f693 135 /*!< Indicates open circuit or mis-wire condition detected on the channel */
kevin1990 7:4dbae381f693 136 ADI_SENSE_CHANNEL_ALERT_REF_DETECT = (1 << 6),
kevin1990 7:4dbae381f693 137 /*!< Indicates reference-detect error condition detected on the channel */
kevin1990 7:4dbae381f693 138 } ADI_SENSE_CHANNEL_ALERT_FLAGS;
kevin1990 7:4dbae381f693 139
kevin1990 7:4dbae381f693 140 /*! Status details retreived from the ADI Sense device. */
kevin1990 7:4dbae381f693 141 typedef struct {
kevin1990 7:4dbae381f693 142 ADI_SENSE_DEVICE_STATUS_FLAGS deviceStatus;
kevin1990 7:4dbae381f693 143 /*!< General summary status information from the device */
kevin1990 7:4dbae381f693 144 ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS diagnosticsStatus;
kevin1990 7:4dbae381f693 145 /*!< Diagnostic error status information from the device */
kevin1990 7:4dbae381f693 146 ADI_SENSE_CHANNEL_ALERT_FLAGS channelAlerts[ADI_SENSE_MAX_CHANNELS];
kevin1990 7:4dbae381f693 147 /*!< Per-channel alert status information from the device */
kevin1990 7:4dbae381f693 148 } ADI_SENSE_STATUS;
kevin1990 7:4dbae381f693 149
kevin1990 7:4dbae381f693 150 /*! Data sample details retreived from the ADI Sense device. */
kevin1990 7:4dbae381f693 151 typedef struct {
kevin1990 7:4dbae381f693 152 ADI_SENSE_DEVICE_STATUS_FLAGS status;
kevin1990 7:4dbae381f693 153 /*!< Device summary status snapshot when the sample was recorded */
kevin1990 7:4dbae381f693 154 ADI_SENSE_CHANNEL_ID channelId;
kevin1990 7:4dbae381f693 155 /*!< The measurement channel from which this sample was obtained */
kevin1990 7:4dbae381f693 156 uint32_t rawValue;
kevin1990 7:4dbae381f693 157 /*!< The raw (unprocessed) value obtained directly from the measurement
kevin1990 7:4dbae381f693 158 * channel, if available
kevin1990 7:4dbae381f693 159 */
kevin1990 7:4dbae381f693 160 float32_t processedValue;
kevin1990 7:4dbae381f693 161 /*!< The processed value obtained from the measurement channel, as a final
kevin1990 7:4dbae381f693 162 * measurement value, following calibration and linearisation correction,
kevin1990 7:4dbae381f693 163 * and conversion into an appropriate unit of measurement.
kevin1990 7:4dbae381f693 164 */
kevin1990 7:4dbae381f693 165 } ADI_SENSE_DATA_SAMPLE;
kevin1990 7:4dbae381f693 166
kevin1990 7:4dbae381f693 167
kevin1990 7:4dbae381f693 168 /******************************************************************************
kevin1990 7:4dbae381f693 169 * ADI Sense High-Level API function prototypes
kevin1990 7:4dbae381f693 170 *****************************************************************************/
kevin1990 7:4dbae381f693 171
kevin1990 7:4dbae381f693 172 /*!
kevin1990 7:4dbae381f693 173 * @brief Open ADI Sense device handle and set up communication interface.
kevin1990 7:4dbae381f693 174 *
kevin1990 7:4dbae381f693 175 * @param[in] nDeviceIndex Zero-based index number identifying this device
kevin1990 7:4dbae381f693 176 * instance. Note that this will be used to
kevin1990 7:4dbae381f693 177 * retrieve a specific device configuration for
kevin1990 7:4dbae381f693 178 * this device (see @ref adi_sense_SetDeviceConfig
kevin1990 7:4dbae381f693 179 * and @ref ADI_SENSE_CONFIG)
kevin1990 7:4dbae381f693 180 * @param[in] pConnectionInfo Host-specific connection details (e.g. SPI, GPIO)
kevin1990 7:4dbae381f693 181 * @param[out] phDevice Pointer to return an ADI Sense device handle
kevin1990 7:4dbae381f693 182 *
kevin1990 7:4dbae381f693 183 * @return Status
kevin1990 7:4dbae381f693 184 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 185 * - #ADI_SENSE_NO_MEM Failed to allocate memory resources.
kevin1990 7:4dbae381f693 186 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid device index specified
kevin1990 7:4dbae381f693 187 *
kevin1990 7:4dbae381f693 188 * @details Configure and initialise the Log interface and the SPI/GPIO
kevin1990 7:4dbae381f693 189 * communication interface to the ADISense module.
kevin1990 7:4dbae381f693 190 */
kevin1990 7:4dbae381f693 191 ADI_SENSE_RESULT adi_sense_Open(
kevin1990 7:4dbae381f693 192 unsigned const nDeviceIndex,
kevin1990 7:4dbae381f693 193 ADI_SENSE_CONNECTION * const pConnectionInfo,
kevin1990 7:4dbae381f693 194 ADI_SENSE_DEVICE_HANDLE * const phDevice);
kevin1990 7:4dbae381f693 195
kevin1990 7:4dbae381f693 196 /*!
kevin1990 7:4dbae381f693 197 * @brief Close ADI Sense device context and free resources.
kevin1990 7:4dbae381f693 198 *
kevin1990 7:4dbae381f693 199 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 200 *
kevin1990 7:4dbae381f693 201 * @return Status
kevin1990 7:4dbae381f693 202 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 203 */
kevin1990 7:4dbae381f693 204 ADI_SENSE_RESULT adi_sense_Close(
kevin1990 7:4dbae381f693 205 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 206
kevin1990 7:4dbae381f693 207 /*!
kevin1990 7:4dbae381f693 208 * @brief Get the current state of the specified GPIO input signal.
kevin1990 7:4dbae381f693 209 *
kevin1990 7:4dbae381f693 210 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 211 * @param[in] ePin GPIO pin to query
kevin1990 7:4dbae381f693 212 * @param[out] pbError Pointer to return the state of the status signal GPIO pin
kevin1990 7:4dbae381f693 213 *
kevin1990 7:4dbae381f693 214 * @return Status
kevin1990 7:4dbae381f693 215 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 216 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
kevin1990 7:4dbae381f693 217 *
kevin1990 7:4dbae381f693 218 * @details Sets *pbAsserted to true if the status signal is asserted, or false
kevin1990 7:4dbae381f693 219 * otherwise.
kevin1990 7:4dbae381f693 220 */
kevin1990 7:4dbae381f693 221 ADI_SENSE_RESULT adi_sense_GetGpioState(
kevin1990 7:4dbae381f693 222 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 223 ADI_SENSE_GPIO_PIN const ePinId,
kevin1990 7:4dbae381f693 224 bool_t * const pbAsserted);
kevin1990 7:4dbae381f693 225
kevin1990 7:4dbae381f693 226 /*!
kevin1990 7:4dbae381f693 227 * @brief Register an application-defined callback function for GPIO interrupts
kevin1990 7:4dbae381f693 228 *
kevin1990 7:4dbae381f693 229 * @param[in] hDevice ADI Sense context handle (@ref adi_sense_Open)
kevin1990 7:4dbae381f693 230 * @param[in] ePin GPIO pin on which to enable/disable interrupts
kevin1990 7:4dbae381f693 231 * @param[in] callbackFunction Function to be called when an interrupt occurs.
kevin1990 7:4dbae381f693 232 * Specify NULL here to disable interrupts.
kevin1990 7:4dbae381f693 233 * @param[in] pCallbackParam Optional opaque parameter passed to the callback
kevin1990 7:4dbae381f693 234 *
kevin1990 7:4dbae381f693 235 * @return Status
kevin1990 7:4dbae381f693 236 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 237 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
kevin1990 7:4dbae381f693 238 */
kevin1990 7:4dbae381f693 239 ADI_SENSE_RESULT adi_sense_RegisterGpioCallback(
kevin1990 7:4dbae381f693 240 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 241 ADI_SENSE_GPIO_PIN const ePinId,
kevin1990 7:4dbae381f693 242 ADI_SENSE_GPIO_CALLBACK const callbackFunction,
kevin1990 7:4dbae381f693 243 void * const pCallbackParam);
kevin1990 7:4dbae381f693 244
kevin1990 7:4dbae381f693 245 /*!
kevin1990 7:4dbae381f693 246 * @brief Reset the ADI Sense device.
kevin1990 7:4dbae381f693 247 *
kevin1990 7:4dbae381f693 248 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 249 *
kevin1990 7:4dbae381f693 250 * @return Status
kevin1990 7:4dbae381f693 251 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 252 *
kevin1990 7:4dbae381f693 253 * @details Trigger a hardware-reset of the ADI Sense device.
kevin1990 7:4dbae381f693 254 *
kevin1990 7:4dbae381f693 255 * @note The device may require several seconds before it is ready for use
kevin1990 7:4dbae381f693 256 * again. @ref adi_sense_GetDeviceReadyState may be used to check if
kevin1990 7:4dbae381f693 257 * the device is ready.
kevin1990 7:4dbae381f693 258 */
kevin1990 7:4dbae381f693 259 ADI_SENSE_RESULT adi_sense_Reset(
kevin1990 7:4dbae381f693 260 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 261
kevin1990 7:4dbae381f693 262 /*!
kevin1990 7:4dbae381f693 263 * @brief Check if the device is ready, following power-up or a reset.
kevin1990 7:4dbae381f693 264 *
kevin1990 7:4dbae381f693 265 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 266 * @param[out] pbReady Pointer to return true if the device is ready, or false
kevin1990 7:4dbae381f693 267 * otherwise
kevin1990 7:4dbae381f693 268 *
kevin1990 7:4dbae381f693 269 * @return Status
kevin1990 7:4dbae381f693 270 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 271 *
kevin1990 7:4dbae381f693 272 * @details This function attempts to read a fixed-value device register via
kevin1990 7:4dbae381f693 273 * the communication interface.
kevin1990 7:4dbae381f693 274 */
kevin1990 7:4dbae381f693 275 ADI_SENSE_RESULT adi_sense_GetDeviceReadyState(
kevin1990 7:4dbae381f693 276 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 277 bool_t * const pbReady);
kevin1990 7:4dbae381f693 278
kevin1990 7:4dbae381f693 279 /*!
kevin1990 7:4dbae381f693 280 * @brief Obtain the product ID from the device.
kevin1990 7:4dbae381f693 281 *
kevin1990 7:4dbae381f693 282 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 283 * @param[out] pProductId Pointer to return the product ID value
kevin1990 7:4dbae381f693 284 *
kevin1990 7:4dbae381f693 285 * @return Status
kevin1990 7:4dbae381f693 286 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 287 *
kevin1990 7:4dbae381f693 288 * @details Reads the product ID registers on the device and returns the value.
kevin1990 7:4dbae381f693 289 */
kevin1990 7:4dbae381f693 290 ADI_SENSE_RESULT adi_sense_GetProductID(
kevin1990 7:4dbae381f693 291 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 292 ADI_SENSE_PRODUCT_ID * const pProductId);
kevin1990 7:4dbae381f693 293
kevin1990 7:4dbae381f693 294 /*!
kevin1990 7:4dbae381f693 295 * @brief Write full configuration settings to the device registers.
kevin1990 7:4dbae381f693 296 *
kevin1990 7:4dbae381f693 297 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 298 * @param[out] pConfig Pointer to the configuration data structure
kevin1990 7:4dbae381f693 299 *
kevin1990 7:4dbae381f693 300 * @return Status
kevin1990 7:4dbae381f693 301 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 302 *
kevin1990 7:4dbae381f693 303 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 304 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 305 *
kevin1990 7:4dbae381f693 306 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 307 */
kevin1990 7:4dbae381f693 308 ADI_SENSE_RESULT adi_sense_SetDeviceConfig(
kevin1990 7:4dbae381f693 309 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 310 ADI_SENSE_CONFIG * const pConfig);
kevin1990 7:4dbae381f693 311
kevin1990 7:4dbae381f693 312 /*!
kevin1990 7:4dbae381f693 313 * @brief Write DSP look-up table data to the device memory
kevin1990 7:4dbae381f693 314 *
kevin1990 7:4dbae381f693 315 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 316 * @param[out] pDspData Pointer to the DSP look-up table data structure
kevin1990 7:4dbae381f693 317 *
kevin1990 7:4dbae381f693 318 * @return Status
kevin1990 7:4dbae381f693 319 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 320 *
kevin1990 7:4dbae381f693 321 * @details Validates the DSP look-up table data format and loads it into
kevin1990 7:4dbae381f693 322 * device memory via dedicated keyhole registers.
kevin1990 7:4dbae381f693 323 *
kevin1990 7:4dbae381f693 324 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 325 */
kevin1990 7:4dbae381f693 326 ADI_SENSE_RESULT adi_sense_SetDspData(
kevin1990 7:4dbae381f693 327 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 328 ADI_SENSE_DSP_LUT_RAW * const pDspData);
kevin1990 7:4dbae381f693 329
kevin1990 7:4dbae381f693 330 /*!
kevin1990 7:4dbae381f693 331 * @brief Apply the configuration settings currently stored in device registers
kevin1990 7:4dbae381f693 332 *
kevin1990 7:4dbae381f693 333 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 334 *
kevin1990 7:4dbae381f693 335 * @return Status
kevin1990 7:4dbae381f693 336 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 337 *
kevin1990 7:4dbae381f693 338 * @details Instructs the ADI Sense device to reload and apply configuration
kevin1990 7:4dbae381f693 339 * from the device configuration registers. Changes to configuration
kevin1990 7:4dbae381f693 340 * registers are ignored by the device until this function is called.
kevin1990 7:4dbae381f693 341 *
kevin1990 7:4dbae381f693 342 * @note No other command must be running when this is called.
kevin1990 7:4dbae381f693 343 */
kevin1990 7:4dbae381f693 344 ADI_SENSE_RESULT adi_sense_ApplyConfigUpdates(
kevin1990 7:4dbae381f693 345 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 346
kevin1990 7:4dbae381f693 347 /*!
kevin1990 7:4dbae381f693 348 * @brief Store the configuration settings to persistent memory on the device.
kevin1990 7:4dbae381f693 349 *
kevin1990 7:4dbae381f693 350 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 351 *
kevin1990 7:4dbae381f693 352 * @return Status
kevin1990 7:4dbae381f693 353 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 354 *
kevin1990 7:4dbae381f693 355 * @details Instructs the ADI Sense device to save the current contents of its
kevin1990 7:4dbae381f693 356 * device configuration registers to non-volatile memory.
kevin1990 7:4dbae381f693 357 *
kevin1990 7:4dbae381f693 358 * @note No other command must be running when this is called.
kevin1990 7:4dbae381f693 359 * @note Do not power down the device while this command is running.
kevin1990 7:4dbae381f693 360 */
kevin1990 7:4dbae381f693 361 ADI_SENSE_RESULT adi_sense_SaveConfig(
kevin1990 7:4dbae381f693 362 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 363
kevin1990 7:4dbae381f693 364 /*!
kevin1990 7:4dbae381f693 365 * @brief Restore configuration settings from persistent memory on the device.
kevin1990 7:4dbae381f693 366 *
kevin1990 7:4dbae381f693 367 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 368 *
kevin1990 7:4dbae381f693 369 * @return Status
kevin1990 7:4dbae381f693 370 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 371 *
kevin1990 7:4dbae381f693 372 * @details Instructs the ADI Sense device to restore the contents of its
kevin1990 7:4dbae381f693 373 * device configuration registers from non-volatile memory.
kevin1990 7:4dbae381f693 374 *
kevin1990 7:4dbae381f693 375 * @note No other command must be running when this is called.
kevin1990 7:4dbae381f693 376 */
kevin1990 7:4dbae381f693 377 ADI_SENSE_RESULT adi_sense_RestoreConfig(
kevin1990 7:4dbae381f693 378 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 379
kevin1990 7:4dbae381f693 380 /*!
kevin1990 7:4dbae381f693 381 * @brief Start the measurement cycles on the device.
kevin1990 7:4dbae381f693 382 *
kevin1990 7:4dbae381f693 383 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 384 *
kevin1990 7:4dbae381f693 385 * @return Status
kevin1990 7:4dbae381f693 386 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 387 *
kevin1990 7:4dbae381f693 388 * @details Instructs the ADI Sense device to start executing measurement cycles
kevin1990 7:4dbae381f693 389 * according to the current applied configuration settings. The
kevin1990 7:4dbae381f693 390 * DATAREADY status signal will be asserted whenever new measurement
kevin1990 7:4dbae381f693 391 * data is published, according to selected settings.
kevin1990 7:4dbae381f693 392 * Measurement cycles may be stopped by calling @ref
kevin1990 7:4dbae381f693 393 * adi_sense_StopMeasurement.
kevin1990 7:4dbae381f693 394 *
kevin1990 7:4dbae381f693 395 * @note No other command must be running when this is called.
kevin1990 7:4dbae381f693 396 */
kevin1990 7:4dbae381f693 397 ADI_SENSE_RESULT adi_sense_StartMeasurement(
kevin1990 7:4dbae381f693 398 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 399
kevin1990 7:4dbae381f693 400 /*!
kevin1990 7:4dbae381f693 401 * @brief Stop the measurement cycles on the device.
kevin1990 7:4dbae381f693 402 *
kevin1990 7:4dbae381f693 403 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 404 *
kevin1990 7:4dbae381f693 405 * @return Status
kevin1990 7:4dbae381f693 406 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 407 *
kevin1990 7:4dbae381f693 408 * @details Instructs the ADI Sense device to stop executing measurement cycles.
kevin1990 7:4dbae381f693 409 * The command may be delayed until the current conversion, if any, has
kevin1990 7:4dbae381f693 410 * been completed and published.
kevin1990 7:4dbae381f693 411 *
kevin1990 7:4dbae381f693 412 * @note To be used only if a measurement command is currently running.
kevin1990 7:4dbae381f693 413 */
kevin1990 7:4dbae381f693 414 ADI_SENSE_RESULT adi_sense_StopMeasurement(
kevin1990 7:4dbae381f693 415 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 416
kevin1990 7:4dbae381f693 417 /*!
kevin1990 7:4dbae381f693 418 * @brief Run built-in diagnostic checks on the device.
kevin1990 7:4dbae381f693 419 *
kevin1990 7:4dbae381f693 420 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 421 *
kevin1990 7:4dbae381f693 422 * @return Status
kevin1990 7:4dbae381f693 423 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 424 *
kevin1990 7:4dbae381f693 425 * @details Instructs the ADI Sense device to start executing measurement cycles
kevin1990 7:4dbae381f693 426 * according to the current applied configuration settings. Device
kevin1990 7:4dbae381f693 427 * status registers will be updated to indicate if any errors were
kevin1990 7:4dbae381f693 428 * detected by the diagnostics checks.
kevin1990 7:4dbae381f693 429 *
kevin1990 7:4dbae381f693 430 * @note No other command must be running when this is called.
kevin1990 7:4dbae381f693 431 */
kevin1990 7:4dbae381f693 432 ADI_SENSE_RESULT adi_sense_RunDiagnostics(
kevin1990 7:4dbae381f693 433 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 7:4dbae381f693 434
kevin1990 7:4dbae381f693 435 /*!
kevin1990 7:4dbae381f693 436 * @brief Read the current status from the device registers.
kevin1990 7:4dbae381f693 437 *
kevin1990 7:4dbae381f693 438 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 439 * @param[out] pStatus Pointer to return the status summary obtained from the
kevin1990 7:4dbae381f693 440 * device.
kevin1990 7:4dbae381f693 441 *
kevin1990 7:4dbae381f693 442 * @return Status
kevin1990 7:4dbae381f693 443 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 444 *
kevin1990 7:4dbae381f693 445 * @details Reads the status registers and extracts the relevant information
kevin1990 7:4dbae381f693 446 * to return to the caller.
kevin1990 7:4dbae381f693 447 *
kevin1990 7:4dbae381f693 448 * @note This may be called at any time, assuming the device is ready.
kevin1990 7:4dbae381f693 449 */
kevin1990 7:4dbae381f693 450 ADI_SENSE_RESULT adi_sense_GetStatus(
kevin1990 7:4dbae381f693 451 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 452 ADI_SENSE_STATUS * const pStatus);
kevin1990 7:4dbae381f693 453
kevin1990 7:4dbae381f693 454 /*!
kevin1990 7:4dbae381f693 455 * @brief Read measurement data samples from the device registers.
kevin1990 7:4dbae381f693 456 *
kevin1990 7:4dbae381f693 457 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 458 * @param[out] pSamples Pointer to return a set of requested data samples.
kevin1990 7:4dbae381f693 459 * @param[in] nRequested Number of requested data samples.
kevin1990 7:4dbae381f693 460 * @param[out] pnReturned Number of valid data samples successfully retrieved.
kevin1990 7:4dbae381f693 461 *
kevin1990 7:4dbae381f693 462 * @return Status
kevin1990 7:4dbae381f693 463 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 464 *
kevin1990 7:4dbae381f693 465 * @details Reads the status registers and extracts the relevant information
kevin1990 7:4dbae381f693 466 * to return to the caller.
kevin1990 7:4dbae381f693 467 *
kevin1990 7:4dbae381f693 468 * @note This is intended to be called only when the DATAREADY status signal
kevin1990 7:4dbae381f693 469 * is asserted.
kevin1990 7:4dbae381f693 470 */
kevin1990 7:4dbae381f693 471 ADI_SENSE_RESULT adi_sense_GetData(
kevin1990 7:4dbae381f693 472 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 473 ADI_SENSE_DATA_SAMPLE * const pSamples,
kevin1990 7:4dbae381f693 474 uint32_t const nRequested,
kevin1990 7:4dbae381f693 475 uint32_t * const pnReturned);
kevin1990 7:4dbae381f693 476
kevin1990 7:4dbae381f693 477 /*!
kevin1990 7:4dbae381f693 478 * @brief Check if a command is currently running on the device.
kevin1990 7:4dbae381f693 479 *
kevin1990 7:4dbae381f693 480 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 481 * @param[out] pbCommandRunning Pointer to return the command running status
kevin1990 7:4dbae381f693 482 *
kevin1990 7:4dbae381f693 483 * @return Status
kevin1990 7:4dbae381f693 484 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 485 *
kevin1990 7:4dbae381f693 486 * @details Reads the device status register to check if a command is running.
kevin1990 7:4dbae381f693 487 */
kevin1990 7:4dbae381f693 488 ADI_SENSE_RESULT adi_sense_GetCommandRunningState(
kevin1990 7:4dbae381f693 489 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 490 bool_t *pbCommandRunning);
kevin1990 7:4dbae381f693 491
kevin1990 7:4dbae381f693 492 /*!
kevin1990 7:4dbae381f693 493 * @brief Get the number of samples available when DATAREADY status is asserted.
kevin1990 7:4dbae381f693 494 *
kevin1990 7:4dbae381f693 495 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 496 * @param[out] peOperatingMode Pointer to return the configured operating mode
kevin1990 7:4dbae381f693 497 * @param[out] peDataPublishMode Pointer to return the configured data publishing mode
kevin1990 7:4dbae381f693 498 * @param[out] pnSamplesPerDataready Pointer to return the calculated number of samples
kevin1990 7:4dbae381f693 499 * available when DATAREADY is asserted
kevin1990 7:4dbae381f693 500 * @param[out] pnSamplesPerCycle Pointer to return the calculated number of samples
kevin1990 7:4dbae381f693 501 * produced per measurement cycle
kevin1990 7:4dbae381f693 502 *
kevin1990 7:4dbae381f693 503 * @return Status
kevin1990 7:4dbae381f693 504 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 505 *
kevin1990 7:4dbae381f693 506 * @details Examines the current configuration settings in the device registers
kevin1990 7:4dbae381f693 507 * to calculate the number of samples available whenever the DATAREADY
kevin1990 7:4dbae381f693 508 * signal is asserted, along with other related information. This may
kevin1990 7:4dbae381f693 509 * be used to allocate buffers to store samples and to determine how
kevin1990 7:4dbae381f693 510 * many samples to retrieve whenever the DATAREADY status is asserted.
kevin1990 7:4dbae381f693 511 */
kevin1990 7:4dbae381f693 512 ADI_SENSE_RESULT adi_sense_GetDataPublishingInfo(
kevin1990 7:4dbae381f693 513 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 514 ADI_SENSE_OPERATING_MODE * const peOperatingMode,
kevin1990 7:4dbae381f693 515 ADI_SENSE_DATA_PUBLISH_MODE * const peDataPublishMode,
kevin1990 7:4dbae381f693 516 uint32_t * const pnSamplesPerDataready,
kevin1990 7:4dbae381f693 517 uint32_t * const pnSamplesPerCycle);
kevin1990 7:4dbae381f693 518
kevin1990 7:4dbae381f693 519
kevin1990 7:4dbae381f693 520 /******************************************************************************
kevin1990 7:4dbae381f693 521 * ADI Sense Low-Level API function prototypes
kevin1990 7:4dbae381f693 522 *****************************************************************************/
kevin1990 7:4dbae381f693 523
kevin1990 7:4dbae381f693 524 /*!
kevin1990 7:4dbae381f693 525 * @brief Read one or more device registers at the specified register address.
kevin1990 7:4dbae381f693 526 *
kevin1990 7:4dbae381f693 527 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 528 * @param[in] nAddress Register map address to read from
kevin1990 7:4dbae381f693 529 * @param[out] pData Pointer to return the register map data
kevin1990 7:4dbae381f693 530 * @param[in] nLength Number of bytes of data to read from the register map
kevin1990 7:4dbae381f693 531 *
kevin1990 7:4dbae381f693 532 * @return Status
kevin1990 7:4dbae381f693 533 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 534 *
kevin1990 7:4dbae381f693 535 * @details Provides direct byte-level read access to the device register map.
kevin1990 7:4dbae381f693 536 * The size and format of the register(s) must be known.
kevin1990 7:4dbae381f693 537 *
kevin1990 7:4dbae381f693 538 * @note Reads from special "keyhole" or "FIFO" registers will be handled
kevin1990 7:4dbae381f693 539 * according to documentation for those registers.
kevin1990 7:4dbae381f693 540 */
kevin1990 7:4dbae381f693 541 ADI_SENSE_RESULT adi_sense_ReadRegister(
kevin1990 7:4dbae381f693 542 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 543 uint16_t const nAddress,
kevin1990 7:4dbae381f693 544 void * const pData,
kevin1990 7:4dbae381f693 545 unsigned const nLength);
kevin1990 7:4dbae381f693 546
kevin1990 7:4dbae381f693 547 /*!
kevin1990 7:4dbae381f693 548 * @brief Write one or more device registers at the specified register address.
kevin1990 7:4dbae381f693 549 *
kevin1990 7:4dbae381f693 550 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 551 * @param[in] nAddress Register map address to read from
kevin1990 7:4dbae381f693 552 * @param[out] pData Pointer to return the register map data
kevin1990 7:4dbae381f693 553 * @param[in] nLength Number of bytes of data to read from the register map
kevin1990 7:4dbae381f693 554 *
kevin1990 7:4dbae381f693 555 * @return Status
kevin1990 7:4dbae381f693 556 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 557 *
kevin1990 7:4dbae381f693 558 * @details Provides direct byte-level write access to the device register map.
kevin1990 7:4dbae381f693 559 * The size and format of the register(s) must be known.
kevin1990 7:4dbae381f693 560 *
kevin1990 7:4dbae381f693 561 * @note Writes to read-only registers will be ignored by the device.
kevin1990 7:4dbae381f693 562 * @note Writes to special "keyhole" registers will be handled according to
kevin1990 7:4dbae381f693 563 * documentation for those registers.
kevin1990 7:4dbae381f693 564 */
kevin1990 7:4dbae381f693 565 ADI_SENSE_RESULT adi_sense_WriteRegister(
kevin1990 7:4dbae381f693 566 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 7:4dbae381f693 567 uint16_t const nAddress,
kevin1990 7:4dbae381f693 568 void * const pData,
kevin1990 7:4dbae381f693 569 unsigned const nLength);
kevin1990 7:4dbae381f693 570
kevin1990 7:4dbae381f693 571 /*!
kevin1990 7:4dbae381f693 572 * @brief Update power configuration settings on the device.
kevin1990 7:4dbae381f693 573 *
kevin1990 7:4dbae381f693 574 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 575 * @param[in] pPowerConfig Power configuration details
kevin1990 7:4dbae381f693 576 *
kevin1990 7:4dbae381f693 577 * @return Status
kevin1990 7:4dbae381f693 578 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 579 *
kevin1990 7:4dbae381f693 580 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 581 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 582 *
kevin1990 7:4dbae381f693 583 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 584 */
kevin1990 7:4dbae381f693 585 ADI_SENSE_RESULT adi_sense_SetPowerConfig(
kevin1990 7:4dbae381f693 586 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 587 ADI_SENSE_POWER_CONFIG *pPowerConfig);
kevin1990 7:4dbae381f693 588
kevin1990 7:4dbae381f693 589 /*!
kevin1990 7:4dbae381f693 590 * @brief Update measurement configuration settings on the device.
kevin1990 7:4dbae381f693 591 *
kevin1990 7:4dbae381f693 592 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 593 * @param[in] pMeasurementConfig Measurement configuration details
kevin1990 7:4dbae381f693 594 *
kevin1990 7:4dbae381f693 595 * @return Status
kevin1990 7:4dbae381f693 596 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 597 *
kevin1990 7:4dbae381f693 598 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 599 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 600 *
kevin1990 7:4dbae381f693 601 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 602 */
kevin1990 7:4dbae381f693 603 ADI_SENSE_RESULT adi_sense_SetMeasurementConfig(
kevin1990 7:4dbae381f693 604 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 605 ADI_SENSE_MEASUREMENT_CONFIG *pMeasurementConfig);
kevin1990 7:4dbae381f693 606
kevin1990 7:4dbae381f693 607 /*!
kevin1990 7:4dbae381f693 608 * @brief Update diagnostics configuration settings on the device.
kevin1990 7:4dbae381f693 609 *
kevin1990 7:4dbae381f693 610 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 611 * @param[in] pDiagnosticsConfig Diagnostics configuration details
kevin1990 7:4dbae381f693 612 *
kevin1990 7:4dbae381f693 613 * @return Status
kevin1990 7:4dbae381f693 614 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 615 *
kevin1990 7:4dbae381f693 616 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 617 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 618 *
kevin1990 7:4dbae381f693 619 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 620 */
kevin1990 7:4dbae381f693 621 ADI_SENSE_RESULT adi_sense_SetDiagnosticsConfig(
kevin1990 7:4dbae381f693 622 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 623 ADI_SENSE_DIAGNOSTICS_CONFIG *pDiagnosticsConfig);
kevin1990 7:4dbae381f693 624
kevin1990 7:4dbae381f693 625 /*!
kevin1990 7:4dbae381f693 626 * @brief Update channel configuration settings for a specific channel.
kevin1990 7:4dbae381f693 627 *
kevin1990 7:4dbae381f693 628 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 629 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 630 * @param[in] pChannelConfig Channel configuration details
kevin1990 7:4dbae381f693 631 *
kevin1990 7:4dbae381f693 632 * @return Status
kevin1990 7:4dbae381f693 633 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 634 *
kevin1990 7:4dbae381f693 635 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 636 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 637 * Allows individual channel configuration details to be dynamically
kevin1990 7:4dbae381f693 638 * adjusted without rewriting the full device configuration.
kevin1990 7:4dbae381f693 639 *
kevin1990 7:4dbae381f693 640 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 641 */
kevin1990 7:4dbae381f693 642 ADI_SENSE_RESULT adi_sense_SetChannelConfig(
kevin1990 7:4dbae381f693 643 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 644 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 645 ADI_SENSE_CHANNEL_CONFIG *pChannelConfig);
kevin1990 7:4dbae381f693 646
kevin1990 7:4dbae381f693 647 /*!
kevin1990 7:4dbae381f693 648 * @brief Update number of measurements-per-cycle for a specific channel.
kevin1990 7:4dbae381f693 649 *
kevin1990 7:4dbae381f693 650 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 651 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 652 * @param[in] nMeasurementsPerCycle Specifies the number of measurements to be
kevin1990 7:4dbae381f693 653 * obtained from this channel in each
kevin1990 7:4dbae381f693 654 * measurement cycle. Set as 0 to disable the
kevin1990 7:4dbae381f693 655 * channel (omit from measurement cycle).
kevin1990 7:4dbae381f693 656 *
kevin1990 7:4dbae381f693 657 * @return Status
kevin1990 7:4dbae381f693 658 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 659 *
kevin1990 7:4dbae381f693 660 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 661 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 662 * Allows individual channels to be dynamically enabled/disabled, and
kevin1990 7:4dbae381f693 663 * measurements-per-cycle to be adjusted.
kevin1990 7:4dbae381f693 664 *
kevin1990 7:4dbae381f693 665 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 666 */
kevin1990 7:4dbae381f693 667 ADI_SENSE_RESULT adi_sense_SetChannelCount(
kevin1990 7:4dbae381f693 668 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 669 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 670 uint32_t nMeasurementsPerCycle);
kevin1990 7:4dbae381f693 671
kevin1990 7:4dbae381f693 672 /*!
kevin1990 7:4dbae381f693 673 * @brief Update the measurement threshold limits for a specified channel.
kevin1990 7:4dbae381f693 674 *
kevin1990 7:4dbae381f693 675 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 676 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 677 * @param[in] highThresholdLimit Optional maximum threshold value for each
kevin1990 7:4dbae381f693 678 * processed sample, to be checked prior to
kevin1990 7:4dbae381f693 679 * publishing. A channel ALERT condition is
kevin1990 7:4dbae381f693 680 * raised if the processed value is higher than
kevin1990 7:4dbae381f693 681 * this threshold. Set to NaN if not required.
kevin1990 7:4dbae381f693 682 * @param[in] lowThresholdLimit Optional minimum threshold value for each
kevin1990 7:4dbae381f693 683 * processed sample, to be checked prior to
kevin1990 7:4dbae381f693 684 * publishing. A channel ALERT condition is
kevin1990 7:4dbae381f693 685 * raised if the processed value is lower than
kevin1990 7:4dbae381f693 686 * this threshold. Set to NaN if not required.
kevin1990 7:4dbae381f693 687 *
kevin1990 7:4dbae381f693 688 * @return Status
kevin1990 7:4dbae381f693 689 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 690 *
kevin1990 7:4dbae381f693 691 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 692 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 693 * Allows individual channel thresholds to be dynamically adjusted.
kevin1990 7:4dbae381f693 694 *
kevin1990 7:4dbae381f693 695 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 696 */
kevin1990 7:4dbae381f693 697 ADI_SENSE_RESULT adi_sense_SetChannelThresholdLimits(
kevin1990 7:4dbae381f693 698 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 699 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 700 float32_t highThresholdLimit,
kevin1990 7:4dbae381f693 701 float32_t lowThresholdLimit);
kevin1990 7:4dbae381f693 702
kevin1990 7:4dbae381f693 703 /*!
kevin1990 7:4dbae381f693 704 * @brief Update the extra settling time for a specified channel.
kevin1990 7:4dbae381f693 705 *
kevin1990 7:4dbae381f693 706 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 707 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 708 * @param[in] settlingTime A minimum settling time is applied internally for
kevin1990 7:4dbae381f693 709 * each channel, based on the sensor type. However,
kevin1990 7:4dbae381f693 710 * additional settling time (microseconds) can
kevin1990 7:4dbae381f693 711 * optionally be specified here. Set to 0 if not
kevin1990 7:4dbae381f693 712 * required.
kevin1990 7:4dbae381f693 713 *
kevin1990 7:4dbae381f693 714 * @return Status
kevin1990 7:4dbae381f693 715 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 716 *
kevin1990 7:4dbae381f693 717 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 718 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 719 * Allows individual channel settling times to be dynamically adjusted.
kevin1990 7:4dbae381f693 720 *
kevin1990 7:4dbae381f693 721 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 722 */
kevin1990 7:4dbae381f693 723 ADI_SENSE_RESULT adi_sense_SetChannelSettlingTime(
kevin1990 7:4dbae381f693 724 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 725 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 726 uint32_t settlingTime);
kevin1990 7:4dbae381f693 727
kevin1990 7:4dbae381f693 728 /*!
kevin1990 7:4dbae381f693 729 * @brief Update configuration settings for a specific ADC analog channel.
kevin1990 7:4dbae381f693 730 *
kevin1990 7:4dbae381f693 731 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 732 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 733 * @param[in] pAdcChannelConfig ADC analog channel configuration details
kevin1990 7:4dbae381f693 734 *
kevin1990 7:4dbae381f693 735 * @return Status
kevin1990 7:4dbae381f693 736 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 737 *
kevin1990 7:4dbae381f693 738 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 739 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 740 * Allows individual channel configuration details to be dynamically
kevin1990 7:4dbae381f693 741 * adjusted without rewriting the full device configuration.
kevin1990 7:4dbae381f693 742 *
kevin1990 7:4dbae381f693 743 * @note Applicable only to ADC analog sensor channels
kevin1990 7:4dbae381f693 744 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 745 */
kevin1990 7:4dbae381f693 746 ADI_SENSE_RESULT adi_sense_SetAdcChannelConfig(
kevin1990 7:4dbae381f693 747 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 748 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 749 ADI_SENSE_CHANNEL_CONFIG *pAdcChannelConfig);
kevin1990 7:4dbae381f693 750
kevin1990 7:4dbae381f693 751 /*!
kevin1990 7:4dbae381f693 752 * @brief Update configuration settings for a specific I2C digital channel.
kevin1990 7:4dbae381f693 753 *
kevin1990 7:4dbae381f693 754 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 755 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 756 * @param[in] pI2cChannelConfig I2C digital channel configuration details
kevin1990 7:4dbae381f693 757 *
kevin1990 7:4dbae381f693 758 * @return Status
kevin1990 7:4dbae381f693 759 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 760 *
kevin1990 7:4dbae381f693 761 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 762 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 763 * Allows individual channel configuration details to be dynamically
kevin1990 7:4dbae381f693 764 * adjusted without rewriting the full device configuration.
kevin1990 7:4dbae381f693 765 *
kevin1990 7:4dbae381f693 766 * @note Applicable only to I2C digital sensor channels
kevin1990 7:4dbae381f693 767 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 768 */
kevin1990 7:4dbae381f693 769 ADI_SENSE_RESULT adi_sense_SetI2cChannelConfig(
kevin1990 7:4dbae381f693 770 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 771 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 772 ADI_SENSE_I2C_CHANNEL_CONFIG *pI2cChannelConfig);
kevin1990 7:4dbae381f693 773
kevin1990 7:4dbae381f693 774
kevin1990 7:4dbae381f693 775 /*!
kevin1990 7:4dbae381f693 776 * @brief Update configuration settings for a specific SPI digital channel.
kevin1990 7:4dbae381f693 777 *
kevin1990 7:4dbae381f693 778 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 779 * @param[in] eChannelId Selects the channel to be updated
kevin1990 7:4dbae381f693 780 * @param[in] pSpiChannelConfig SPI digital channel configuration details
kevin1990 7:4dbae381f693 781 *
kevin1990 7:4dbae381f693 782 * @return Status
kevin1990 7:4dbae381f693 783 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 784 *
kevin1990 7:4dbae381f693 785 * @details Translates configuration details provided into device-specific
kevin1990 7:4dbae381f693 786 * register settings and updates device configuration registers.
kevin1990 7:4dbae381f693 787 * Allows individual channel configuration details to be dynamically
kevin1990 7:4dbae381f693 788 * adjusted without rewriting the full device configuration.
kevin1990 7:4dbae381f693 789 *
kevin1990 7:4dbae381f693 790 * @note Applicable only to SPI digital sensor channels
kevin1990 7:4dbae381f693 791 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
kevin1990 7:4dbae381f693 792 */
kevin1990 7:4dbae381f693 793 ADI_SENSE_RESULT adi_sense_SetSpiChannelConfig(
kevin1990 7:4dbae381f693 794 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 795 ADI_SENSE_CHANNEL_ID eChannelId,
kevin1990 7:4dbae381f693 796 ADI_SENSE_SPI_CHANNEL_CONFIG *pSpiChannelConfig);
kevin1990 7:4dbae381f693 797
kevin1990 7:4dbae381f693 798 /*!
kevin1990 7:4dbae381f693 799 * @brief Read the contents of the ADI Sense internal calibration table
kevin1990 7:4dbae381f693 800 *
kevin1990 7:4dbae381f693 801 * Calibration coefficients/gains/offsets are stored internally in a 2D table of
kevin1990 7:4dbae381f693 802 * 32-bit floating point values. Refer to product documentation for details of
kevin1990 7:4dbae381f693 803 * the rows and columns.
kevin1990 7:4dbae381f693 804 *
kevin1990 7:4dbae381f693 805 * @param[in] hDevice ADI Sense device context handle
kevin1990 7:4dbae381f693 806 * @param[in] buffer Pointer to destination buffer for the calibration data
kevin1990 7:4dbae381f693 807 * @param[in] maxLen The buffer capacity in bytes (e.g. 672 for 56x3 table)
kevin1990 7:4dbae381f693 808 * @param[out] dataLen The number of bytes written to the buffer
kevin1990 7:4dbae381f693 809 * @param[out] nRows Pointer to return the number of table rows (e.g. 56)
kevin1990 7:4dbae381f693 810 * @param[out] nColums Pointer to return the number of table columns (e.g. 3)
kevin1990 7:4dbae381f693 811 *
kevin1990 7:4dbae381f693 812 * @return Status
kevin1990 7:4dbae381f693 813 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 7:4dbae381f693 814 * - #ADI_SENSE_FAILURE
kevin1990 7:4dbae381f693 815 * - #ADI_SENSE_INVALID_OPERATION Invalid register identifier.
kevin1990 7:4dbae381f693 816 */
kevin1990 7:4dbae381f693 817 ADI_SENSE_RESULT adi_sense_ReadCalTable(
kevin1990 7:4dbae381f693 818 ADI_SENSE_DEVICE_HANDLE hDevice,
kevin1990 7:4dbae381f693 819 float *buffer,
kevin1990 7:4dbae381f693 820 unsigned maxLen,
kevin1990 7:4dbae381f693 821 unsigned *dataLen,
kevin1990 7:4dbae381f693 822 unsigned *nRows,
kevin1990 7:4dbae381f693 823 unsigned *nColumns);
kevin1990 7:4dbae381f693 824
kevin1990 7:4dbae381f693 825 #ifdef __cplusplus
kevin1990 7:4dbae381f693 826 }
kevin1990 7:4dbae381f693 827 #endif
kevin1990 7:4dbae381f693 828
kevin1990 7:4dbae381f693 829 /*!
kevin1990 7:4dbae381f693 830 * @}
kevin1990 7:4dbae381f693 831 */
kevin1990 7:4dbae381f693 832
kevin1990 7:4dbae381f693 833 #endif /* __ADI_SENSE_API_H__ */
kevin1990 7:4dbae381f693 834