Vybhav Kadaba / Mbed OS EV-PRO-MW1001_Development_v11775

Files at this revision

API Documentation at this revision

Comitter:
Vkadaba
Date:
Thu Nov 14 05:35:08 2019 +0000
Parent:
32:52445bef314d
Child:
34:b60ee1e0af2b
Commit message:
Added support for the following:; 1.Rsense; 2.Excitation current state; 3.Buffer bypass ; ; the aobve support is only for analog sensors.; Tested and the system is working fine

Changed in this revision

inc/admw1001/admw1001_config.h Show annotated file Show diff for this revision Revisions of this file
sensor0_typeK_cjc0_config.c Show annotated file Show diff for this revision Revisions of this file
sensor2_bridge_4w_load_cell_config.c Show annotated file Show diff for this revision Revisions of this file
src/admw_1001.c Show annotated file Show diff for this revision Revisions of this file
--- a/inc/admw1001/admw1001_config.h	Fri Oct 25 05:08:19 2019 +0000
+++ b/inc/admw1001/admw1001_config.h	Thu Nov 14 05:35:08 2019 +0000
@@ -172,6 +172,16 @@
 
 }   ADMW1001_OPEN_SENSOR_DIAGNOSTICS;
 
+
+typedef enum
+{
+    ADMW1001_BUFFER_BYPASSS_DISABLED = 0,
+    /*!< Buffer Bypass Disabled */
+    ADMW1001_BUFFER_BYPASSS_ENABLED,
+    /*!< Buffer Bypass Enabled */
+ 
+}   ADMW1001_BUFFER_BYPASSS;
+
 /*! ADMW1001 analog input signal amplification gain options
  *
  *  @note applicable only to ADC analog sensor channels
@@ -220,13 +230,10 @@
  */
 typedef enum
 {
-    ADMW1001_ADC_EXC_STATE_OFF=-1,
-    /*!< Excitation for measurement is off*/
+    ADMW1001_ADC_EXC_STATE_CYCLE_POWER=0,
+    /*!< Excitation for measurement is active only during measurement */
     ADMW1001_ADC_EXC_STATE_ALWAYS_ON,
     /*!< Excitation for measurement is always on */
-    ADMW1001_ADC_EXC_STATE_CYCLE_POWER,
-    /*!< Excitation for measurement is active only during measurement */
-
 }   ADMW1001_ADC_EXC_STATE;
 
 /*! ADMW1001 analog sensor excitation current output level options
@@ -496,8 +503,10 @@
      *   Applicable only if the selected reference type is
      *   voltage.
      *   (see @ref ADMW1001_ADC_REFERENCE_TYPE)
-     */    
-    uint32_t                    reserved1[4];
+     */ 
+    float32_t                   RSenseValue;
+    /*!< Sense resistor value in Ohms. */  
+    uint32_t                    reserved1[3];
     /*!< Reserved for future use and ensure word alignment.
      */ 
 
@@ -557,7 +566,9 @@
     ADMW1001_ADC_REFERENCE_TYPE     reference;
     bool                        vBiasEnable;
     /*!< ADC Reference configuration */
-    uint8_t                         reserved0[3];
+    uint8_t                         bufferBypass;
+    /*!< Buffer Bypass configuration */  
+    uint8_t                         reserved0[2];
     /*!< Reserved for future use and ensure word alignment. */
     uint32_t                        reserved1[6];
     /*!< Reserved for future use and ensure word alignment. */
