initial commit

Revision:
32:52445bef314d
Parent:
19:09d58952b65d
Child:
50:d84305e5e1c0
--- a/inc/admw_api.h	Wed Oct 23 16:18:50 2019 +0000
+++ b/inc/admw_api.h	Fri Oct 25 05:08:19 2019 +0000
@@ -50,6 +50,7 @@
 #include "inc/admw_spi.h"
 #include "inc/admw_log.h"
 #include "inc/admw_time.h"
+#include "inc/admw1001/admw1001_sensor_types.h"
 
 /*! @defgroup ADMW_Api ADMW Host Library API
  *  Host library API common to the ADMW product family.
@@ -60,17 +61,9 @@
 extern "C" {
 #endif
 
-/*! The maximum number of channels supported by this API
- * @note Specific ADMW products may implement a lower number of channels */
-#define ADMW_MAX_CHANNELS 16
-
 /*! A handle used in all API functions to identify the ADMW device. */
-
 typedef void* ADMW_DEVICE_HANDLE;
 
-#define ADMW_FORMATTED_VERSION_SIZE     11u
-#define ADMW_VERSION_REG_VAL_SIZE       4u
-#define ADMW1001_FIRMWARE_VERSION_DEFAULT "00.00.0000"
 #define SPI_BUFFER_SIZE                        100u
 
 #define SFL_READ_STATUS_HDR_SIZE               14u
@@ -78,13 +71,16 @@
 #define SFL_READ_STATUS_RESPONSE_SIZE          42u
 
 /*! Supported connection types for communication with the ADMW device. */
-typedef enum {
+typedef enum
+{
     ADMW_CONNECTION_TYPE_SPI = 1,
     /*!< Serial Peripheral Interface (SPI) connection type */
-} ADMW_CONNECTION_TYPE;
+
+}   ADMW_CONNECTION_TYPE;
 
 /*! Connection details for communication with a ADMW device instance. */
-typedef struct {
+typedef struct
+{
     ADMW_CONNECTION_TYPE      type;
     /*!< Connection type selection */
     ADMW_PLATFORM_SPI_CONFIG  spi;
@@ -93,10 +89,12 @@
     /*!< GPIO connection parameters, for device reset and status I/O signals */
     ADMW_PLATFORM_LOG_CONFIG  log;
     /*!< Log interface connection parameters, for display/routing of log messages */
-} ADMW_CONNECTION;
+
+}   ADMW_CONNECTION;
 
 /*! Bit masks (flags) for the different device status indicators. */
-typedef enum {
+typedef enum
+{
     ADMW_DEVICE_STATUS_BUSY         = (1 << 0),
     /*!< Indicates that a command is currently running on the device */
     ADMW_DEVICE_STATUS_DATAREADY    = (1 << 1),
@@ -111,100 +109,110 @@
     /*!< Indicates that a configuration error condition has been detected by the device */
     ADMW_DEVICE_STATUS_LUT_ERROR    = (1 << 6),
     /*!< Indicates that a look-up table error condition has been detected by the device */
-} ADMW_DEVICE_STATUS_FLAGS;
+
+}   ADMW_DEVICE_STATUS_FLAGS;
 
 /*! Bit masks (flags) for the different diagnostics status indicators. */
-typedef enum {
+typedef enum
+{
     ADMW_DIAGNOSTICS_STATUS_CHECKSUM_ERROR       = (1 << 0),
     /*!< Indicates Error on Internal Checksum Calculations */
     ADMW_DIAGNOSTICS_STATUS_CONVERSION_ERROR     = (1 << 8),
     /*!< Indicates Error During Internal ADC Conversions */
     ADMW_DIAGNOSTICS_STATUS_CALIBRATION_ERROR    = (1 << 9),
     /*!< Indicates Error During Internal Device Calibrations */
-} ADMW_DIAGNOSTICS_STATUS_FLAGS;
+
+}   ADMW_DIAGNOSTICS_STATUS_FLAGS;
 
 /*! Bit masks (flags) for the different channel alert indicators. */
