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