
initial commit
Revision 50:d84305e5e1c0, committed 2020-02-17
- Comitter:
- Vkadaba
- Date:
- Mon Feb 17 11:23:39 2020 +0000
- Parent:
- 49:c31473bc013e
- Child:
- 51:b6d4519ef813
- Child:
- 52:d32ea3dfc8ac
- Commit message:
- Mbed Firmware Update to support Device FW v1.12.061
Changed in this revision
--- a/common/utils.c Thu Feb 06 11:04:31 2020 +0000 +++ b/common/utils.c Mon Feb 17 11:23:39 2020 +0000 @@ -134,7 +134,7 @@ { for (uint32_t i = 0; i < nNumSamples; i++) { - ADMW_LOG_INFO("Sample # %2d Channel # %2d :: Raw %0X %f :: Processed %f :: flags:%s%s", + ADMW_LOG_INFO("Sample # %2d Channel # %2d :: Raw %X %f :: Processed %f :: flags:%s%s", i+1, pSampleBuffer[i].channelId, pSampleBuffer[i].rawValue, (pSampleBuffer[i].rawValue/1024.0),
--- a/inc/admw1001/ADMW1001_REGISTERS.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/ADMW1001_REGISTERS.h Mon Feb 17 11:23:39 2020 +0000 @@ -279,7 +279,7 @@ #define REG_CORE_LUT_DATA_RESET 0x00000000 /* Reset Value for LUT_Data */ #define REG_CORE_LUT_DATA 0x00000074 /* CORE Data to Read/Write from Addressed LUT Entry */ #define REG_CORE_REVISION_RESET 0x01000000 /* Reset Value for Revision */ -#define REG_CORE_REVISION 0x0000008C /* CORE Hardware, Firmware Revision */ +#define REG_CORE_REVISION 0x0000008A /* CORE Hardware, Firmware Revision */ #define REG_CORE_CHANNEL_COUNTn_RESET 0x00000000 /* Reset Value for Channel_Count[n] */ #define REG_CORE_CHANNEL_COUNT0_RESET 0x00000000 /* Reset Value for REG_CORE_CHANNEL_COUNT0 */ #define REG_CORE_CHANNEL_COUNT1_RESET 0x00000000 /* Reset Value for REG_CORE_CHANNEL_COUNT1 */
--- a/inc/admw1001/ADMW1001_REGISTERS_typedefs.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/ADMW1001_REGISTERS_typedefs.h Mon Feb 17 11:23:39 2020 +0000 @@ -1,9 +1,7 @@ /* ================================================================================ Created by : - Created on : 2020 Jan 08, 12:45 GMT Standard Time - - Created on : 2020 Jan 08, 12:45 GMT Standard Time + Created on : 2020 Jan 15, 14:45 GMT Standard Time Project : ADMW1001_REGISTERS File : ADMW1001_REGISTERS_typedefs.h @@ -18,7 +16,6 @@ This file was auto-generated. Do not make local changes to this file. - Auto generation script information: Script: C:\Program Files (x86)\Yoda-19.05.01\generators\inc\genHeaders Last modified: 26-SEP-2017 @@ -74,38 +71,6 @@ /*@}*/ -/** @defgroup Interface_Config_B Interface Configuration B (Interface_Config_B) Register - * Interface Configuration B (Interface_Config_B) Register. - * @{ - */ - -/* ========================================================================= - *! \enum ADMW_SPI_Interface_Config_B_Single_Inst - *! \brief Select Streaming or Single Instruction Mode (Single_Inst) Enumerations - * ========================================================================= */ -typedef enum -{ - SPI_INTERFACE_CONFIG_B_STREAMING_MODE = 0, /**< Streaming mode is enabled */ - SPI_INTERFACE_CONFIG_B_SINGLE_INSTRUCTION_MODE = 1 /**< Single Instruction mode is enabled */ -} ADMW_SPI_Interface_Config_B_Single_Inst; - - -/* ========================================================================== - *! \struct ADMW_SPI_Interface_Config_B_Struct - *! \brief Interface Configuration B Register bit field structure - * ========================================================================== */ -typedef struct _ADMW_SPI_Interface_Config_B_t { - union { - struct { - uint8_t reserved0 : 7; - uint8_t Single_Inst : 1; /**< Select Streaming or Single Instruction Mode */ - }; - uint8_t VALUE8; - }; -} ADMW_SPI_Interface_Config_B_t; - -/*@}*/ - /** @defgroup Chip_Type Chip Type (Chip_Type) Register * Chip Type (Chip_Type) Register. * @{ @@ -139,8 +104,7 @@ typedef struct _ADMW_SPI_Product_ID_L_t { union { struct { - uint8_t Product_ID_Trim_Bits : 4; /**< These Bits Vary on Die Configured for Multiple Generics */ - uint8_t Product_ID_Fixed_Bits : 4; /**< Product_ID_Fixed_Bits[3:0] These Bits are Fixed on Die Configured for Multiple Generics */ + uint8_t Product_ID : 8; /**< Product_ID[7:0] The Device Chip Type and Family */ }; uint8_t VALUE8; }; @@ -160,7 +124,7 @@ typedef struct _ADMW_SPI_Product_ID_H_t { union { struct { - uint8_t Product_ID_Fixed_Bits : 8; /**< Product_ID_Fixed_Bits[11:4] These Bits are Fixed on Die Configured for Multiple Generics */ + uint8_t Product_ID : 8; /**< Product_ID[15:8] The Device Chip Type and Family */ }; uint8_t VALUE8; }; @@ -168,27 +132,6 @@ /*@}*/ -/** @defgroup Chip_Grade Chip Grade (Chip_Grade) Register - * Chip Grade (Chip_Grade) Register. - * @{ - */ - -/* ========================================================================== - *! \struct ADMW_SPI_Chip_Grade_Struct - *! \brief Chip Grade Register bit field structure - * ========================================================================== */ -typedef struct _ADMW_SPI_Chip_Grade_t { - union { - struct { - uint8_t Device_Revision : 4; /**< Device Hardware Revision */ - uint8_t Grade : 4; /**< Device Performance Grade */ - }; - uint8_t VALUE8; - }; -} ADMW_SPI_Chip_Grade_t; - -/*@}*/ - /** @defgroup Scratch_Pad Scratch Pad (Scratch_Pad) Register * Scratch Pad (Scratch_Pad) Register. * @{ @@ -311,85 +254,6 @@ /*@}*/ -/** @defgroup Transfer_Config Transfer Config (Transfer_Config) Register - * Transfer Config (Transfer_Config) Register. - * @{ - */ - -/* ========================================================================= - *! \enum ADMW_SPI_Transfer_Config_Stream_Mode - *! \brief When Streaming, Control Master to Slave Transfer (Stream_Mode) Enumerations - * ========================================================================= */ -typedef enum -{ - SPI_TRANSFER_CONFIG_UPDATE_ON_WRITE = 0, /**< Transfers after each byte/mulit-byte register */ - SPI_TRANSFER_CONFIG_UPDATE_ON_ADDRESS_LOOP = 1 /**< Transfers when address loops */ -} ADMW_SPI_Transfer_Config_Stream_Mode; - - -/* ========================================================================== - *! \struct ADMW_SPI_Transfer_Config_Struct - *! \brief Transfer Config Register bit field structure - * ========================================================================== */ -typedef struct _ADMW_SPI_Transfer_Config_t { - union { - struct { - uint8_t reserved0 : 1; - uint8_t Stream_Mode : 1; /**< When Streaming, Control Master to Slave Transfer */ - uint8_t reserved2 : 6; - }; - uint8_t VALUE8; - }; -} ADMW_SPI_Transfer_Config_t; - -/*@}*/ - -/** @defgroup Interface_Config_C Interface Configuration C (Interface_Config_C) Register - * Interface Configuration C (Interface_Config_C) Register. - * @{ - */ - -/* ========================================================================= - *! \enum ADMW_SPI_Interface_Config_C_Strict_Register_Access - *! \brief Multibyte Registers Must Be Read or Written in Full (Strict_Register_Access) Enumerations - * ========================================================================= */ -typedef enum -{ - SPI_INTERFACE_CONFIG_C_NORMAL_ACCESS = 0, /**< Normal mode, no access restrictions */ - SPI_INTERFACE_CONFIG_C_STRICT_ACCESS = 1 /**< Strict mode, multi-byte registers require all bytes read/written */ -} ADMW_SPI_Interface_Config_C_Strict_Register_Access; - - -/* ========================================================================= - *! \enum ADMW_SPI_Interface_Config_C_CRC_Enable - *! \brief CRC Enable (CRC_Enable) Enumerations - * ========================================================================= */ -typedef enum -{ - SPI_INTERFACE_CONFIG_C_DISABLED = 0, /**< CRC Disabled */ - SPI_INTERFACE_CONFIG_C_ENABLED = 1 /**< CRC Enabled */ -} ADMW_SPI_Interface_Config_C_CRC_Enable; - - -/* ========================================================================== - *! \struct ADMW_SPI_Interface_Config_C_Struct - *! \brief Interface Configuration C Register bit field structure - * ========================================================================== */ -typedef struct _ADMW_SPI_Interface_Config_C_t { - union { - struct { - uint8_t CRC_EnableB : 2; /**< Inverted CRC Enable */ - uint8_t reserved2 : 2; - uint8_t Send_Status : 1; /**< Sends Status in 4-Wire Mode When Enabled */ - uint8_t Strict_Register_Access : 1; /**< Multibyte Registers Must Be Read or Written in Full */ - uint8_t CRC_Enable : 2; /**< CRC Enable */ - }; - uint8_t VALUE8; - }; -} ADMW_SPI_Interface_Config_C_t; - -/*@}*/ - /** @defgroup Interface_Status_A Interface Status A (Interface_Status_A) Register * Interface Status A (Interface_Status_A) Register. * @{ @@ -433,7 +297,6 @@ CORE_COMMAND_LATCH_CONFIG = 7, /**< Latch configuration. */ CORE_COMMAND_LOAD_LUT = 8, /**< Load LUT from flash */ CORE_COMMAND_SAVE_LUT = 9, /**< Save LUT to flash */ - CORE_COMMAND_POWER_DOWN = 20, /**< Enter Low Power State */ CORE_COMMAND_LOAD_CONFIG_1 = 24, /**< Load registers with configuration from flash */ CORE_COMMAND_SAVE_CONFIG_1 = 25 /**< Store current registers to flash configuration */ } ADMW_CORE_Command_Special_Command; @@ -478,7 +341,8 @@ typedef enum { CORE_MODE_DRDY_PER_CONVERSION = 0, /**< Data ready per conversion */ - CORE_MODE_DRDY_PER_CYCLE = 1 /**< Data ready per cycle */ + CORE_MODE_DRDY_PER_CYCLE = 1, /**< Data ready per cycle */ + CORE_MODE_DRDY_PER_FIFO_FILL = 2 } ADMW_CORE_Mode_Drdy_Mode; @@ -542,9 +406,8 @@ * ========================================================================= */ typedef enum { - - CORE_CYCLE_CONTROL_CYCLE_SW = 0, /**< Ground Switch Opens outside of measurement cycle to conserve power */ - CORE_CYCLE_CONTROL_CLOSE_SW = 1, /**< Ground Switch Closed */ + CORE_CYCLE_CONTROL_OPEN_SW = 0, /**< Ground Switch Opens outside of measurement cycle to conserve power */ + CORE_CYCLE_CONTROL_CLOSE_SW = 1 /**< Ground Switch Closed */ } ADMW_CORE_Cycle_Control_GND_SW_CTRL; @@ -698,9 +561,10 @@ uint16_t Sensor_OverRange : 1; /**< Indicates If the Sensor is Overrange */ uint16_t CJ_Soft_Fault : 1; /**< Cold Junction Soft Fault */ uint16_t CJ_Hard_Fault : 1; /**< Cold Junction Hard Fault */ - uint16_t ADC_Input_OverRange : 1; /**< Indicates the ADC Input is Overrange */ - uint16_t Sensor_HardFault : 1; /**< Indicates Sensor Hard Fault */ - uint16_t reserved8 : 8; + uint16_t ADC_Input_OverRange : 1; /**< Indicates the ADC Input is Overrange */ + uint16_t Sensor_HardFault : 1; /**< Indicates Sensor Hard Fault */ + uint16_t Threshold_Exceeded : 1; + uint16_t reserved7 : 7; }; uint16_t VALUE16; }; @@ -913,7 +777,6 @@ typedef struct _ADMW_CORE_LUT_Offset_t { union { struct { - uint16_t LUT_Offset : 11; /**< Offset into the Lookup Table */ uint16_t reserved11 : 5; }; @@ -1076,9 +939,9 @@ * ========================================================================= */ typedef enum { - CORE_SENSOR_DETAILS_LUT_DEFAULT = 0, /**< Default lookup table for selected sensor type */ - CORE_SENSOR_DETAILS_LUT_CUSTOM = 1, /**< User defined custom lookup table. */ - CORE_SENSOR_DETAILS_LUT_RESERVED = 2 /**< Reserved */ + CORE_SENSOR_DETAILS_LUT_DEFAULT = 0, /**< Default lookup table for selected sensor type */ + CORE_SENSOR_DETAILS_LUT_CUSTOM = 1, /**< User defined custom lookup table. */ + CORE_SENSOR_DETAILS_LUT_RESERVED = 2 /**< Reserved */ } ADMW_CORE_Sensor_Details_LUT_Select; @@ -1213,20 +1076,6 @@ * @{ */ -/* ========================================================================= - *! \enum ADMW_CORE_Settling_Time_Settling_Time_Units - *! \brief Units for Settling Time (Settling_Time_Units) Enumerations - * ========================================================================= */ -typedef enum -{ - - CORE_SETTLING_TIME_MILLISECONDS = 0, /**< Micro-seconds */ - CORE_SETTLING_TIME_SECONDS = 1, /**< Milli-seconds */ - CORE_SETTLING_TIME_RESERVED = 2, /**< Seconds */ - CORE_SETTLING_TIME_UNDEFINED = 3 /**< Undefined */ -} ADMW_CORE_Settling_Time_Settling_Time_Units; - - /* ========================================================================== *! \struct ADMW_CORE_Settling_Time_Struct *! \brief Settling Time Register bit field structure @@ -1234,8 +1083,8 @@ typedef struct _ADMW_CORE_Settling_Time_t { union { struct { - uint16_t Settling_Time : 14; /**< Settling Time to Allow When Switching to Channel */ - uint16_t Settling_Time_Units : 2; /**< Units for Settling Time */ + uint16_t Settling_Time : 8; /**< Additional Settling Time in Milliseconds. Max 255ms */ + uint16_t reserved8 : 8; }; uint16_t VALUE16; }; @@ -1522,17 +1371,6 @@ */ /* ========================================================================= - *! \enum ADMW_CORE_Digital_Sensor_Comms_Digital_Sensor_Comms_En - *! \brief Enable Digital Sensor Communications Register Parameters (Digital_Sensor_Comms_En) Enumerations - * ========================================================================= */ -typedef enum -{ - CORE_DIGITAL_SENSOR_COMMS_DIGITAL_COMMS_DEFAULT = 0, /**< Default parameters used for digital sensor communications */ - CORE_DIGITAL_SENSOR_COMMS_DIGITAL_COMMS_USER = 1 /**< User supplied parameters used for digital sensor communications */ -} ADMW_CORE_Digital_Sensor_Comms_Digital_Sensor_Comms_En; - - -/* ========================================================================= *! \enum ADMW_CORE_Digital_Sensor_Comms_SPI_Clock *! \brief Controls Clock Frequency for SPI Sensors (SPI_Clock) Enumerations * ========================================================================= */ @@ -1590,12 +1428,12 @@ typedef struct _ADMW_CORE_Digital_Sensor_Comms_t { union { struct { - uint16_t Digital_Sensor_Comms_En : 1; /**< Enable Digital Sensor Communications Register Parameters */ - uint16_t SPI_Clock : 4; /**< Controls Clock Frequency for SPI Sensors */ - uint16_t I2C_Clock : 2; /**< Controls SCLK Frequency for I2C Sensors */ - uint16_t reserved7 : 3; - uint16_t SPI_Mode : 2; /**< Configuration for Sensor SPI Protocol */ - uint16_t reserved12 : 4; + uint16_t reserved0 : 1; + uint16_t SPI_Clock : 4; /**< Controls Clock Frequency for SPI Sensors */ + uint16_t I2C_Clock : 2; /**< Controls SCLK Frequency for I2C Sensors */ + uint16_t reserved7 : 3; + uint16_t SPI_Mode : 2; /**< Configuration for Sensor SPI Protocol */ + uint16_t reserved12 : 4; }; uint16_t VALUE16; }; @@ -1606,7 +1444,6 @@ #if defined (__CC_ARM) #pragma pop +#endif #endif - -#endif
--- a/inc/admw1001/admw1001_config.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/admw1001_config.h Mon Feb 17 11:23:39 2020 +0000 @@ -116,10 +116,10 @@ /*! ADMW1001 power mode options */ typedef enum { - ADMW1001_POWER_MODE_HIBERNATION = 0, + ADMW1001_POWER_MODE_ACTIVE = 0, + /*!< Part is fully powered up and either cycling through a sequence or awaiting a configuration */ + ADMW1001_POWER_MODE_HIBERNATION, /*!< module has entede hibernation mode. All analog circuitry is disabled. All peripherals disabled apart from the Wake-up pin functionality. */ - ADMW1001_POWER_MODE_ACTIVE, - /*!< Part is fully powered up and either cycling through a sequence or awaiting a configuration */ } ADMW1001_POWER_MODE; @@ -468,8 +468,9 @@ /*!< Excitation current state */ uint8_t groundSwitch; /*!< Option to open or close sensor ground switch */ - uint8_t reserved0; - /*!< Reserved for future use and ensure word alignment. + uint8_t fifoNumCycles; + /*!< Specifies the number of cycles to fill a FIFO buffer + * Applicable only when operatingMode is ADMW1001_OPERATING_MODE_CONTINUOUS */ uint32_t cycleInterval; /*!< Cycle interval - specifies the time interval between the start of each
--- a/inc/admw1001/admw1001_host_comms.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/admw1001_host_comms.h Mon Feb 17 11:23:39 2020 +0000 @@ -73,28 +73,25 @@ * The following minimum delay, in microseconds, must be inserted after each SPI * transfer to allow time for it to be processed by the device */ -#define ADMW1001_HOST_COMMS_XFER_DELAY (40) +#define ADMW1001_HOST_COMMS_XFER_DELAY (60) /* * The following defines the maximum number of retries before aborting a transfer. */ #define ADMW1001_HOST_COMMS_MAX_RETRIES (10) +/*! ADMW1001 Sensor Result bit field structure */ +typedef struct _ADMW1001_Sensor_Result_t +{ + float32_t Sensor_Result; /**< Linearized and compensated sensor result */ + uint32_t Channel_ID : 4; /**< Indicates which channel this result corresponds to */ + uint32_t Ch_Error : 1; /**< Indicates Error on channel */ + uint32_t Ch_Alert : 1; /**< Indicates Alert on channel */ + uint32_t Ch_Raw : 1; /**< Indicates if Raw sensor data field is valid */ + uint32_t Ch_Valid : 1; /**< Indicates if this Result structure is valid */ + uint32_t Status : 24; /**< Reserved for future use */ + float32_t Raw_Sample; /**< Raw sensor data value */ -/*! ADMW1001 Sensor Result bit field structure */ -typedef struct ADMW1001_Sensor_Result_t { - union { - struct { - float32_t Sensor_Result; /**< Linearized and compensated sensor result */ - uint32_t Channel_ID : 4; /**< Indicates which channel this result corresponds to */ - uint32_t Ch_Error : 1; /**< Indicates Error on channel */ - uint32_t Ch_Alert : 1; /**< Indicates Alert on channel */ - uint32_t Ch_Raw : 1; /**< Indicates if Raw sensor data field is valid */ - uint32_t Ch_Valid : 1; /**< Indicates if this Result structure is valid */ - uint32_t Raw_Sample : 24; /**< Raw sensor data value */ - }; - uint64_t VALUE64; - }; -} ADMW1001_Sensor_Result_t; +} ADMW1001_Sensor_Result_t; #endif /* __ADMW1001_HOST_COMMS_H__ */
--- a/inc/admw1001/admw1001_lut_data.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/admw1001_lut_data.h Mon Feb 17 11:23:39 2020 +0000 @@ -57,14 +57,15 @@ #endif /*! LUT data validation signature */ -#define ADMW_LUT_SIGNATURE 0x4C555473 +#define ADMW_LUT_SIGNATURE 0x4C555473 /*! LUT data CRC-16-CCITT seed value */ -#define ADMW_LUT_CRC_SEED 0x4153 +#define ADMW_LUT_CRC_SEED 0x4153 /*! LUT maximum allowed size */ #define ADMW_LUT_MAX_SIZE 10240U +#define MAX_LUT_NUM_ENTRIES 16 /*! Linearisation look-up table / co-efficient list geometry */ typedef enum { ADMW1001_LUT_GEOMETRY_RESERVED = 0x00, @@ -73,12 +74,6 @@ /**< 1D/2D equation coefficient list */ ADMW1001_LUT_GEOMETRY_NES_1D = 0x02, /**< 1-dimensional not-equally-spaced look-up table */ - ADMW1001_LUT_GEOMETRY_NES_2D = 0x03, - /**< 2-dimensional not-equally-spaced look-up table */ - ADMW1001_LUT_GEOMETRY_ES_1D = 0x04, - /**< 1-dimensional equally-spaced look-up table */ - ADMW1001_LUT_GEOMETRY_ES_2D = 0x05, - /**< 2-dimensional equally-spaced look-up table */ } ADMW1001_LUT_GEOMETRY; /*! Linearisation equation type */ @@ -220,22 +215,22 @@ /*! Macro to calculate the number of elements in * a @ref ADMW1001_LUT_1D_NES table */ #define ADMW1001_LUT_1D_NES_NELEMENTS(_t) \ - ((_t).nElements * 2) + ((_t).nElements * 2) /*! Macro to calculate the number of elements in * a @ref ADMW1001_LUT_2D_ES table */ #define ADMW1001_LUT_2D_ES_NELEMENTS(_t) \ - ((_t).nElementsX * (_t).nElementsX) + ((_t).nElementsX * (_t).nElementsX) /*! Macro to calculate the number of elements in * a @ref ADMW1001_LUT_2D_NES table */ #define ADMW1001_LUT_2D_NES_NELEMENTS(_t) \ - ((_t).nElementsX + (_t).nElementsY + ((_t).nElementsX * (_t).nElementsY)) + ((_t).nElementsX + (_t).nElementsY + ((_t).nElementsX * (_t).nElementsY)) /*! Macro to calculate the number of elements in * a @ref ADMW1001_LUT_2D_POLYN_COEFF_LIST table */ #define ADMW1001_LUT_2D_POLYN_COEFF_LIST_NELEMENTS(_t) \ - (((_t).maxDegree + 1) * ((_t).maxDegree + 2) / 2) + (((_t).maxDegree + 1) * ((_t).maxDegree + 2) / 2) /*! Macro to calculate the storage size in bytes of * a @ref ADMW1001_LUT_COEFF_LIST table */ @@ -270,14 +265,15 @@ /*! Look-Up Table descriptor */ typedef union __attribute__((packed, aligned(4))) { struct { - uint16_t geometry : 6; /**< ADMW1001_LUT_GEOMETRY */ - uint16_t equation : 6; /**< ADMW1001_LUT_EQUATION */ - uint16_t dir : 4; /**< ADMW1001_LUT_TC_DIRECTION */ - uint16_t sensor : 12; /**< ADMW1001_ADC_SENSOR_TYPE */ - uint16_t dataType : 4; /**< ADMW1001_LUT_DATA_TYPE */ - uint16_t length; /**< Length (bytes) of table data section - (excl. this header) */ - uint16_t crc16; /**< CRC-16-CCITT of the data */ + uint16_t geometry : 4; /**< ADMW1001_LUT_GEOMETRY */ + uint8_t channel : 2; /**< ADMW1001_ADC_CHANNEL */ + uint16_t equation : 6; /**< ADMW1001_LUT_EQUATION */ + uint16_t dir : 4; /**< ADMW1001_LUT_TC_DIRECTION */ + uint16_t sensor : 12; /**< ADMW1001_ADC_SENSOR_TYPE */ + uint16_t dataType : 4; /**< ADMW1001_LUT_DATA_TYPE */ + uint16_t length; /**< Length (bytes) of table data section + (excl. this header) */ + uint16_t crc16; /**< CRC-16-CCITT of the data */ }; uint64_t value64; } ADMW1001_LUT_DESCRIPTOR; @@ -333,7 +329,7 @@ typedef struct __attribute__((packed, aligned(4))) { ADMW1001_LUT_HEADER header; /*!< LUT data top-level header structure */ - ADMW1001_LUT_TABLE tables[]; + ADMW1001_LUT_TABLE tables[1]; /*!< Variable-length array of one-or-more look-up table structures */ } ADMW1001_LUT;
--- a/inc/admw1001/admw1001_sensor_types.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw1001/admw1001_sensor_types.h Mon Feb 17 11:23:39 2020 +0000 @@ -102,11 +102,6 @@ */ typedef enum { - ADMW1001_ADC_SENSOR_THERMOCOUPLE_T = 0, - /*!< Standard T-type Thermocouple temperature sensor - * - * @note For use with Analog Sensor channels only - */ ADMW1001_ADC_SENSOR_THERMOCOUPLE_J = 1, /*!< Standard J-type Thermocouple temperature sensor * @@ -117,150 +112,313 @@ * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMOCOUPLE_1 = 8, - /*!< Standard thermocouple temperature sensor + ADMW1001_ADC_SENSOR_THERMOCOUPLE_E = 3, + /*!< Standard E-type Thermocouple temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_THERMOCOUPLE_N = 4, + /*!< Standard N-type Thermocouple temperature sensor with default + * linearisation and default configuration options * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMOCOUPLE_2 = 9, - /*!< Standard thermocouple temperature sensor + ADMW1001_ADC_SENSOR_THERMOCOUPLE_R = 5, + /*!< Standard R-type Thermocouple temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_THERMOCOUPLE_S = 6, + /*!< Standard S-type Thermocouple temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_THERMOCOUPLE_T = 7, + /*!< Standard T-type Thermocouple temperature sensor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMOCOUPLE_3 = 10, - /*!< Standard thermocouple temperature sensor + ADMW1001_ADC_SENSOR_THERMOCOUPLE_B = 8, + /*!< Standard B-type Thermocouple temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_THERMOCOUPLE_CUSTOM = 9, + /*!< CUSTOM -type Thermocouple temperature sensor with custom + * linearisation and default configuration options * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMOCOUPLE_4 = 11, - /*!< Standard thermocouple temperature sensor + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT100_DEF_L1 = 32, + /*!< Standard 2-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000_DEF_L1 = 33, + /*!< Standard 2-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options * - * @note For use with Analog Sensor channels only + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_PT100 = 32, - /*!< Standard 2-wire PT100 RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT10 = 34, + /*!< Standard 2-wire PT10 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT50 = 35, + /*!< Standard 2-wire PT50 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000 = 33, - /*!< Standard 2-wire PT1000 RTD temperature + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT100 = 36, + /*!< Standard 2-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT200 = 37, + /*!< Standard 2-wire PT200 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_1 = 40, - /*!< 2-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT500 = 38, + /*!< Standard 2-wire PT500 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000 = 39, + /*!< Standard 2-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000_0P00375 = 40, + /*!< Standard 2-wire PT1000 RTD temperature sensor with alpha 0.00375 + * linearisation * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_2 = 41, - /*!< 2-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_2WIRE_NI120 = 41, + /*!< Standard 2-wire NI120 RTD temperature sensor + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_2WIRE_CUSTOM = 42, + /*!< 2-wire Custom RTD temperature sensor with user-defined linearisation and + * default configuration options * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_3 = 42, - /*!< 2-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT100_DEF_L1 = 64, + /*!< Standard 3-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000_DEF_L1 = 65, + /*!< Standard 3-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Analog Sensor channels only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT10 = 66, + /*!< Standard 3-wire PT10 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_2WIRE_4 = 43, - /*!< 2-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT50 = 67, + /*!< Standard 3-wire PT50 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT100 = 68, + /*!< Standard 3-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Cold-Juction Compensation and Analog Sensor channels * only */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_PT100 = 64, - /*!< Standard 3-wire PT100 RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT200 = 69, + /*!< Standard 3-wire PT200 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT500 = 70, + /*!< Standard 3-wire PT500 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000 = 71, + /*!< Standard 3-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options * - * @note For use with Analog Sensor channels only + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000_0P00375 = 72, + /*!< Standard 3-wire PT1000 RTD temperature sensor with alpha 0.00375 + * linearisation + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000 = 65, - /*!< Standard 3-wire PT1000 RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_3WIRE_NI120 = 73, + /*!< Standard 3-wire NI120 RTD temperature sensor + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_3WIRE_CUSTOM = 74, + /*!< 3-wire Custom RTD temperature sensor with user-defined linearisation and + * default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT100_DEF_L1 = 96, + /*!< Standard 4-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_1 = 72, - /*!< 3-wire RTD temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_2 = 73, - /*!< 3-wire RTD temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_3 = 74, - /*!< 3-wire RTD temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_RTD_3WIRE_4 = 75, - /*!< 3-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000_DEF_L1 = 97, + /*!< Standard 4-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_PT100 = 96, - /*!< Standard 4-wire PT100 RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT10 = 98, + /*!< Standard 4-wire PT10 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT50 = 99, + /*!< Standard 4-wire PT50 RTD temperature sensor with default + * linearisation and default configuration options * - * @note For use with Analog Sensor channels only + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT100 = 100, + /*!< Standard 4-wire PT100 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT200 = 101, + /*!< Standard 4-wire PT200 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000 = 97, - /*!< Standard 4-wire PT1000 RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT500 = 102, + /*!< Standard 4-wire PT500 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000 = 103, + /*!< Standard 4-wire PT1000 RTD temperature sensor with default + * linearisation and default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000_0P00375 = 104, + /*!< Standard 4-wire PT1000 RTD temperature sensor with alpha 0.00375 + * linearisation * - * @note For use with Analog Sensor channels only + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_RTD_4WIRE_NI120 = 105, + /*!< Standard 4-wire NI120 RTD temperature sensor + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_1 = 104, - /*!< 4-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_RTD_4WIRE_CUSTOM = 106, + /*!< 4-wire Custom RTD temperature sensor with user-defined linearisation and + * default configuration options + * + * @note For use with Cold-Juction Compensation and Analog Sensor channels + * only + */ + ADMW1001_ADC_SENSOR_THERMISTOR_44004_44033_2P252K_AT_25C = 128, + /*!< Standard 2.252kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_2 = 105, - /*!< 4-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_THERMISTOR_44005_44030_3K_AT_25C = 129, + /*!< Standard 3kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_3 = 106, - /*!< 4-wire RTD temperature sensor + ADMW1001_ADC_SENSOR_THERMISTOR_44007_44034_5K_AT_25C = 130, + /*!< Standard 5kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_RTD_4WIRE_4 = 107, - /*!< 4-wire RTD temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_THERMISTOR_A_10K = 128, + ADMW1001_ADC_SENSOR_THERMISTOR_44006_44031_10K_AT_25C = 131, /*!< Standard 10kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMISTOR_B_10K = 129, - /*!< Standard 10kOhm NTC Thermistor + ADMW1001_ADC_SENSOR_THERMISTOR_44008_44032_30K_AT_25C = 132, + /*!< Standard 30kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMISTOR_1 = 136, - /*!< Thermistor sensor + ADMW1001_ADC_SENSOR_THERMISTOR_YSI_400 = 133, + /*!< Standard YSI400 NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMISTOR_2 = 137, - /*!< Thermistor sensor with user-defined linearisation and - * default configuration options + ADMW1001_ADC_SENSOR_THERMISTOR_SPECTRUM_1003K_1K = 134, + /*!< Standard 1kOhm NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMISTOR_3 = 138, - /*!< Thermistor sensor + ADMW1001_ADC_SENSOR_THERMISTOR_CUSTOM_STEINHART_HART = 135, + /*!< CUSTOM Equation NTC Thermistor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_THERMISTOR_4 = 139, - /*!< Thermistor sensor + ADMW1001_ADC_SENSOR_THERMISTOR_CUSTOM_TABLE = 136, + /*!< Custom Table NTC Thermistor * * @note For use with Analog Sensor channels only */ @@ -312,46 +470,11 @@ * @note For use with Analog Sensor channels only * @note Bridge Excitation Voltage must be selected as reference */ - ADMW1001_ADC_SENSOR_DIODE_2C_TYPEA = 224, - /*!< Standard Diode two current temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_DIODE_3C_TYPEA = 225, - /*!< Standard Diode three current temperature sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_DIODE_2C_1 = 232, - /*!< Standard Diode two current sensor - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_DIODE_3C_1 = 233, - /*!< Standard Diode three current sensor + ADMW1001_ADC_SENSOR_DIODE = 224, + /*!< Standard Diode current temperature sensor * * @note For use with Analog Sensor channels only */ - ADMW1001_ADC_SENSOR_MICROPHONE_A = 256, - /*!< Generic microphone sensor without external amplifier - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_MICROPHONE_B = 257, - /*!< Generic microphone sensor with external amplifier and bias - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_MICROPHONE_1 = 264, - /*!< Generic microphone sensor without external amplifier - * - * @note For use with Analog Sensor channels only - */ - ADMW1001_ADC_SENSOR_MICROPHONE_2 = 265, - /*!< Generic microphone sensor with external amplifier and bias - * - * @note For use with Analog Sensor channels only - */ ADMW1001_ADC_SENSOR_VOLTAGE = 512, /*!< Generic voltage sensor * @@ -485,6 +608,12 @@ * * @note For use with I2C Digital Sensor channels only */ + ADMW1001_I2C_SENSOR_TEMPERATURE_ADT742X = 2218, + /*!< ADT742X sensor + * Note: the ADT742X Temperature sensor. + * + * @note For use with I2C Digital Sensor channels only + */ ADMW1001_I2C_SENSOR_CO2_A = 2224, /*!< Sensirion SCD30 C02 sensor * Note: the SCD30 is a combined CO2, Humidity and Temperature sensor. @@ -492,6 +621,8 @@ * * @note For use with I2C Digital Sensor channels only */ + + } ADMW1001_I2C_SENSOR_TYPE;
--- a/inc/admw_api.h Thu Feb 06 11:04:31 2020 +0000 +++ b/inc/admw_api.h Mon Feb 17 11:23:39 2020 +0000 @@ -172,6 +172,8 @@ /*!< Device summary status snapshot when the sample was recorded */ uint32_t channelId; /*!< The measurement channel from which this sample was obtained */ + uint8_t measurementStatus; + /*!< The measurement status from the DMZ layer */ uint32_t rawValue; /*!< The raw (unprocessed) value obtained directly from the measurement * channel, if available @@ -205,7 +207,16 @@ } ADMW_USER_CONFIG_SLOT; +/*! Identifiers for the user configuration slots in persistent memory. */ +typedef enum +{ + ADMW_FLASH_LUT_CHANNEL_0=0, + ADMW_FLASH_LUT_CHANNEL_1, + ADMW_FLASH_LUT_CHANNEL_2, + ADMW_FLASH_LUT_CHANNEL_3, + +} ADMW_USER_LUT_CONFIG_SLOT; typedef struct { @@ -690,7 +701,7 @@ bool *pbCommandRunning); ADMW_RESULT admw1001_sendRun( ADMW_DEVICE_HANDLE const hDevice); -ADMW_RESULT deviceInformation(ADMW_DEVICE_HANDLE hDevice); +ADMW_RESULT admw_deviceInformation(ADMW_DEVICE_HANDLE hDevice); #ifdef __cplusplus }
--- a/main.cpp Thu Feb 06 11:04:31 2020 +0000 +++ b/main.cpp Mon Feb 17 11:23:39 2020 +0000 @@ -67,6 +67,7 @@ int main() { + ADMW_RESULT res; ADMW_STATUS status; ADMW_DEVICE_HANDLE hDevice; @@ -122,7 +123,7 @@ * Check device status after updating the configuration */ res = admw_GetStatus(hDevice, &status); - deviceInformation(hDevice); + admw_deviceInformation(hDevice); if (res != ADMW_SUCCESS) { ADMW_LOG_ERROR("Failed to retrieve device status"); return res;
--- a/src/admw_1001.c Thu Feb 06 11:04:31 2020 +0000 +++ b/src/admw_1001.c Mon Feb 17 11:23:39 2020 +0000 @@ -388,7 +388,7 @@ return ADMW_SUCCESS; } -ADMW_RESULT deviceInformation(ADMW_DEVICE_HANDLE hDevice) +ADMW_RESULT admw_deviceInformation(ADMW_DEVICE_HANDLE hDevice) { uint16_t nAddress = REG_CORE_REVISION; char nData[ADMW_VERSION_REG_VAL_SIZE]; //4 Bytes of version register data @@ -433,8 +433,8 @@ if (bWaitForCompletion) { do { - /* Allow a minimum 50usec delay for status update before checking */ - admw_TimeDelayUsec(50); + /* Allow a minimum 100usec delay for status update before checking */ + admw_TimeDelayUsec(100); eRet = admw_GetCommandRunningState(hDevice, &bCommandRunning); if (eRet) @@ -645,7 +645,7 @@ admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); } while ((commandResponse[0] != ADMW1001_HOST_COMMS_CMD_RESP_0) || (commandResponse[1] != ADMW1001_HOST_COMMS_CMD_RESP_1)); - + for (unsigned i = 0; i < nRequested; i++) { bool bHoldCs = true; /* Keep the CS signal asserted for all but the last sample */ @@ -690,7 +690,7 @@ nValidSamples++; - admw_TimeDelayUsec(30); + admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); } *pnReturned = nValidSamples; @@ -902,18 +902,15 @@ ADMW_CORE_Mode_t modeReg; READ_REG_U8(hDevice, modeReg.VALUE8, CORE_MODE); - if(eMeasurementMode==ADMW_MEASUREMENT_MODE_NORMAL) { + if (eMeasurementMode == (modeReg.Conversion_Mode == CORE_MODE_SINGLECYCLE)) + *peOperatingMode = ADMW1001_OPERATING_MODE_SINGLECYCLE; + else + *peOperatingMode = ADMW1001_OPERATING_MODE_CONTINUOUS; - if (modeReg.Conversion_Mode == CORE_MODE_SINGLECYCLE) - *peOperatingMode = ADMW1001_OPERATING_MODE_SINGLECYCLE; - else - *peOperatingMode = ADMW1001_OPERATING_MODE_CONTINUOUS; - } - if (eMeasurementMode == ADMW_MEASUREMENT_MODE_OMIT_RAW) { - *pnBytesPerSample = 5; + *pnBytesPerSample = 8; } else { - *pnBytesPerSample = 8; + *pnBytesPerSample = 12; } for (ADMW1001_CH_ID chId = ADMW1001_CH_ID_ANLG_1_UNIVERSAL; @@ -937,7 +934,7 @@ * active when those sensors are selected and we use the count * from the corresponding "physical" channel */ -#if 0 /* SPI sensors arent supported at present to be added back once there is +#if 0 /* SPI sensors arent supported at present to be added back once there is * support for these sensors */ ADMW_CORE_Sensor_Type_t sensorTypeReg; @@ -970,14 +967,30 @@ if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_CONVERSION) { *pnSamplesPerDataready = 1; + } else if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_CYCLE) { + *pnSamplesPerDataready = nSamplesPerCycle; + } else if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_FIFO_FILL) { + ADMW_CORE_Fifo_Num_Cycles_t fifoNumCyclesReg; + + READ_REG_U8(hDevice, fifoNumCyclesReg.VALUE8, CORE_FIFO_NUM_CYCLES); + + *pnSamplesPerDataready = nSamplesPerCycle * fifoNumCyclesReg.Fifo_Num_Cycles; } else { - *pnSamplesPerDataready = nSamplesPerCycle; + ADMW_LOG_ERROR("Invalid DRDY mode %d specified", + modeReg.Drdy_Mode); + return ADMW_INVALID_PARAM; } if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_CONVERSION) { *peDataReadyMode = ADMW1001_DATAREADY_PER_CONVERSION; + } else if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_CYCLE) { + *peDataReadyMode = ADMW1001_DATAREADY_PER_CYCLE; + } else if (modeReg.Drdy_Mode == CORE_MODE_DRDY_PER_FIFO_FILL) { + *peDataReadyMode = ADMW1001_DATAREADY_PER_FIFO_FILL; } else { - *peDataReadyMode = ADMW1001_DATAREADY_PER_CYCLE; + ADMW_LOG_ERROR("Invalid DRDY mode %d specified", + modeReg.Drdy_Mode); + return ADMW_INVALID_PARAM; } return ADMW_SUCCESS; @@ -1002,7 +1015,7 @@ ADMW_DEVICE_HANDLE hDevice, ADMW1001_POWER_MODE powerMode) { - ADMW_CORE_Power_Config_t powerConfigReg; + ADMW_CORE_Power_Config_t powerConfigReg = { 0 }; if (powerMode == ADMW1001_POWER_MODE_HIBERNATION) { powerConfigReg.Power_Mode_MCU = CORE_POWER_CONFIG_HIBERNATION; @@ -1069,6 +1082,8 @@ modeReg.Drdy_Mode = CORE_MODE_DRDY_PER_CONVERSION; } else if (eDataReadyMode == ADMW1001_DATAREADY_PER_CYCLE) { modeReg.Drdy_Mode = CORE_MODE_DRDY_PER_CYCLE; + } else if (eDataReadyMode == ADMW1001_DATAREADY_PER_FIFO_FILL) { + modeReg.Drdy_Mode = CORE_MODE_DRDY_PER_FIFO_FILL; } else { ADMW_LOG_ERROR("Invalid data-ready mode %d specified", eDataReadyMode); return ADMW_INVALID_PARAM; @@ -1081,7 +1096,7 @@ ADMW_RESULT admw_SetCycleControl(ADMW_DEVICE_HANDLE hDevice, uint32_t nCycleInterval, - bool vBiasEnable, + bool vBiasEnable, bool vPostExecCurrentState, bool vGroundSwitch) { @@ -1093,7 +1108,7 @@ cycleControlReg.Cycle_Time_Units = CORE_CYCLE_CONTROL_SECONDS; } else { ADMW_LOG_ERROR("Invalid nCycleInterval %d specified", nCycleInterval); - return ADMW_INVALID_PARAM; + return ADMW_INVALID_PARAM; } if (vBiasEnable == true) { @@ -1101,35 +1116,33 @@ } CHECK_REG_FIELD_VAL(CORE_CYCLE_CONTROL_CYCLE_TIME, nCycleInterval); cycleControlReg.Cycle_Time = nCycleInterval; - - switch(vPostExecCurrentState) - { - case ADMW1001_ADC_EXC_STATE_CYCLE_POWER: - cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_POWERCYCLE; - break; - case ADMW1001_ADC_EXC_STATE_ALWAYS_ON: - cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_ALWAYSON; - break; - default: - ADMW_LOG_ERROR("Invalid Post measurement Excitation Current state %d specified", - vPostExecCurrentState); - return ADMW_INVALID_PARAM; + + switch(vPostExecCurrentState) { + case ADMW1001_ADC_EXC_STATE_CYCLE_POWER: + cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_POWERCYCLE; + break; + case ADMW1001_ADC_EXC_STATE_ALWAYS_ON: + cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_ALWAYSON; + break; + default: + ADMW_LOG_ERROR("Invalid Post measurement Excitation Current state %d specified", + vPostExecCurrentState); + return ADMW_INVALID_PARAM; } - - switch(vGroundSwitch) - { - case ADMW1001_ADC_GND_SW_OPEN: - cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_CYCLE_SW; - break; - case ADMW1001_ADC_GND_SW_CLOSED: - cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_CLOSE_SW; - break; - default: - ADMW_LOG_ERROR("Invalid ground switch state %d specified", - vGroundSwitch); - return ADMW_INVALID_PARAM; + + switch(vGroundSwitch) { + case ADMW1001_ADC_GND_SW_OPEN: + cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_OPEN_SW; + break; + case ADMW1001_ADC_GND_SW_CLOSED: + cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_CLOSE_SW; + break; + default: + ADMW_LOG_ERROR("Invalid ground switch state %d specified", + vGroundSwitch); + return ADMW_INVALID_PARAM; } - + WRITE_REG_U16(hDevice, cycleControlReg.VALUE16, CORE_CYCLE_CONTROL); return ADMW_SUCCESS; @@ -1142,6 +1155,14 @@ return ADMW_SUCCESS; } +static ADMW_RESULT admw_SetFifoNumCycles( + ADMW_DEVICE_HANDLE hDevice, + uint8_t fifoNumCycles) +{ + WRITE_REG_U8(hDevice, fifoNumCycles, CORE_FIFO_NUM_CYCLES); + + return ADMW_SUCCESS; +} static ADMW_RESULT admw_SetExternalReferenceValues( ADMW_DEVICE_HANDLE hDevice, @@ -1152,14 +1173,14 @@ return ADMW_SUCCESS; } static ADMW_RESULT admw_SetAVDDVoltage( - ADMW_DEVICE_HANDLE hDevice, - float32_t AVDDVoltage) - { + ADMW_DEVICE_HANDLE hDevice, + float32_t AVDDVoltage) +{ - WRITE_REG_FLOAT(hDevice, AVDDVoltage, CORE_AVDD_VOLTAGE); + WRITE_REG_FLOAT(hDevice, AVDDVoltage, CORE_AVDD_VOLTAGE); - return ADMW_SUCCESS; - } + return ADMW_SUCCESS; +} ADMW_RESULT admw1001_SetMeasurementConfig( ADMW_DEVICE_HANDLE hDevice, @@ -1184,17 +1205,33 @@ return eRet; } + if (pMeasConfig->fifoNumCycles > 0) { + eRet = admw_SetFifoNumCycles(hDevice, + pMeasConfig->fifoNumCycles); + } + + if (eRet != ADMW_SUCCESS) { + ADMW_LOG_ERROR("Failed to set the FIFO number of cycles."); + return eRet; + } + if(pMeasConfig->externalRef1Value > 0) { eRet = admw_SetExternalReferenceValues(hDevice, pMeasConfig->externalRef1Value); } - if((pMeasConfig->AVDDVoltage >= 3.0) && (pMeasConfig->AVDDVoltage <= 3.6)) - { + + if (eRet != ADMW_SUCCESS) { + ADMW_LOG_ERROR("Failed to set external reference values"); + return eRet; + } + + if((pMeasConfig->AVDDVoltage >= 3.0) && (pMeasConfig->AVDDVoltage <= 3.6)) { eRet = admw_SetAVDDVoltage(hDevice, pMeasConfig->AVDDVoltage); } + if (eRet != ADMW_SUCCESS) { - ADMW_LOG_ERROR("Failed to set external reference values"); + ADMW_LOG_ERROR("Failed to set AVDD Voltge"); return eRet; } @@ -1212,7 +1249,6 @@ return ADMW_SUCCESS; } - ADMW_RESULT admw1001_SetDiagnosticsConfig( ADMW_DEVICE_HANDLE hDevice, ADMW1001_DIAGNOSTICS_CONFIG *pDiagnosticsConfig) @@ -1313,18 +1349,37 @@ /* Ensure that the sensor type is valid for this channel */ switch(sensorType) { + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT10: + + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT50: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT100: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT200: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT500: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000_0P00375: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_NI120: + case ADMW1001_ADC_SENSOR_RTD_2WIRE_CUSTOM: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT10: + + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT50: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT100: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT200: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT500: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000_0P00375: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_NI120: + case ADMW1001_ADC_SENSOR_RTD_4WIRE_CUSTOM: + case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT10: + + case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT50: case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT100: + case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT200: + case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT500: case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000: - case ADMW1001_ADC_SENSOR_RTD_3WIRE_1: - case ADMW1001_ADC_SENSOR_RTD_3WIRE_2: - case ADMW1001_ADC_SENSOR_RTD_3WIRE_3: - case ADMW1001_ADC_SENSOR_RTD_3WIRE_4: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT100: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_PT1000: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_1: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_2: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_3: - case ADMW1001_ADC_SENSOR_RTD_4WIRE_4: + case ADMW1001_ADC_SENSOR_RTD_3WIRE_PT1000_0P00375 : + + case ADMW1001_ADC_SENSOR_RTD_3WIRE_NI120: + case ADMW1001_ADC_SENSOR_RTD_3WIRE_CUSTOM: case ADMW1001_ADC_SENSOR_BRIDGE_4WIRE_1: case ADMW1001_ADC_SENSOR_BRIDGE_4WIRE_2: case ADMW1001_ADC_SENSOR_BRIDGE_4WIRE_3: @@ -1333,28 +1388,23 @@ case ADMW1001_ADC_SENSOR_BRIDGE_6WIRE_2: case ADMW1001_ADC_SENSOR_BRIDGE_6WIRE_3: case ADMW1001_ADC_SENSOR_BRIDGE_6WIRE_4: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT100: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_PT1000: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_1: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_2: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_3: - case ADMW1001_ADC_SENSOR_RTD_2WIRE_4: - case ADMW1001_ADC_SENSOR_DIODE_2C_TYPEA: - case ADMW1001_ADC_SENSOR_DIODE_3C_TYPEA: - case ADMW1001_ADC_SENSOR_DIODE_2C_1: - case ADMW1001_ADC_SENSOR_DIODE_3C_1: - case ADMW1001_ADC_SENSOR_THERMISTOR_A_10K: - case ADMW1001_ADC_SENSOR_THERMISTOR_B_10K: - case ADMW1001_ADC_SENSOR_THERMISTOR_1: - case ADMW1001_ADC_SENSOR_THERMISTOR_2: - case ADMW1001_ADC_SENSOR_THERMISTOR_3: - case ADMW1001_ADC_SENSOR_THERMISTOR_4: + case ADMW1001_ADC_SENSOR_DIODE: + case ADMW1001_ADC_SENSOR_THERMISTOR_44004_44033_2P252K_AT_25C: + case ADMW1001_ADC_SENSOR_THERMISTOR_44005_44030_3K_AT_25C: + case ADMW1001_ADC_SENSOR_THERMISTOR_44007_44034_5K_AT_25C: + case ADMW1001_ADC_SENSOR_THERMISTOR_44006_44031_10K_AT_25C: + case ADMW1001_ADC_SENSOR_THERMISTOR_44008_44032_30K_AT_25C: + case ADMW1001_ADC_SENSOR_THERMISTOR_YSI_400: + case ADMW1001_ADC_SENSOR_THERMISTOR_SPECTRUM_1003K_1K: + case ADMW1001_ADC_SENSOR_THERMISTOR_CUSTOM_STEINHART_HART: + case ADMW1001_ADC_SENSOR_THERMISTOR_CUSTOM_TABLE: case ADMW1001_ADC_SENSOR_SINGLE_ENDED_ABSOLUTE: case ADMW1001_ADC_SENSOR_DIFFERENTIAL_ABSOLUTE: case ADMW1001_ADC_SENSOR_SINGLE_ENDED_RATIO: case ADMW1001_ADC_SENSOR_DIFFERENTIAL_RATIO: - if (! (ADMW1001_CHANNEL_IS_ADC_SENSOR(eChannelId) || - ADMW1001_CHANNEL_IS_ADC_CJC(eChannelId) || ADMW1001_CHANNEL_IS_ADC(eChannelId) )) { + + if (! (ADMW1001_CHANNEL_IS_ADC_CJC(eChannelId) || + ADMW1001_CHANNEL_IS_ADC(eChannelId) )) { ADMW_LOG_ERROR( "Invalid ADC sensor type %d specified for channel %d", sensorType, eChannelId); @@ -1369,10 +1419,12 @@ case ADMW1001_ADC_SENSOR_THERMOCOUPLE_J: case ADMW1001_ADC_SENSOR_THERMOCOUPLE_K: case ADMW1001_ADC_SENSOR_THERMOCOUPLE_T: - case ADMW1001_ADC_SENSOR_THERMOCOUPLE_1: - case ADMW1001_ADC_SENSOR_THERMOCOUPLE_2: - case ADMW1001_ADC_SENSOR_THERMOCOUPLE_3: - case ADMW1001_ADC_SENSOR_THERMOCOUPLE_4: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_E: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_N: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_R: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_S: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_B: + case ADMW1001_ADC_SENSOR_THERMOCOUPLE_CUSTOM: if (! ADMW1001_CHANNEL_IS_ADC_VOLTAGE(eChannelId)) { ADMW_LOG_ERROR( "Invalid ADC sensor type %d specified for channel %d", @@ -1779,6 +1831,7 @@ switch(sensorType) { case ADMW1001_I2C_SENSOR_HUMIDITY_A: case ADMW1001_I2C_SENSOR_HUMIDITY_B: + case ADMW1001_I2C_SENSOR_TEMPERATURE_ADT742X: sensorTypeReg.Sensor_Type = sensorType; break; default: @@ -1812,7 +1865,6 @@ digitalSensorComms.VALUE16 = REG_RESET_VAL(CORE_DIGITAL_SENSOR_COMMSn); if(pDigitalComms->useCustomCommsConfig) { - digitalSensorComms.Digital_Sensor_Comms_En = 1; if(pDigitalComms->i2cClockSpeed == ADMW1001_DIGITAL_SENSOR_COMMS_I2C_CLOCK_SPEED_100K) { digitalSensorComms.I2C_Clock = CORE_DIGITAL_SENSOR_COMMS_I2C_100K; @@ -1892,10 +1944,9 @@ pDigitalComms->spiClock); return ADMW_INVALID_PARAM; } - } else { - digitalSensorComms.Digital_Sensor_Comms_En = 0; } + WRITE_REG_U16(hDevice, digitalSensorComms.VALUE16, CORE_DIGITAL_SENSOR_COMMSn(eChannelId)); return ADMW_SUCCESS; @@ -2106,17 +2157,6 @@ { ADMW_CORE_Settling_Time_t settlingTimeReg; - if (nSettlingTime < (1 << 12)) - { - - settlingTimeReg.Settling_Time_Units = CORE_SETTLING_TIME_MILLISECONDS; - } - else - { - settlingTimeReg.Settling_Time_Units = CORE_SETTLING_TIME_SECONDS; - nSettlingTime /= 1000; - } - CHECK_REG_FIELD_VAL(CORE_SETTLING_TIME_SETTLING_TIME, nSettlingTime); settlingTimeReg.Settling_Time = nSettlingTime; @@ -2307,6 +2347,7 @@ { ADMW1001_LUT_HEADER *pLutHeader = &pLutData->header; ADMW1001_LUT_TABLE *pLutTable = pLutData->tables; + unsigned actualLength = 0; if (pLutData->header.signature != ADMW_LUT_SIGNATURE) { @@ -2314,7 +2355,10 @@ ADMW_LUT_SIGNATURE, pLutHeader->signature); return ADMW_INVALID_SIGNATURE; } - + if ((pLutData->tables->descriptor.geometry!= ADMW1001_LUT_GEOMETRY_NES_1D) && + (pLutData->tables->data.lut1dNes.nElements > MAX_LUT_NUM_ENTRIES)) { + return ADMW_INVALID_PARAM; + } for (unsigned i = 0; i < pLutHeader->numTables; i++) { ADMW1001_LUT_DESCRIPTOR *pDesc = &pLutTable->descriptor; ADMW1001_LUT_TABLE_DATA *pData = &pLutTable->data; @@ -2337,14 +2381,6 @@ } break; case ADMW1001_LUT_GEOMETRY_NES_1D: - case ADMW1001_LUT_GEOMETRY_NES_2D: - case ADMW1001_LUT_GEOMETRY_ES_1D: - case ADMW1001_LUT_GEOMETRY_ES_2D: - if (pDesc->equation != ADMW1001_LUT_EQUATION_LUT) { - ADMW_LOG_ERROR("Invalid equation %u specified for LUT table %u", - pDesc->equation, i); - return ADMW_INVALID_PARAM; - } break; default: ADMW_LOG_ERROR("Invalid geometry %u specified for LUT table %u", @@ -2394,7 +2430,6 @@ return ADMW_SUCCESS; } - ADMW_RESULT admw1001_SetLutDataRaw( ADMW_DEVICE_HANDLE const hDevice, ADMW1001_LUT_RAW * const pLutData) @@ -2411,22 +2446,11 @@ switch (pDesc->geometry) { case ADMW1001_LUT_GEOMETRY_COEFFS: if (pDesc->equation == ADMW1001_LUT_EQUATION_BIVARIATE_POLYN) - *pLength = ADMW1001_LUT_2D_POLYN_COEFF_LIST_SIZE(pData->coeffList2d); - else *pLength = ADMW1001_LUT_COEFF_LIST_SIZE(pData->coeffList); break; case ADMW1001_LUT_GEOMETRY_NES_1D: *pLength = ADMW1001_LUT_1D_NES_SIZE(pData->lut1dNes); break; - case ADMW1001_LUT_GEOMETRY_NES_2D: - *pLength = ADMW1001_LUT_2D_NES_SIZE(pData->lut2dNes); - break; - case ADMW1001_LUT_GEOMETRY_ES_1D: - *pLength = ADMW1001_LUT_1D_ES_SIZE(pData->lut1dEs); - break; - case ADMW1001_LUT_GEOMETRY_ES_2D: - *pLength = ADMW1001_LUT_2D_ES_SIZE(pData->lut2dEs); - break; default: ADMW_LOG_ERROR("Invalid LUT table geometry %d specified\r\n", pDesc->geometry);