![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ADISense1000 Version 2.1 code base
Fork of AdiSense1000_V21 by
Diff: inc/adi_sense_api.h
- Revision:
- 28:4eb837cd71df
- Parent:
- 26:12d0204be712
--- a/inc/adi_sense_api.h Mon Mar 26 14:50:05 2018 +0000 +++ b/inc/adi_sense_api.h Thu May 17 10:34:45 2018 +0100 @@ -1,10 +1,3 @@ -/*! - ****************************************************************************** - * @file: adi_sense_api.h - * @brief: ADISENSE Host Library Application Programming Interface (API) - *----------------------------------------------------------------------------- - */ - /* Copyright 2017 (c) Analog Devices, Inc. @@ -40,6 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/*! + ****************************************************************************** + * @file: adi_sense_api.h + * @brief: ADISENSE Host Library Application Programming Interface (API) + *----------------------------------------------------------------------------- + */ + #ifndef __ADI_SENSE_API_H__ #define __ADI_SENSE_API_H__ @@ -81,6 +81,8 @@ /*!< SPI connection parameters, required if SPI connection type is used */ ADI_SENSE_PLATFORM_GPIO_CONFIG gpio; /*!< GPIO connection parameters, for device reset and status I/O signals */ + ADI_SENSE_PLATFORM_LOG_CONFIG log; + /*!< Log interface connection parameters, for display/routing of log messages */ } ADI_SENSE_CONNECTION; /*! Bit masks (flags) for the different device status indicators. */ @@ -99,6 +101,8 @@ /*!< Indicates that a configuration error condition has been detected by the device */ ADI_SENSE_DEVICE_STATUS_LUT_ERROR = (1 << 6), /*!< Indicates that a look-up table error condition has been detected by the device */ + ADI_SENSE_DEVICE_STATUS_EXT_FLASH_ERROR = (1 << 7), + /*!< Indicates that an external flash memory error condition has been detected by the device */ } ADI_SENSE_DEVICE_STATUS_FLAGS; /*! Bit masks (flags) for the different diagnostics status indicators. */ @@ -111,14 +115,6 @@ /*!< Indicates Low Voltage on Internal Supply Voltages */ ADI_SENSE_DIAGNOSTICS_STATUS_SUPPLY_CAP_ERROR = (1 << 3), /*!< Indicates Fault on Internal Supply Regulator Capacitor */ - ADI_SENSE_DIAGNOSTICS_STATUS_AINM_UV_ERROR = (1 << 4), - /*!< Indicates Under-Voltage Error on Negative Analog Input */ - ADI_SENSE_DIAGNOSTICS_STATUS_AINM_OV_ERROR = (1 << 5), - /*!< Indicates Over-Voltage Error on Negative Analog Input */ - ADI_SENSE_DIAGNOSTICS_STATUS_AINP_UV_ERROR = (1 << 6), - /*!< Indicates Under-Voltage Error on Positive Analog Input */ - ADI_SENSE_DIAGNOSTICS_STATUS_AINP_OV_ERROR = (1 << 7), - /*!< Indicates Over-Voltage Error on Positive Analog Input */ ADI_SENSE_DIAGNOSTICS_STATUS_CONVERSION_ERROR = (1 << 8), /*!< Indicates Error During Internal ADC Conversions */ ADI_SENSE_DIAGNOSTICS_STATUS_CALIBRATION_ERROR = (1 << 9), @@ -149,10 +145,6 @@ /*!< Indicates digital sensor not-ready error condition detected on the channel */ ADI_SENSE_CHANNEL_ALERT_COMP_NOT_READY = (1 << 10), /*!< Indicates compensation channel not-ready error condition detected on the channel */ - ADI_SENSE_CHANNEL_ALERT_UNDER_VOLTAGE = (1 << 11), - /*!< Indicates under-voltage condition detected on the channel */ - ADI_SENSE_CHANNEL_ALERT_OVER_VOLTAGE = (1 << 12), - /*!< Indicates over-voltage condition detected on the channel */ ADI_SENSE_CHANNEL_ALERT_LUT_UNDER_RANGE = (1 << 13), /*!< Indicates raw sample was under the available LUT/equation range */ ADI_SENSE_CHANNEL_ALERT_LUT_OVER_RANGE = (1 << 14), @@ -206,8 +198,19 @@ ADI_SENSE_MEASUREMENT_MODE_OMIT_RAW, /*!< In this mode, normal measurement cycle(s) are executed and data samples * are returned with raw measurement values omitted for efficiency. */ + ADI_SENSE_MEASUREMENT_MODE_FFT, + /*!< In this mode, FFT mode measurement cycle(s) are executed and data + * samples are returned based on FFT-specific configuration parameters. */ } ADI_SENSE_MEASUREMENT_MODE; +/*! Identifiers for the user configuration slots in persistent memory. */ +typedef enum { + ADI_SENSE_FLASH_CONFIG_1, + ADI_SENSE_FLASH_CONFIG_2, + ADI_SENSE_FLASH_CONFIG_3, + ADI_SENSE_FLASH_CONFIG_4, +} ADI_SENSE_USER_CONFIG_SLOT; + /****************************************************************************** * ADISENSE High-Level API function prototypes @@ -287,6 +290,26 @@ void * const pCallbackParam); /*! + * @brief Trigger a shut down of the device. + * + * @param[in] hDevice ADISENSE device context handle + * + * @return Status + * - #ADI_SENSE_SUCCESS Call completed successfully. + * + * @details Instructs the ADISENSE device to initiate a shut down, + * typically used to conserve power when the device is not + * in use. The device may be restarted by calling + * @ref adi_sense_Reset(). Note that active configuration + * settings are not preserved during shutdown and must be + * reloaded after the device has become ready again. + * + * @note No other command must be running when this is called. + */ +ADI_SENSE_RESULT adi_sense_Shutdown( + ADI_SENSE_DEVICE_HANDLE const hDevice); + +/*! * @brief Reset the ADISENSE device. * * @param[in] hDevice ADISENSE device context handle @@ -374,6 +397,7 @@ * @brief Store the configuration settings to persistent memory on the device. * * @param[in] hDevice ADISENSE device context handle + * @param[in] eSlotId User configuration slot in persistent memory * * @return Status * - #ADI_SENSE_SUCCESS Call completed successfully. @@ -385,12 +409,14 @@ * @note Do not power down the device while this command is running. */ ADI_SENSE_RESULT adi_sense_SaveConfig( - ADI_SENSE_DEVICE_HANDLE const hDevice); + ADI_SENSE_DEVICE_HANDLE const hDevice, + ADI_SENSE_USER_CONFIG_SLOT const eSlotId); /*! * @brief Restore configuration settings from persistent memory on the device. * * @param[in] hDevice ADISENSE device context handle + * @param[in] eSlotId User configuration slot in persistent memory * * @return Status * - #ADI_SENSE_SUCCESS Call completed successfully. @@ -401,9 +427,75 @@ * @note No other command must be running when this is called. */ ADI_SENSE_RESULT adi_sense_RestoreConfig( + ADI_SENSE_DEVICE_HANDLE const hDevice, + ADI_SENSE_USER_CONFIG_SLOT const eSlotId); + +/*! + * @brief Erases the external flash memory. + * + * @param[in] hDevice ADISENSE device context handle + * + * @return Status + * - #ADI_SENSE_SUCCESS Call completed successfully. + * + * @details Sends the bulk erase instruction to the external flash + * device. All stored samples are deleted. + * It is a blocking operation and takes tens of seconds to + * complete. + * + * @note No other command must be running when this is called. + */ +ADI_SENSE_RESULT adi_sense_EraseExternalFlash( ADI_SENSE_DEVICE_HANDLE const hDevice); /*! + * @brief Gets the number of samples stored in the external flash + * memory. + * + * @param[in] hDevice ADISENSE device context handle + * @param[in] pSampleCount Address of the return value. + * + * @return Status + * - #ADI_SENSE_SUCCESS Call completed successfully. + * + * @note No other command must be running when this is called. + */ +ADI_SENSE_RESULT adi_sense_GetExternalFlashSampleCount( + ADI_SENSE_DEVICE_HANDLE const hDevice, + uint32_t * nSampleCount); + +// DEBUG - TO BE DELETED +ADI_SENSE_RESULT adi_sense_SetExternalFlashIndex( + ADI_SENSE_DEVICE_HANDLE const hDevice, + uint32_t nStartIndex); + +/*! + * @brief Read measurement samples stored in the the external flash memory. + * + * @param[in] hDevice ADISENSE device context handle + * @param[out] pSamples Pointer to return a set of requested data + * samples. + * @param[in] nStartIndex Index of first sample to retrieve. + * @param[in] nBytesPerSample The size, in bytes, of each sample. + * @param[in] nRequested Number of requested data samples. + * @param[out] pnReturned Number of valid data samples successfully + * retrieved. + * + * @return Status + * - #ADI_SENSE_SUCCESS Call completed successfully. + * + * @details Reads the status registers and extracts the relevant information + * to return to the caller. + * + */ +ADI_SENSE_RESULT adi_sense_GetExternalFlashData( + ADI_SENSE_DEVICE_HANDLE const hDevice, + ADI_SENSE_DATA_SAMPLE * const pSamples, + uint32_t const nIndex, + uint32_t const nRequested, + uint32_t * const pnReturned); + +/*! * @brief Store the LUT data to persistent memory on the device. * * @param[in] hDevice ADISENSE device context handle @@ -516,6 +608,24 @@ ADI_SENSE_DEVICE_HANDLE const hDevice); /*! + * @brief Run built-in digital calibration on the device. + * + * @param[in] hDevice ADISENSE device context handle + * + * @return Status + * - #ADI_SENSE_SUCCESS Call completed successfully. + * + * @details Instructs the ADISENSE device to execute its calibration + * routines, on any enabled digital channels, according to the + * current applied configuration settings. Device status registers + * will be updated to indicate if any errors were detected. + * + * @note No other command must be running when this is called. + */ +ADI_SENSE_RESULT adi_sense_RunDigitalCalibration( + ADI_SENSE_DEVICE_HANDLE const hDevice); + +/*! * @brief Read the current status from the device registers. * * @param[in] hDevice ADISENSE device context handle @@ -541,6 +651,7 @@ * @param[in] eMeasurementMode Must be set to the same value used for @ref * adi_sense_StartMeasurement(). * @param[out] pSamples Pointer to return a set of requested data samples. + * @param[in] nBytesPerSample The size, in bytes, of each sample. * @param[in] nRequested Number of requested data samples. * @param[out] pnReturned Number of valid data samples successfully retrieved. * @@ -557,6 +668,7 @@ ADI_SENSE_DEVICE_HANDLE const hDevice, ADI_SENSE_MEASUREMENT_MODE const eMeasurementMode, ADI_SENSE_DATA_SAMPLE * const pSamples, + uint8_t const nBytesPerSample, uint32_t const nRequested, uint32_t * const pnReturned); @@ -584,4 +696,3 @@ */ #endif /* __ADI_SENSE_API_H__ */ -