--- a/sensor0_typeK_cjc0_config.c	Fri Oct 25 05:08:19 2019 +0000
+++ b/sensor0_typeK_cjc0_config.c	Thu Nov 14 05:35:08 2019 +0000
@@ -1,3 +1,4 @@
+
 /*!
  ******************************************************************************
  * @file:   config.c
@@ -57,6 +58,7 @@
             .dataReadyMode = ADMW1001_DATAREADY_PER_CYCLE, // FIX: Temporarily all values from json are hardcoded to this one in the Contracts.FileGenerator - > file translations!!
             .cycleInterval = 0,
             .vBiasEnable = true,
+            .RSenseValue = 1000.0,
         },
         .diagnostics = {
             .disableGlobalDiag = true,
@@ -96,6 +98,7 @@
                         .groundSwitch = ADMW1001_ADC_GND_SW_OPEN
                     },
                     .reference = ADMW1001_ADC_REFERENCE_VOLTAGE_INTERNAL,
+                    .bufferBypass = ADMW1001_BUFFER_BYPASSS_DISABLED,
                 },
             },
             [ADMW1001_CH_ID_ANLG_1_DIFFERENTIAL] = {
@@ -118,7 +121,7 @@
                     .rtdCurve = ADMW1001_ADC_RTD_CURVE_EUROPEAN,
                     .gain = ADMW1001_ADC_GAIN_8X,
                     .current = {
-                        .excitationState= ADMW1001_ADC_EXC_STATE_OFF,
+                        .excitationState= ADMW1001_ADC_EXC_STATE_CYCLE_POWER,
                         .outputLevel = ADMW1001_ADC_NO_EXTERNAL_EXC_CURRENT,
                         .diodeRatio = 0,
                     },
@@ -130,8 +133,10 @@
                         .groundSwitch = ADMW1001_ADC_GND_SW_OPEN
                     },
                     .reference = ADMW1001_ADC_REFERENCE_VOLTAGE_INTERNAL,
+                    .bufferBypass = ADMW1001_BUFFER_BYPASSS_DISABLED,
                 },
             },
         },
     },
 };
+
--- a/sensor2_bridge_4w_load_cell_config.c	Fri Oct 25 05:08:19 2019 +0000
+++ b/sensor2_bridge_4w_load_cell_config.c	Thu Nov 14 05:35:08 2019 +0000
@@ -53,6 +53,7 @@
             .operatingMode = ADMW1001_OPERATING_MODE_CONTINUOUS,
             .dataReadyMode = ADMW1001_DATAREADY_PER_CYCLE, // FIX: Temporarily all values from json are hardcoded to this one in the Contracts.FileGenerator - > file translations!!
             .cycleInterval = 0,
+            .RSenseValue = 1000.0,
         },
         .diagnostics = {
             .disableGlobalDiag = true,
@@ -86,6 +87,7 @@
                         .groundSwitch = ADMW1001_ADC_GND_SW_CLOSED
                     },
                     .reference = ADMW1001_ADC_REFERENCE_VOLTAGE_AVDD,
+                    .bufferBypass = ADMW1001_BUFFER_BYPASSS_DISABLED,
                 },
             },
         },
--- a/src/admw_1001.c	Fri Oct 25 05:08:19 2019 +0000
+++ b/src/admw_1001.c	Thu Nov 14 05:35:08 2019 +0000
@@ -1030,6 +1030,19 @@
     return ADMW_SUCCESS;
 }
 
+static ADMW_RESULT admw_SetRSenseValue(
+    ADMW_DEVICE_HANDLE hDevice,
+    float32_t RSenseValue)
+{
+   ADMW_CORE_External_Reference_Resistor_t RefResistorConfigReg;
+  
+   RefResistorConfigReg.Ext_Refin1_Value = RSenseValue;
+   
+   WRITE_REG_FLOAT(hDevice, RefResistorConfigReg.VALUE32, CORE_EXTERNAL_REFERENCE_RESISTOR);
+   
+   return ADMW_SUCCESS;
+
+}
 static ADMW_RESULT admw_SetMode(
     ADMW_DEVICE_HANDLE hDevice,
     ADMW1001_OPERATING_MODE eOperatingMode,
@@ -1130,6 +1143,12 @@
         return eRet;
     }
 
+    eRet = admw_SetRSenseValue(hDevice, pMeasConfig->RSenseValue);
+    if (eRet != ADMW_SUCCESS)
+    {
+        ADMW_LOG_ERROR("Failed to set RSenseValue");
+        return eRet;
+    }
     return ADMW_SUCCESS;
 }
 
@@ -1428,14 +1447,17 @@
     return ADMW_SUCCESS;
 }
 
-static ADMW_RESULT admw_SetChannelAdcFilter(
+static ADMW_RESULT admw_SetChannelAdcMeasurementSetup(
     ADMW_DEVICE_HANDLE hDevice,
     ADMW1001_CH_ID eChannelId,
-    ADMW1001_ADC_FILTER_CONFIG *pFilterConfig)
+    ADMW1001_ADC_CHANNEL_CONFIG *pAdcChannelConfig)
 {
     ADMW_CORE_Measurement_Setup_t MeasSetupReg;
+    ADMW1001_ADC_FILTER_CONFIG *pFilterConfig = &pAdcChannelConfig->filter;
     MeasSetupReg.VALUE32 = REG_RESET_VAL(CORE_MEASUREMENT_SETUPn);
-
+    MeasSetupReg.PST_MEAS_EXC_CTRL = pAdcChannelConfig->current.excitationState;
+    MeasSetupReg.Buffer_Bypass = pAdcChannelConfig->bufferBypass;
+    
     if (pFilterConfig->type == ADMW1001_ADC_FILTER_SINC4) {
         MeasSetupReg.ADC_Filter_Type = CORE_MEASUREMENT_SETUP_ENABLE_SINC4;
         MeasSetupReg.ADC_SF = pFilterConfig->sf;
@@ -1533,8 +1555,8 @@
         return eRet;
     }
 
-    eRet = admw_SetChannelAdcFilter(hDevice, eChannelId,
-                                    &pAdcChannelConfig->filter);
+    eRet = admw_SetChannelAdcMeasurementSetup(hDevice, eChannelId,
+                                         pAdcChannelConfig);
     if (eRet != ADMW_SUCCESS) {
         ADMW_LOG_ERROR("Failed to set ADC filter for channel %d",
                        eChannelId);