# HG changeset patch # User Ideenmodellierer # Date 1605207298 -3600 # Node ID eb2060caca7d10ec3de3dd1707b17844b4ac261b # Parent 573a2bc796c8f7c09683aaf27bdb85be0f266a92 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. diff -r 573a2bc796c8 -r eb2060caca7d Discovery/Inc/data_exchange_main.h --- 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); diff -r 573a2bc796c8 -r eb2060caca7d Discovery/Inc/externLogbookFlash.h --- 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); diff -r 573a2bc796c8 -r eb2060caca7d Discovery/Src/data_exchange_main.c --- 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; +}