changeset 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 573a2bc796c8
children 2702bfa7b177
files Discovery/Inc/data_exchange_main.h Discovery/Inc/externLogbookFlash.h Discovery/Src/data_exchange_main.c
diffstat 3 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/data_exchange_main.h	Thu Nov 12 19:48:28 2020 +0100
+++ b/Discovery/Inc/data_exchange_main.h	Thu Nov 12 19:54:58 2020 +0100
@@ -50,6 +50,7 @@
 void DataEX_control_connection_while_asking_for_sleep(void);
 uint8_t DataEX_check_RTE_version__needs_update(void);
 void setAvgDepth(SDiveState *pStateReal);
+uint8_t DataEX_external_ADC_Present(void);
 
 SDataReceiveFromMaster * dataOutGetPointer(void);
 
--- a/Discovery/Inc/externLogbookFlash.h	Thu Nov 12 19:48:28 2020 +0100
+++ b/Discovery/Inc/externLogbookFlash.h	Thu Nov 12 19:54:58 2020 +0100
@@ -166,7 +166,7 @@
 
 uint16_t ext_flash_repair_SPECIAL_dive_numbers_starting_count_with(uint16_t startCount);
 
-uint32_t ext_flash_AnalyseSampleBuffer(char *pstrResult);
+uint32_t ext_flash_AnalyseSampleBuffer(void);
 void ext_flash_CloseSector(void);
 
 uint32_t ext_flash_read_profilelength_small_header(uint32_t smallHeaderAddr);
--- 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;
+}