-typedef enum {
-    ADMW_CHANNEL_ALERT_TIMEOUT          = (1 << 0),
-    /*!< Indicates timeout condition detected on the channel */
-    ADMW_CHANNEL_ALERT_UNDER_RANGE      = (1 << 1),
-    /*!< Indicates raw sample under valid input range, possibly clamped */
-    ADMW_CHANNEL_ALERT_OVER_RANGE       = (1 << 2),
-    /*!< Indicates raw sample over valid input range, possibly clamped */
-    ADMW_CHANNEL_ALERT_LOW_LIMIT        = (1 << 3),
-    /*!< Indicates measurement result was below configured minimum threshold */
-    ADMW_CHANNEL_ALERT_HIGH_LIMIT       = (1 << 4),
-    /*!< Indicates measurement result was above configured maximum threshold */
-    ADMW_CHANNEL_ALERT_SENSOR_OPEN      = (1 << 5),
-    /*!< Indicates open circuit or mis-wire condition detected on the channel */
-    ADMW_CHANNEL_ALERT_REF_DETECT       = (1 << 6),
-    /*!< Indicates reference-detect error condition detected on the channel */
-    ADMW_CHANNEL_ALERT_CONFIG_ERR       = (1 << 7),
-    /*!< Indicates configuration error condition detected on the channel */
-    ADMW_CHANNEL_ALERT_LUT_ERR          = (1 << 8),
-    /*!< Indicates look-up table error condition detected on the channel */
-    ADMW_CHANNEL_ALERT_SENSOR_NOT_READY = (1 << 9),
-    /*!< Indicates digital sensor not-ready error condition detected on the channel */
-    ADMW_CHANNEL_ALERT_COMP_NOT_READY   = (1 << 10),
-    /*!< Indicates compensation channel not-ready error condition detected on the channel */
-    ADMW_CHANNEL_ALERT_LUT_UNDER_RANGE  = (1 << 13),
-    /*!< Indicates raw sample was under the available LUT/equation range */
-    ADMW_CHANNEL_ALERT_LUT_OVER_RANGE   = (1 << 14),
-    /*!< Indicates raw sample was over the available LUT/equation range */
-} ADMW_CHANNEL_ALERT_FLAGS;
+typedef enum
+{
+    ADMW_ALERT_DETAIL_CH_RESULT_VALID             = (1 << 0),
+    /*!< Indicates valid result in the channel */
+    ADMW_ALERT_DETAIL_CH_ADC_NEAR_OVERRANGE       = (1 << 1),
+    /*!< Indicates ADC is near overrange in the channel */
+    ADMW_ALERT_DETAIL_CH_SENSOR_UNDERRANGE        = (1 << 2),
+    /*!< Indicates sensor underrange in the channel */
+    ADMW_ALERT_DETAIL_CH_SENSOR_OVERRANGE         = (1 << 3),
+    /*!< Indicates sensor overrange in the channel */
+    ADMW_ALERT_DETAIL_CH_CJ_SOFT_FAULT            = (1 << 4),
+    /*!< Indicates Cold Junction soft fault in the channel */
+    ADMW_ALERT_DETAIL_CH_CJ_HARD_FAULT            = (1 << 5),
+    /*!< Indicates Cold Junction Hard Fault in the channel */
+    ADMW_ALERT_DETAIL_CH_ADC_INPUT_OVERRANGE      = (1 << 6),
+    /*!< Indicates ADC Input overrange in the channel */
+    ADMW_ALERT_DETAIL_CH_SENSOR_HARDFAULT         = (1 << 7),
+    /*!< Indicates Hard Fault in the channel */
+}   ADMW_CHANNEL_ALERT_FLAGS;
 
 /*! Status details retreived from the ADMW device. */
