diff Discovery/Src/data_exchange_main.c @ 556:eb2060caca7d

Switch source of o2 sensor data depending on availability of external ADC: Dependig on the HW configuration provided by RTE the data vields for o2 voltage values are derived from the optical or the external ADC interface. TODO: Add manual selection to O2 menu to enable manuel switching.
author Ideenmodellierer
date Thu, 12 Nov 2020 19:54:58 +0100
parents d784f281833a
children 84a4e1200726
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Thu Nov 12 19:48:28 2020 +0100
+++ b/Discovery/Src/data_exchange_main.c	Thu Nov 12 19:54:58 2020 +0100
@@ -72,6 +72,7 @@
 #include "buehlmann.h"
 #include "externLogbookFlash.h"
 
+//#define TESTBENCH
 
 /* Exported variables --------------------------------------------------------*/
 static uint8_t	wasPowerOn = 0;
@@ -771,15 +772,6 @@
 	SDiveState *pStateReal = stateRealGetPointerWrite();
 	static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
 	
-	/* internal sensor: HUD data
-	 */
-	for(int i=0;i<3;i++)
-	{
-		pStateReal->lifeData.ppO2Sensor_bar[i] = get_ppO2Sensor_bar(i);
-		pStateReal->lifeData.sensorVoltage_mV[i] = get_sensorVoltage_mV(i);
-	}
-	pStateReal->lifeData.HUD_battery_voltage_V = get_HUD_battery_voltage_V();
-
 	
 	// wireless - �ltere daten aufr�umen
 #if 0
@@ -870,6 +862,27 @@
 		dataIn.mode = MODE_DIVE;
 	}
 
+
+	/* internal sensor: HUD data	 */
+	if(DataEX_external_ADC_Present == 0)
+	{
+		for(int i=0;i<3;i++)
+		{
+			pStateReal->lifeData.ppO2Sensor_bar[i] = get_ppO2Sensor_bar(i);
+			pStateReal->lifeData.sensorVoltage_mV[i] = get_sensorVoltage_mV(i);
+		}
+		pStateReal->lifeData.HUD_battery_voltage_V = get_HUD_battery_voltage_V();
+	}
+	else /* use data from external ADC */
+	{
+		if(pStateReal->data_old__lost_connection_to_slave == 0)
+		{
+			pStateReal->lifeData.sensorVoltage_mV[0] = dataIn.data[0].extADC_voltage[0];
+			pStateReal->lifeData.sensorVoltage_mV[1] = dataIn.data[0].extADC_voltage[1];
+			pStateReal->lifeData.sensorVoltage_mV[2] = dataIn.data[0].extADC_voltage[2];
+		}
+	}
+
 	if(pStateReal->data_old__lost_connection_to_slave == 0)
 	{
 		meter = getSampleDepth(&dataIn, pStateReal);
@@ -1170,4 +1183,12 @@
 		DataEX_merge_DeviceData_and_store();
 	}
 }
+uint8_t DataEX_external_ADC_Present(void)
+{
+	uint8_t retval;
+	SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn;
 
+	retval = dataInDevice->hw_Info.extADC;
+
+	return retval;
+}