ADISense1000 Version 2.1 code base

Fork of AdiSense1000_V21 by Sean Wilson

Committer:
Dan O'Donovan
Date:
Tue Jun 12 21:27:34 2018 +0100
Branch:
v2.0
Revision:
30:119ff4f3aef6
Parent:
29:57edca10d78c
Adding host library and example code for v2.0 release to v2.0 branch

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 */
kevin1990 29:57edca10d78c 84 ADI_SENSE_PLATFORM_LOG_CONFIG log;
kevin1990 29:57edca10d78c 85 /*!< Log interface connection parameters, for display/routing of log messages */
danodonovan 26:12d0204be712 86 } ADI_SENSE_CONNECTION;
danodonovan 26:12d0204be712 87
danodonovan 26:12d0204be712 88 /*! Bit masks (flags) for the different device status indicators. */
danodonovan 26:12d0204be712 89 typedef enum {
danodonovan 26:12d0204be712 90 ADI_SENSE_DEVICE_STATUS_BUSY = (1 << 0),
danodonovan 26:12d0204be712 91 /*!< Indicates that a command is currently running on the device */
danodonovan 26:12d0204be712 92 ADI_SENSE_DEVICE_STATUS_DATAREADY = (1 << 1),
danodonovan 26:12d0204be712 93 /*!< Indicates the availability of measurement data for retrieval */
danodonovan 26:12d0204be712 94 ADI_SENSE_DEVICE_STATUS_ERROR = (1 << 2),
danodonovan 26:12d0204be712 95 /*!< Indicates that an error condition has been detected by the device */
danodonovan 26:12d0204be712 96 ADI_SENSE_DEVICE_STATUS_ALERT = (1 << 3),
danodonovan 26:12d0204be712 97 /*!< Indicates that an alert condition has been detected by the device */
danodonovan 26:12d0204be712 98 ADI_SENSE_DEVICE_STATUS_FIFO_ERROR = (1 << 4),
danodonovan 26:12d0204be712 99 /*!< Indicates that a FIFO error condition has been detected by the device */
danodonovan 26:12d0204be712 100 ADI_SENSE_DEVICE_STATUS_CONFIG_ERROR = (1 << 5),
danodonovan 26:12d0204be712 101 /*!< Indicates that a configuration error condition has been detected by the device */
danodonovan 26:12d0204be712 102 ADI_SENSE_DEVICE_STATUS_LUT_ERROR = (1 << 6),
danodonovan 26:12d0204be712 103 /*!< Indicates that a look-up table error condition has been detected by the device */
kevin1990 29:57edca10d78c 104 ADI_SENSE_DEVICE_STATUS_EXT_FLASH_ERROR = (1 << 7),
kevin1990 29:57edca10d78c 105 /*!< Indicates that an external flash memory error condition has been detected by the device */
danodonovan 26:12d0204be712 106 } ADI_SENSE_DEVICE_STATUS_FLAGS;
danodonovan 26:12d0204be712 107
danodonovan 26:12d0204be712 108 /*! Bit masks (flags) for the different diagnostics status indicators. */
danodonovan 26:12d0204be712 109 typedef enum {
danodonovan 26:12d0204be712 110 ADI_SENSE_DIAGNOSTICS_STATUS_CHECKSUM_ERROR = (1 << 0),
danodonovan 26:12d0204be712 111 /*!< Indicates Error on Internal Checksum Calculations */
danodonovan 26:12d0204be712 112 ADI_SENSE_DIAGNOSTICS_STATUS_COMMS_ERROR = (1 << 1),
danodonovan 26:12d0204be712 113 /*!< Indicates Error on Internal Device Communications */
danodonovan 26:12d0204be712 114 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_MONITOR_ERROR = (1 << 2),
danodonovan 26:12d0204be712 115 /*!< Indicates Low Voltage on Internal Supply Voltages */
danodonovan 26:12d0204be712 116 ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_CAP_ERROR = (1 << 3),
danodonovan 26:12d0204be712 117 /*!< Indicates Fault on Internal Supply Regulator Capacitor */
danodonovan 26:12d0204be712 118 ADI_SENSE_DIAGNOSTICS_STATUS_CONVERSION_ERROR = (1 << 8),
danodonovan 26:12d0204be712 119 /*!< Indicates Error During Internal ADC Conversions */
danodonovan 26:12d0204be712 120 ADI_SENSE_DIAGNOSTICS_STATUS_CALIBRATION_ERROR = (1 << 9),
danodonovan 26:12d0204be712 121 /*!< Indicates Error During Internal Device Calibrations */
danodonovan 26:12d0204be712 122 } ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS;
danodonovan 26:12d0204be712 123
danodonovan 26:12d0204be712 124 /*! Bit masks (flags) for the different channel alert indicators. */
danodonovan 26:12d0204be712 125 typedef enum {
danodonovan 26:12d0204be712 126 ADI_SENSE_CHANNEL_ALERT_TIMEOUT = (1 << 0),
danodonovan 26:12d0204be712 127 /*!< Indicates timeout condition detected on the channel */
danodonovan 26:12d0204be712 128 ADI_SENSE_CHANNEL_ALERT_UNDER_RANGE = (1 << 1),
danodonovan 26:12d0204be712 129 /*!< Indicates raw sample under valid input range, possibly clamped */
danodonovan 26:12d0204be712 130 ADI_SENSE_CHANNEL_ALERT_OVER_RANGE = (1 << 2),
danodonovan 26:12d0204be712 131 /*!< Indicates raw sample over valid input range, possibly clamped */
danodonovan 26:12d0204be712 132 ADI_SENSE_CHANNEL_ALERT_LOW_LIMIT = (1 << 3),
danodonovan 26:12d0204be712 133 /*!< Indicates measurement result was below configured minimum threshold */
danodonovan 26:12d0204be712 134 ADI_SENSE_CHANNEL_ALERT_HIGH_LIMIT = (1 << 4),
danodonovan 26:12d0204be712 135 /*!< Indicates measurement result was above configured maximum threshold */
danodonovan 26:12d0204be712 136 ADI_SENSE_CHANNEL_ALERT_SENSOR_OPEN = (1 << 5),
danodonovan 26:12d0204be712 137 /*!< Indicates open circuit or mis-wire condition detected on the channel */
danodonovan 26:12d0204be712 138 ADI_SENSE_CHANNEL_ALERT_REF_DETECT = (1 << 6),
danodonovan 26:12d0204be712 139 /*!< Indicates reference-detect error condition detected on the channel */
danodonovan 26:12d0204be712 140 ADI_SENSE_CHANNEL_ALERT_CONFIG_ERR = (1 << 7),
danodonovan 26:12d0204be712 141 /*!< Indicates configuration error condition detected on the channel */
danodonovan 26:12d0204be712 142 ADI_SENSE_CHANNEL_ALERT_LUT_ERR = (1 << 8),
danodonovan 26:12d0204be712 143 /*!< Indicates look-up table error condition detected on the channel */
danodonovan 26:12d0204be712 144 ADI_SENSE_CHANNEL_ALERT_SENSOR_NOT_READY = (1 << 9),
danodonovan 26:12d0204be712 145 /*!< Indicates digital sensor not-ready error condition detected on the channel */
danodonovan 26:12d0204be712 146 ADI_SENSE_CHANNEL_ALERT_COMP_NOT_READY = (1 << 10),
danodonovan 26:12d0204be712 147 /*!< Indicates compensation channel not-ready error condition detected on the channel */
danodonovan 26:12d0204be712 148 ADI_SENSE_CHANNEL_ALERT_LUT_UNDER_RANGE = (1 << 13),
danodonovan 26:12d0204be712 149 /*!< Indicates raw sample was under the available LUT/equation range */
danodonovan 26:12d0204be712 150 ADI_SENSE_CHANNEL_ALERT_LUT_OVER_RANGE = (1 << 14),
danodonovan 26:12d0204be712 151 /*!< Indicates raw sample was over the available LUT/equation range */
danodonovan 26:12d0204be712 152 } ADI_SENSE_CHANNEL_ALERT_FLAGS;
danodonovan 26:12d0204be712 153
danodonovan 26:12d0204be712 154 /*! Status details retreived from the ADISENSE device. */
danodonovan 26:12d0204be712 155 typedef struct {
danodonovan 26:12d0204be712 156 ADI_SENSE_DEVICE_STATUS_FLAGS deviceStatus;
danodonovan 26:12d0204be712 157 /*!< General summary status information from the device */
danodonovan 26:12d0204be712 158 ADI_SENSE_DIAGNOSTICS_STATUS_FLAGS diagnosticsStatus;
danodonovan 26:12d0204be712 159 /*!< Diagnostic error status information from the device */
danodonovan 26:12d0204be712 160 ADI_SENSE_CHANNEL_ALERT_FLAGS channelAlerts[ADI_SENSE_MAX_CHANNELS];
danodonovan 26:12d0204be712 161 /*!< Per-channel alert status information from the device */
danodonovan 26:12d0204be712 162 uint32_t errorCode;
danodonovan 26:12d0204be712 163 /*!< Code identifying the last error signalled by the device */
danodonovan 26:12d0204be712 164 uint32_t alertCode;
danodonovan 26:12d0204be712 165 /*!< Code identifying the last alert signalled by the device */
Dan O'Donovan 30:119ff4f3aef6 166 uint32_t debugCode;
Dan O'Donovan 30:119ff4f3aef6 167 /*!< Supplementary code related to the last error/alert */
danodonovan 26:12d0204be712 168 uint32_t channelAlertCodes[ADI_SENSE_MAX_CHANNELS];
danodonovan 26:12d0204be712 169 /*!< Per-channel code identifying the last alert signalled for each channel */
danodonovan 26:12d0204be712 170 } ADI_SENSE_STATUS;
danodonovan 26:12d0204be712 171
danodonovan 26:12d0204be712 172 /*! Data sample details retreived from the ADISENSE device. */
danodonovan 26:12d0204be712 173 typedef struct {
danodonovan 26:12d0204be712 174 ADI_SENSE_DEVICE_STATUS_FLAGS status;
danodonovan 26:12d0204be712 175 /*!< Device summary status snapshot when the sample was recorded */
danodonovan 26:12d0204be712 176 uint32_t channelId;
danodonovan 26:12d0204be712 177 /*!< The measurement channel from which this sample was obtained */
danodonovan 26:12d0204be712 178 uint32_t rawValue;
danodonovan 26:12d0204be712 179 /*!< The raw (unprocessed) value obtained directly from the measurement
danodonovan 26:12d0204be712 180 * channel, if available
danodonovan 26:12d0204be712 181 */
danodonovan 26:12d0204be712 182 float32_t processedValue;
danodonovan 26:12d0204be712 183 /*!< The processed value obtained from the measurement channel, as a final
danodonovan 26:12d0204be712 184 * measurement value, following calibration and linearisation correction,
danodonovan 26:12d0204be712 185 * and conversion into an appropriate unit of measurement.
danodonovan 26:12d0204be712 186 */
danodonovan 26:12d0204be712 187 } ADI_SENSE_DATA_SAMPLE;
danodonovan 26:12d0204be712 188
danodonovan 26:12d0204be712 189 /*! Measurement mode options for the ADISENSE device.
danodonovan 26:12d0204be712 190 * @ref adi_sense_StartMeasurement
danodonovan 26:12d0204be712 191 */
danodonovan 26:12d0204be712 192 typedef enum {
danodonovan 26:12d0204be712 193 ADI_SENSE_MEASUREMENT_MODE_HEALTHCHECK = 1,
danodonovan 26:12d0204be712 194 /*!< In this mode, a special health-check measurement cycle is executed,
danodonovan 26:12d0204be712 195 * carrying out a single conversion per channel with measurement
danodonovan 26:12d0204be712 196 * diagnostics enabled, intended for use as a system health check. */
danodonovan 26:12d0204be712 197 ADI_SENSE_MEASUREMENT_MODE_NORMAL,
danodonovan 26:12d0204be712 198 /*!< In this mode, normal measurement cycle(s) are executed and data samples
danodonovan 26:12d0204be712 199 * are returned with raw measurement values included. */
danodonovan 26:12d0204be712 200 ADI_SENSE_MEASUREMENT_MODE_OMIT_RAW,
danodonovan 26:12d0204be712 201 /*!< In this mode, normal measurement cycle(s) are executed and data samples
danodonovan 26:12d0204be712 202 * are returned with raw measurement values omitted for efficiency. */
Dan O'Donovan 27:567abf893938 203 ADI_SENSE_MEASUREMENT_MODE_FFT,
Dan O'Donovan 27:567abf893938 204 /*!< In this mode, FFT mode measurement cycle(s) are executed and data
Dan O'Donovan 27:567abf893938 205 * samples are returned based on FFT-specific configuration parameters. */
danodonovan 26:12d0204be712 206 } ADI_SENSE_MEASUREMENT_MODE;
danodonovan 26:12d0204be712 207
kevin1990 29:57edca10d78c 208 /*! Identifiers for the user configuration slots in persistent memory. */
kevin1990 29:57edca10d78c 209 typedef enum {
kevin1990 29:57edca10d78c 210 ADI_SENSE_FLASH_CONFIG_1,
kevin1990 29:57edca10d78c 211 ADI_SENSE_FLASH_CONFIG_2,
kevin1990 29:57edca10d78c 212 ADI_SENSE_FLASH_CONFIG_3,
kevin1990 29:57edca10d78c 213 ADI_SENSE_FLASH_CONFIG_4,
kevin1990 29:57edca10d78c 214 } ADI_SENSE_USER_CONFIG_SLOT;
kevin1990 29:57edca10d78c 215
danodonovan 26:12d0204be712 216
danodonovan 26:12d0204be712 217 /******************************************************************************
danodonovan 26:12d0204be712 218 * ADISENSE High-Level API function prototypes
danodonovan 26:12d0204be712 219 *****************************************************************************/
danodonovan 26:12d0204be712 220
danodonovan 26:12d0204be712 221 /*!
danodonovan 26:12d0204be712 222 * @brief Open ADISENSE device handle and set up communication interface.
danodonovan 26:12d0204be712 223 *
danodonovan 26:12d0204be712 224 * @param[in] nDeviceIndex Zero-based index number identifying this device
danodonovan 26:12d0204be712 225 * instance. Note that this will be used to
danodonovan 26:12d0204be712 226 * retrieve a specific device configuration for
danodonovan 26:12d0204be712 227 * this device (see @ref adi_sense_SetConfig
danodonovan 26:12d0204be712 228 * and @ref ADI_SENSE_CONFIG)
danodonovan 26:12d0204be712 229 * @param[in] pConnectionInfo Host-specific connection details (e.g. SPI, GPIO)
danodonovan 26:12d0204be712 230 * @param[out] phDevice Pointer to return an ADISENSE device handle
danodonovan 26:12d0204be712 231 *
danodonovan 26:12d0204be712 232 * @return Status
danodonovan 26:12d0204be712 233 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 234 * - #ADI_SENSE_NO_MEM Failed to allocate memory resources.
danodonovan 26:12d0204be712 235 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid device index specified
danodonovan 26:12d0204be712 236 *
danodonovan 26:12d0204be712 237 * @details Configure and initialise the Log interface and the SPI/GPIO
danodonovan 26:12d0204be712 238 * communication interface to the ADISense module.
danodonovan 26:12d0204be712 239 */
danodonovan 26:12d0204be712 240 ADI_SENSE_RESULT adi_sense_Open(
danodonovan 26:12d0204be712 241 unsigned const nDeviceIndex,
danodonovan 26:12d0204be712 242 ADI_SENSE_CONNECTION * const pConnectionInfo,
danodonovan 26:12d0204be712 243 ADI_SENSE_DEVICE_HANDLE * const phDevice);
danodonovan 26:12d0204be712 244
danodonovan 26:12d0204be712 245 /*!
danodonovan 26:12d0204be712 246 * @brief Close ADISENSE device context and free resources.
danodonovan 26:12d0204be712 247 *
danodonovan 26:12d0204be712 248 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 249 *
danodonovan 26:12d0204be712 250 * @return Status
danodonovan 26:12d0204be712 251 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 252 */
danodonovan 26:12d0204be712 253 ADI_SENSE_RESULT adi_sense_Close(
danodonovan 26:12d0204be712 254 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 255
danodonovan 26:12d0204be712 256 /*!
danodonovan 26:12d0204be712 257 * @brief Get the current state of the specified GPIO input signal.
danodonovan 26:12d0204be712 258 *
danodonovan 26:12d0204be712 259 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 260 * @param[in] ePinId GPIO pin to query
danodonovan 26:12d0204be712 261 * @param[out] pbAsserted Pointer to return the state of the status signal GPIO pin
danodonovan 26:12d0204be712 262 *
danodonovan 26:12d0204be712 263 * @return Status
danodonovan 26:12d0204be712 264 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 265 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
danodonovan 26:12d0204be712 266 *
danodonovan 26:12d0204be712 267 * @details Sets *pbAsserted to true if the status signal is asserted, or false
danodonovan 26:12d0204be712 268 * otherwise.
danodonovan 26:12d0204be712 269 */
danodonovan 26:12d0204be712 270 ADI_SENSE_RESULT adi_sense_GetGpioState(
danodonovan 26:12d0204be712 271 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 272 ADI_SENSE_GPIO_PIN const ePinId,
Dan O'Donovan 30:119ff4f3aef6 273 bool * const pbAsserted);
danodonovan 26:12d0204be712 274
danodonovan 26:12d0204be712 275 /*!
danodonovan 26:12d0204be712 276 * @brief Register an application-defined callback function for GPIO interrupts
danodonovan 26:12d0204be712 277 *
danodonovan 26:12d0204be712 278 * @param[in] hDevice ADISENSE context handle (@ref adi_sense_Open)
danodonovan 26:12d0204be712 279 * @param[in] ePinId GPIO pin on which to enable/disable interrupts
danodonovan 26:12d0204be712 280 * @param[in] callbackFunction Function to be called when an interrupt occurs.
danodonovan 26:12d0204be712 281 * Specify NULL here to disable interrupts.
danodonovan 26:12d0204be712 282 * @param[in] pCallbackParam Optional opaque parameter passed to the callback
danodonovan 26:12d0204be712 283 *
danodonovan 26:12d0204be712 284 * @return Status
danodonovan 26:12d0204be712 285 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 286 * - #ADI_SENSE_INVALID_DEVICE_NUM Invalid GPIO pin specified.
danodonovan 26:12d0204be712 287 */
danodonovan 26:12d0204be712 288 ADI_SENSE_RESULT adi_sense_RegisterGpioCallback(
danodonovan 26:12d0204be712 289 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 290 ADI_SENSE_GPIO_PIN const ePinId,
danodonovan 26:12d0204be712 291 ADI_SENSE_GPIO_CALLBACK const callbackFunction,
danodonovan 26:12d0204be712 292 void * const pCallbackParam);
danodonovan 26:12d0204be712 293
danodonovan 26:12d0204be712 294 /*!
kevin1990 29:57edca10d78c 295 * @brief Trigger a shut down of the device.
kevin1990 29:57edca10d78c 296 *
kevin1990 29:57edca10d78c 297 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 298 *
kevin1990 29:57edca10d78c 299 * @return Status
kevin1990 29:57edca10d78c 300 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 29:57edca10d78c 301 *
kevin1990 29:57edca10d78c 302 * @details Instructs the ADISENSE device to initiate a shut down,
kevin1990 29:57edca10d78c 303 * typically used to conserve power when the device is not
kevin1990 29:57edca10d78c 304 * in use. The device may be restarted by calling
kevin1990 29:57edca10d78c 305 * @ref adi_sense_Reset(). Note that active configuration
kevin1990 29:57edca10d78c 306 * settings are not preserved during shutdown and must be
kevin1990 29:57edca10d78c 307 * reloaded after the device has become ready again.
kevin1990 29:57edca10d78c 308 *
kevin1990 29:57edca10d78c 309 * @note No other command must be running when this is called.
kevin1990 29:57edca10d78c 310 */
kevin1990 29:57edca10d78c 311 ADI_SENSE_RESULT adi_sense_Shutdown(
kevin1990 29:57edca10d78c 312 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 29:57edca10d78c 313
kevin1990 29:57edca10d78c 314 /*!
danodonovan 26:12d0204be712 315 * @brief Reset the ADISENSE device.
danodonovan 26:12d0204be712 316 *
danodonovan 26:12d0204be712 317 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 318 *
danodonovan 26:12d0204be712 319 * @return Status
danodonovan 26:12d0204be712 320 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 321 *
danodonovan 26:12d0204be712 322 * @details Trigger a hardware-reset of the ADISENSE device.
danodonovan 26:12d0204be712 323 *
danodonovan 26:12d0204be712 324 * @note The device may require several seconds before it is ready for use
danodonovan 26:12d0204be712 325 * again. @ref adi_sense_GetDeviceReadyState may be used to check if
danodonovan 26:12d0204be712 326 * the device is ready.
danodonovan 26:12d0204be712 327 */
danodonovan 26:12d0204be712 328 ADI_SENSE_RESULT adi_sense_Reset(
danodonovan 26:12d0204be712 329 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 330
danodonovan 26:12d0204be712 331 /*!
danodonovan 26:12d0204be712 332 * @brief Check if the device is ready, following power-up or a reset.
danodonovan 26:12d0204be712 333 *
danodonovan 26:12d0204be712 334 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 335 * @param[out] pbReady Pointer to return true if the device is ready, or false
danodonovan 26:12d0204be712 336 * otherwise
danodonovan 26:12d0204be712 337 *
danodonovan 26:12d0204be712 338 * @return Status
danodonovan 26:12d0204be712 339 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 340 *
danodonovan 26:12d0204be712 341 * @details This function attempts to read a fixed-value device register via
danodonovan 26:12d0204be712 342 * the communication interface.
danodonovan 26:12d0204be712 343 */
danodonovan 26:12d0204be712 344 ADI_SENSE_RESULT adi_sense_GetDeviceReadyState(
danodonovan 26:12d0204be712 345 ADI_SENSE_DEVICE_HANDLE const hDevice,
Dan O'Donovan 30:119ff4f3aef6 346 bool * const pbReady);
danodonovan 26:12d0204be712 347
danodonovan 26:12d0204be712 348 /*!
danodonovan 26:12d0204be712 349 * @brief Obtain the product ID from the device.
danodonovan 26:12d0204be712 350 *
danodonovan 26:12d0204be712 351 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 352 * @param[out] pProductId Pointer to return the product ID value
danodonovan 26:12d0204be712 353 *
danodonovan 26:12d0204be712 354 * @return Status
danodonovan 26:12d0204be712 355 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 356 *
danodonovan 26:12d0204be712 357 * @details Reads the product ID registers on the device and returns the value.
danodonovan 26:12d0204be712 358 */
danodonovan 26:12d0204be712 359 ADI_SENSE_RESULT adi_sense_GetProductID(
danodonovan 26:12d0204be712 360 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 361 ADI_SENSE_PRODUCT_ID * const pProductId);
danodonovan 26:12d0204be712 362
danodonovan 26:12d0204be712 363 /*!
danodonovan 26:12d0204be712 364 * @brief Write full configuration settings to the device registers.
danodonovan 26:12d0204be712 365 *
danodonovan 26:12d0204be712 366 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 367 * @param[out] pConfig Pointer to the configuration data structure
danodonovan 26:12d0204be712 368 *
danodonovan 26:12d0204be712 369 * @return Status
danodonovan 26:12d0204be712 370 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 371 *
danodonovan 26:12d0204be712 372 * @details Translates configuration details provided into device-specific
danodonovan 26:12d0204be712 373 * register settings and updates device configuration registers.
danodonovan 26:12d0204be712 374 *
danodonovan 26:12d0204be712 375 * @note Settings are not applied until adi_sense_ApplyConfigUpdates() is called
danodonovan 26:12d0204be712 376 */
danodonovan 26:12d0204be712 377 ADI_SENSE_RESULT adi_sense_SetConfig(
danodonovan 26:12d0204be712 378 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 379 ADI_SENSE_CONFIG * const pConfig);
danodonovan 26:12d0204be712 380
danodonovan 26:12d0204be712 381 /*!
danodonovan 26:12d0204be712 382 * @brief Apply the configuration settings currently stored in device registers
danodonovan 26:12d0204be712 383 *
danodonovan 26:12d0204be712 384 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 385 *
danodonovan 26:12d0204be712 386 * @return Status
danodonovan 26:12d0204be712 387 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 388 *
danodonovan 26:12d0204be712 389 * @details Instructs the ADISENSE device to reload and apply configuration
danodonovan 26:12d0204be712 390 * from the device configuration registers. Changes to configuration
danodonovan 26:12d0204be712 391 * registers are ignored by the device until this function is called.
danodonovan 26:12d0204be712 392 *
danodonovan 26:12d0204be712 393 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 394 */
danodonovan 26:12d0204be712 395 ADI_SENSE_RESULT adi_sense_ApplyConfigUpdates(
danodonovan 26:12d0204be712 396 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 397
danodonovan 26:12d0204be712 398 /*!
danodonovan 26:12d0204be712 399 * @brief Store the configuration settings to persistent memory on the device.
danodonovan 26:12d0204be712 400 *
danodonovan 26:12d0204be712 401 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 402 * @param[in] eSlotId User configuration slot in persistent memory
danodonovan 26:12d0204be712 403 *
danodonovan 26:12d0204be712 404 * @return Status
danodonovan 26:12d0204be712 405 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 406 *
danodonovan 26:12d0204be712 407 * @details Instructs the ADISENSE device to save the current contents of its
danodonovan 26:12d0204be712 408 * device configuration registers to non-volatile memory.
danodonovan 26:12d0204be712 409 *
danodonovan 26:12d0204be712 410 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 411 * @note Do not power down the device while this command is running.
danodonovan 26:12d0204be712 412 */
danodonovan 26:12d0204be712 413 ADI_SENSE_RESULT adi_sense_SaveConfig(
kevin1990 29:57edca10d78c 414 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 29:57edca10d78c 415 ADI_SENSE_USER_CONFIG_SLOT const eSlotId);
danodonovan 26:12d0204be712 416
danodonovan 26:12d0204be712 417 /*!
danodonovan 26:12d0204be712 418 * @brief Restore configuration settings from persistent memory on the device.
danodonovan 26:12d0204be712 419 *
danodonovan 26:12d0204be712 420 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 421 * @param[in] eSlotId User configuration slot in persistent memory
danodonovan 26:12d0204be712 422 *
danodonovan 26:12d0204be712 423 * @return Status
danodonovan 26:12d0204be712 424 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 425 *
danodonovan 26:12d0204be712 426 * @details Instructs the ADISENSE device to restore the contents of its
danodonovan 26:12d0204be712 427 * device configuration registers from non-volatile memory.
danodonovan 26:12d0204be712 428 *
danodonovan 26:12d0204be712 429 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 430 */
danodonovan 26:12d0204be712 431 ADI_SENSE_RESULT adi_sense_RestoreConfig(
kevin1990 29:57edca10d78c 432 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 29:57edca10d78c 433 ADI_SENSE_USER_CONFIG_SLOT const eSlotId);
kevin1990 29:57edca10d78c 434
kevin1990 29:57edca10d78c 435 /*!
kevin1990 29:57edca10d78c 436 * @brief Erases the external flash memory.
kevin1990 29:57edca10d78c 437 *
kevin1990 29:57edca10d78c 438 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 439 *
kevin1990 29:57edca10d78c 440 * @return Status
kevin1990 29:57edca10d78c 441 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 29:57edca10d78c 442 *
kevin1990 29:57edca10d78c 443 * @details Sends the bulk erase instruction to the external flash
kevin1990 29:57edca10d78c 444 * device. All stored samples are deleted.
kevin1990 29:57edca10d78c 445 * It is a blocking operation and takes tens of seconds to
kevin1990 29:57edca10d78c 446 * complete.
kevin1990 29:57edca10d78c 447 *
kevin1990 29:57edca10d78c 448 * @note No other command must be running when this is called.
kevin1990 29:57edca10d78c 449 */
kevin1990 29:57edca10d78c 450 ADI_SENSE_RESULT adi_sense_EraseExternalFlash(
danodonovan 26:12d0204be712 451 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 452
danodonovan 26:12d0204be712 453 /*!
kevin1990 29:57edca10d78c 454 * @brief Gets the number of samples stored in the external flash
kevin1990 29:57edca10d78c 455 * memory.
kevin1990 29:57edca10d78c 456 *
kevin1990 29:57edca10d78c 457 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 458 * @param[in] pSampleCount Address of the return value.
kevin1990 29:57edca10d78c 459 *
kevin1990 29:57edca10d78c 460 * @return Status
kevin1990 29:57edca10d78c 461 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 29:57edca10d78c 462 *
kevin1990 29:57edca10d78c 463 * @note No other command must be running when this is called.
kevin1990 29:57edca10d78c 464 */
kevin1990 29:57edca10d78c 465 ADI_SENSE_RESULT adi_sense_GetExternalFlashSampleCount(
kevin1990 29:57edca10d78c 466 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 29:57edca10d78c 467 uint32_t * nSampleCount);
kevin1990 29:57edca10d78c 468
kevin1990 29:57edca10d78c 469 // DEBUG - TO BE DELETED
kevin1990 29:57edca10d78c 470 ADI_SENSE_RESULT adi_sense_SetExternalFlashIndex(
kevin1990 29:57edca10d78c 471 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 29:57edca10d78c 472 uint32_t nStartIndex);
kevin1990 29:57edca10d78c 473
kevin1990 29:57edca10d78c 474 /*!
kevin1990 29:57edca10d78c 475 * @brief Read measurement samples stored in the the external flash memory.
kevin1990 29:57edca10d78c 476 *
kevin1990 29:57edca10d78c 477 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 478 * @param[out] pSamples Pointer to return a set of requested data
kevin1990 29:57edca10d78c 479 * samples.
kevin1990 29:57edca10d78c 480 * @param[in] nStartIndex Index of first sample to retrieve.
kevin1990 29:57edca10d78c 481 * @param[in] nBytesPerSample The size, in bytes, of each sample.
kevin1990 29:57edca10d78c 482 * @param[in] nRequested Number of requested data samples.
kevin1990 29:57edca10d78c 483 * @param[out] pnReturned Number of valid data samples successfully
kevin1990 29:57edca10d78c 484 * retrieved.
kevin1990 29:57edca10d78c 485 *
kevin1990 29:57edca10d78c 486 * @return Status
kevin1990 29:57edca10d78c 487 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 29:57edca10d78c 488 *
kevin1990 29:57edca10d78c 489 * @details Reads the status registers and extracts the relevant information
kevin1990 29:57edca10d78c 490 * to return to the caller.
kevin1990 29:57edca10d78c 491 *
kevin1990 29:57edca10d78c 492 */
kevin1990 29:57edca10d78c 493 ADI_SENSE_RESULT adi_sense_GetExternalFlashData(
kevin1990 29:57edca10d78c 494 ADI_SENSE_DEVICE_HANDLE const hDevice,
kevin1990 29:57edca10d78c 495 ADI_SENSE_DATA_SAMPLE * const pSamples,
kevin1990 29:57edca10d78c 496 uint32_t const nIndex,
kevin1990 29:57edca10d78c 497 uint32_t const nRequested,
kevin1990 29:57edca10d78c 498 uint32_t * const pnReturned);
kevin1990 29:57edca10d78c 499
kevin1990 29:57edca10d78c 500 /*!
danodonovan 26:12d0204be712 501 * @brief Store the LUT data to persistent memory on the device.
danodonovan 26:12d0204be712 502 *
danodonovan 26:12d0204be712 503 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 504 *
danodonovan 26:12d0204be712 505 * @return Status
danodonovan 26:12d0204be712 506 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 507 *
danodonovan 26:12d0204be712 508 * @details Instructs the ADISENSE device to save the current contents of its
danodonovan 26:12d0204be712 509 * LUT data buffer, set using @ref adi_sense_SetLutData, to
danodonovan 26:12d0204be712 510 * non-volatile memory.
danodonovan 26:12d0204be712 511 *
danodonovan 26:12d0204be712 512 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 513 * @note Do not power down the device while this command is running.
danodonovan 26:12d0204be712 514 */
danodonovan 26:12d0204be712 515 ADI_SENSE_RESULT adi_sense_SaveLutData(
danodonovan 26:12d0204be712 516 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 517
danodonovan 26:12d0204be712 518 /*!
danodonovan 26:12d0204be712 519 * @brief Restore LUT data from persistent memory on the device.
danodonovan 26:12d0204be712 520 *
danodonovan 26:12d0204be712 521 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 522 *
danodonovan 26:12d0204be712 523 * @return Status
danodonovan 26:12d0204be712 524 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 525 *
danodonovan 26:12d0204be712 526 * @details Instructs the ADISENSE device to restore the contents of its
danodonovan 26:12d0204be712 527 * LUT data, previously stored with @ref adi_sense_SaveLutData, from
danodonovan 26:12d0204be712 528 * non-volatile memory.
danodonovan 26:12d0204be712 529 *
danodonovan 26:12d0204be712 530 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 531 */
danodonovan 26:12d0204be712 532 ADI_SENSE_RESULT adi_sense_RestoreLutData(
danodonovan 26:12d0204be712 533 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 534
danodonovan 26:12d0204be712 535 /*!
danodonovan 26:12d0204be712 536 * @brief Start the measurement cycles on the device.
danodonovan 26:12d0204be712 537 *
danodonovan 26:12d0204be712 538 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 539 * @param[in] eMeasurementMode Allows a choice of special modes for the
danodonovan 26:12d0204be712 540 * measurement. See @ref ADI_SENSE_MEASUREMENT_MODE
danodonovan 26:12d0204be712 541 * for further information.
danodonovan 26:12d0204be712 542 *
danodonovan 26:12d0204be712 543 * @return Status
danodonovan 26:12d0204be712 544 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 545 *
danodonovan 26:12d0204be712 546 * @details Instructs the ADISENSE device to start executing measurement cycles
danodonovan 26:12d0204be712 547 * according to the current applied configuration settings. The
danodonovan 26:12d0204be712 548 * DATAREADY status signal will be asserted whenever new measurement
danodonovan 26:12d0204be712 549 * data is published, according to selected settings.
danodonovan 26:12d0204be712 550 * Measurement cycles may be stopped by calling @ref
danodonovan 26:12d0204be712 551 * adi_sense_StopMeasurement.
danodonovan 26:12d0204be712 552 *
danodonovan 26:12d0204be712 553 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 554 */
danodonovan 26:12d0204be712 555 ADI_SENSE_RESULT adi_sense_StartMeasurement(
danodonovan 26:12d0204be712 556 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 557 ADI_SENSE_MEASUREMENT_MODE const eMeasurementMode);
danodonovan 26:12d0204be712 558
danodonovan 26:12d0204be712 559 /*!
danodonovan 26:12d0204be712 560 * @brief Stop the measurement cycles on the device.
danodonovan 26:12d0204be712 561 *
danodonovan 26:12d0204be712 562 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 563 *
danodonovan 26:12d0204be712 564 * @return Status
danodonovan 26:12d0204be712 565 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 566 *
danodonovan 26:12d0204be712 567 * @details Instructs the ADISENSE device to stop executing measurement cycles.
danodonovan 26:12d0204be712 568 * The command may be delayed until the current conversion, if any, has
danodonovan 26:12d0204be712 569 * been completed and published.
danodonovan 26:12d0204be712 570 *
danodonovan 26:12d0204be712 571 * @note To be used only if a measurement command is currently running.
danodonovan 26:12d0204be712 572 */
danodonovan 26:12d0204be712 573 ADI_SENSE_RESULT adi_sense_StopMeasurement(
danodonovan 26:12d0204be712 574 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 575
danodonovan 26:12d0204be712 576 /*!
danodonovan 26:12d0204be712 577 * @brief Run built-in diagnostic checks on the device.
danodonovan 26:12d0204be712 578 *
danodonovan 26:12d0204be712 579 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 580 *
danodonovan 26:12d0204be712 581 * @return Status
danodonovan 26:12d0204be712 582 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 583 *
danodonovan 26:12d0204be712 584 * @details Instructs the ADISENSE device to execute its built-in diagnostic
danodonovan 26:12d0204be712 585 * tests, on any enabled measurement channels, according to the current
danodonovan 26:12d0204be712 586 * applied configuration settings. Device status registers will be
danodonovan 26:12d0204be712 587 * updated to indicate if any errors were detected by the diagnostics.
danodonovan 26:12d0204be712 588 *
danodonovan 26:12d0204be712 589 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 590 */
danodonovan 26:12d0204be712 591 ADI_SENSE_RESULT adi_sense_RunDiagnostics(
danodonovan 26:12d0204be712 592 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 593
danodonovan 26:12d0204be712 594 /*!
danodonovan 26:12d0204be712 595 * @brief Run built-in calibration on the device.
danodonovan 26:12d0204be712 596 *
danodonovan 26:12d0204be712 597 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 598 *
danodonovan 26:12d0204be712 599 * @return Status
danodonovan 26:12d0204be712 600 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 601 *
danodonovan 26:12d0204be712 602 * @details Instructs the ADISENSE device to execute its self-calibration
danodonovan 26:12d0204be712 603 * routines, on any enabled measurement channels, according to the
danodonovan 26:12d0204be712 604 * current applied configuration settings. Device status registers
danodonovan 26:12d0204be712 605 * will be updated to indicate if any errors were detected.
danodonovan 26:12d0204be712 606 *
danodonovan 26:12d0204be712 607 * @note No other command must be running when this is called.
danodonovan 26:12d0204be712 608 */
danodonovan 26:12d0204be712 609 ADI_SENSE_RESULT adi_sense_RunCalibration(
danodonovan 26:12d0204be712 610 ADI_SENSE_DEVICE_HANDLE const hDevice);
danodonovan 26:12d0204be712 611
danodonovan 26:12d0204be712 612 /*!
kevin1990 29:57edca10d78c 613 * @brief Run built-in digital calibration on the device.
kevin1990 29:57edca10d78c 614 *
kevin1990 29:57edca10d78c 615 * @param[in] hDevice ADISENSE device context handle
kevin1990 29:57edca10d78c 616 *
kevin1990 29:57edca10d78c 617 * @return Status
kevin1990 29:57edca10d78c 618 * - #ADI_SENSE_SUCCESS Call completed successfully.
kevin1990 29:57edca10d78c 619 *
kevin1990 29:57edca10d78c 620 * @details Instructs the ADISENSE device to execute its calibration
kevin1990 29:57edca10d78c 621 * routines, on any enabled digital channels, according to the
kevin1990 29:57edca10d78c 622 * current applied configuration settings. Device status registers
kevin1990 29:57edca10d78c 623 * will be updated to indicate if any errors were detected.
kevin1990 29:57edca10d78c 624 *
kevin1990 29:57edca10d78c 625 * @note No other command must be running when this is called.
kevin1990 29:57edca10d78c 626 */
kevin1990 29:57edca10d78c 627 ADI_SENSE_RESULT adi_sense_RunDigitalCalibration(
kevin1990 29:57edca10d78c 628 ADI_SENSE_DEVICE_HANDLE const hDevice);
kevin1990 29:57edca10d78c 629
kevin1990 29:57edca10d78c 630 /*!
danodonovan 26:12d0204be712 631 * @brief Read the current status from the device registers.
danodonovan 26:12d0204be712 632 *
danodonovan 26:12d0204be712 633 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 634 * @param[out] pStatus Pointer to return the status summary obtained from the
danodonovan 26:12d0204be712 635 * device.
danodonovan 26:12d0204be712 636 *
danodonovan 26:12d0204be712 637 * @return Status
danodonovan 26:12d0204be712 638 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 639 *
danodonovan 26:12d0204be712 640 * @details Reads the status registers and extracts the relevant information
danodonovan 26:12d0204be712 641 * to return to the caller.
danodonovan 26:12d0204be712 642 *
danodonovan 26:12d0204be712 643 * @note This may be called at any time, assuming the device is ready.
danodonovan 26:12d0204be712 644 */
danodonovan 26:12d0204be712 645 ADI_SENSE_RESULT adi_sense_GetStatus(
danodonovan 26:12d0204be712 646 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 647 ADI_SENSE_STATUS * const pStatus);
danodonovan 26:12d0204be712 648
danodonovan 26:12d0204be712 649 /*!
danodonovan 26:12d0204be712 650 * @brief Read measurement data samples from the device registers.
danodonovan 26:12d0204be712 651 *
danodonovan 26:12d0204be712 652 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 653 * @param[in] eMeasurementMode Must be set to the same value used for @ref
danodonovan 26:12d0204be712 654 * adi_sense_StartMeasurement().
danodonovan 26:12d0204be712 655 * @param[out] pSamples Pointer to return a set of requested data samples.
Dan O'Donovan 27:567abf893938 656 * @param[in] nBytesPerSample The size, in bytes, of each sample.
danodonovan 26:12d0204be712 657 * @param[in] nRequested Number of requested data samples.
danodonovan 26:12d0204be712 658 * @param[out] pnReturned Number of valid data samples successfully retrieved.
danodonovan 26:12d0204be712 659 *
danodonovan 26:12d0204be712 660 * @return Status
danodonovan 26:12d0204be712 661 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 662 *
danodonovan 26:12d0204be712 663 * @details Reads the status registers and extracts the relevant information
danodonovan 26:12d0204be712 664 * to return to the caller.
danodonovan 26:12d0204be712 665 *
danodonovan 26:12d0204be712 666 * @note This is intended to be called only when the DATAREADY status signal
danodonovan 26:12d0204be712 667 * is asserted.
danodonovan 26:12d0204be712 668 */
danodonovan 26:12d0204be712 669 ADI_SENSE_RESULT adi_sense_GetData(
danodonovan 26:12d0204be712 670 ADI_SENSE_DEVICE_HANDLE const hDevice,
danodonovan 26:12d0204be712 671 ADI_SENSE_MEASUREMENT_MODE const eMeasurementMode,
danodonovan 26:12d0204be712 672 ADI_SENSE_DATA_SAMPLE * const pSamples,
Dan O'Donovan 27:567abf893938 673 uint8_t const nBytesPerSample,
danodonovan 26:12d0204be712 674 uint32_t const nRequested,
danodonovan 26:12d0204be712 675 uint32_t * const pnReturned);
danodonovan 26:12d0204be712 676
danodonovan 26:12d0204be712 677 /*!
danodonovan 26:12d0204be712 678 * @brief Check if a command is currently running on the device.
danodonovan 26:12d0204be712 679 *
danodonovan 26:12d0204be712 680 * @param[in] hDevice ADISENSE device context handle
danodonovan 26:12d0204be712 681 * @param[out] pbCommandRunning Pointer to return the command running status
danodonovan 26:12d0204be712 682 *
danodonovan 26:12d0204be712 683 * @return Status
danodonovan 26:12d0204be712 684 * - #ADI_SENSE_SUCCESS Call completed successfully.
danodonovan 26:12d0204be712 685 *
danodonovan 26:12d0204be712 686 * @details Reads the device status register to check if a command is running.
danodonovan 26:12d0204be712 687 */
danodonovan 26:12d0204be712 688 ADI_SENSE_RESULT adi_sense_GetCommandRunningState(
danodonovan 26:12d0204be712 689 ADI_SENSE_DEVICE_HANDLE hDevice,
Dan O'Donovan 30:119ff4f3aef6 690 bool *pbCommandRunning);
danodonovan 26:12d0204be712 691
danodonovan 26:12d0204be712 692 #ifdef __cplusplus
danodonovan 26:12d0204be712 693 }
danodonovan 26:12d0204be712 694 #endif
danodonovan 26:12d0204be712 695
danodonovan 26:12d0204be712 696 /*!
danodonovan 26:12d0204be712 697 * @}
danodonovan 26:12d0204be712 698 */
danodonovan 26:12d0204be712 699
danodonovan 26:12d0204be712 700 #endif /* __ADI_SENSE_API_H__ */