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