-typedef struct {
+typedef struct
+{
     ADMW_DEVICE_STATUS_FLAGS      deviceStatus;
     /*!< General summary status information from the device  */
     ADMW_DIAGNOSTICS_STATUS_FLAGS diagnosticsStatus;
     /*!< Diagnostic error status information from the device  */
-    ADMW_CHANNEL_ALERT_FLAGS      channelAlerts[ADMW_MAX_CHANNELS];
+    ADMW_CHANNEL_ALERT_FLAGS      channelAlerts[ADMW1001_MAX_CHANNELS];
     /*!< Per-channel alert status information from the device  */
-    uint32_t                           errorCode;
+    uint32_t                      errorCode;
     /*!< Code identifying the last error signalled by the device  */
-    uint32_t                           alertCode;
+    uint32_t                      alertCode;
     /*!< Code identifying the last alert signalled by the device  */
-    uint32_t                           debugCode;
+    uint32_t                      debugCode;
     /*!< Supplementary code related to the last error/alert  */
-    uint32_t                           channelAlertCodes[ADMW_MAX_CHANNELS];
+    uint32_t                      channelAlertCodes[ADMW1001_MAX_CHANNELS];
     /*!< Per-channel code identifying the last alert signalled for each channel */
-} ADMW_STATUS;
+
+}   ADMW_STATUS;
 
 /*! Data sample details retreived from the ADMW device. */
-typedef struct {
+typedef struct
+{
     ADMW_DEVICE_STATUS_FLAGS      status;
     /*!< Device summary status snapshot when the sample was recorded */
-    uint32_t                           channelId;
+    uint32_t                      channelId;
     /*!< The measurement channel from which this sample was obtained */
-    uint32_t                           rawValue;
+    uint32_t                      rawValue;
     /*!< The raw (unprocessed) value obtained directly from the measurement
      *   channel, if available
      */
-    float32_t                          processedValue;
+    float32_t                     processedValue;
     /*!< The processed value obtained from the measurement channel, as a final
      *   measurement value, following calibration and linearisation correction,
      *   and conversion into an appropriate unit of measurement.
      */
-} ADMW_DATA_SAMPLE;
+
+}   ADMW_DATA_SAMPLE;
 
 /*! Measurement mode options for the ADMW device.
  *  @ref admw_StartMeasurement
  */
-typedef enum {
+typedef enum
+{
     ADMW_MEASUREMENT_MODE_NORMAL = 0,
     /*!< In this mode, normal measurement cycle(s) are executed and data samples
      *   are returned with raw measurement values included. */
     ADMW_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. */
-} ADMW_MEASUREMENT_MODE;
+
+}   ADMW_MEASUREMENT_MODE;
 
 /*! Identifiers for the user configuration slots in persistent memory. */
-typedef enum {
+typedef enum
+{
     ADMW_FLASH_CONFIG_1,
-} ADMW_USER_CONFIG_SLOT;
+
+}   ADMW_USER_CONFIG_SLOT;
+
+
 
+typedef struct
+{
+    unsigned nDeviceIndex;
+    ADMW_SPI_HANDLE hSpi;
+    ADMW_GPIO_HANDLE hGpio;
+} ADMW_DEVICE_CONTEXT;
 
 /******************************************************************************
  * ADMW High-Level API function prototypes
@@ -227,7 +235,7 @@
  *         - #ADMW_INVALID_DEVICE_NUM Invalid device index specified
  *
  * @details Configure and initialise the Log interface and the SPI/GPIO
- *          communication interface to the ADMW1001 module.
+ *          communication interface to the ADISense module.
  */
 ADMW_RESULT admw_Open(
     unsigned                   const nDeviceIndex,
@@ -681,7 +689,9 @@
     ADMW_DEVICE_HANDLE hDevice,
     bool *pbCommandRunning);
 
+ADMW_RESULT admw1001_sendRun( ADMW_DEVICE_HANDLE   const hDevice);
 ADMW_RESULT deviceInformation(ADMW_DEVICE_HANDLE hDevice);
+
 #ifdef __cplusplus
 }
 #endif