Diaz George / Mbed OS EV-PRO-MW1001

Files at this revision

API Documentation at this revision

Comitter:
diazdgeorge
Date:
Tue Nov 05 12:45:48 2019 +0000
Parent:
30:c78466adc502
Commit message:
added latest configuration parameters support

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
src/admw_1001.c Show annotated file Show diff for this revision Revisions of this file
--- a/inc/admw1001/admw1001_config.h	Thu Oct 03 09:37:48 2019 +0000
+++ b/inc/admw1001/admw1001_config.h	Tue Nov 05 12:45:48 2019 +0000
@@ -172,6 +172,15 @@
 
 }   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 +229,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 +502,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.
      */ 
 
@@ -556,8 +564,9 @@
     /*!< ADC Filter configuration */
     ADMW1001_ADC_REFERENCE_TYPE     reference;
     bool                        vBiasEnable;
+    uint8_t             bufferBypass;   
     /*!< ADC Reference configuration */
-    uint8_t                         reserved0[3];
+    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	Thu Oct 03 09:37:48 2019 +0000
+++ b/sensor0_typeK_cjc0_config.c	Tue Nov 05 12:45:48 2019 +0000
@@ -57,6 +57,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 +97,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 +120,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,6 +132,7 @@
                         .groundSwitch = ADMW1001_ADC_GND_SW_OPEN
                     },
                     .reference = ADMW1001_ADC_REFERENCE_VOLTAGE_INTERNAL,
+                    .bufferBypass = ADMW1001_BUFFER_BYPASSS_DISABLED,
                 },
             },
         },
--- a/src/admw_1001.c	Thu Oct 03 09:37:48 2019 +0000
+++ b/src/admw_1001.c	Tue Nov 05 12:45:48 2019 +0000
@@ -991,6 +991,20 @@
     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,
@@ -1091,6 +1105,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;
 }
 
@@ -1429,14 +1449,18 @@
     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;
@@ -1567,8 +1591,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);