# HG changeset patch # User Ideenmodellierer # Date 1666981777 -7200 # Node ID 6d7c812fc17324b77267a8748fcf57e54c635cb9 # Parent 8c48553a01765028fe458b62919539366af6605e Added digital o2 sensor to settings and data exchange: Added functionality to pass the o2 signals from a digital sensor (via UART) diff -r 8c48553a0176 -r 6d7c812fc173 Common/Inc/data_exchange.h --- a/Common/Inc/data_exchange.h Fri Oct 28 19:39:20 2022 +0200 +++ b/Common/Inc/data_exchange.h Fri Oct 28 20:29:37 2022 +0200 @@ -41,8 +41,14 @@ #define EXT_INTERFACE_UART_MASK (0x0700u) /* Reserve 3 bits for UART protocol selection */ #define EXT_INTERFACE_UART_CO2 (0x0100u) /* Activate protocol for CO2 sensor */ #define EXT_INTERFACE_UART_SENTINEL (0x0200u) /* Activate Sentinel Backup monitor protocol */ +#define EXT_INTERFACE_UART_O2 (0x0400u) /* Activate digital o2 sensor protocol (DiveO2) */ + +/* Command subset for CO2 sensor */ #define EXT_INTERFACE_CO2_CALIB (0x0001u) /* Request calibration of CO2Sensor */ +/* Command subset for O2 sensor */ +#define EXT_INTERFACE_O2_INDICATE (0x0001u) /* Request LED to blink*/ + #define DATA_BUFFER_ADC (0x01u) #define DATA_BUFFER_CO2 (0x02u) diff -r 8c48553a0176 -r 6d7c812fc173 Common/Inc/settings.h --- a/Common/Inc/settings.h Fri Oct 28 19:39:20 2022 +0200 +++ b/Common/Inc/settings.h Fri Oct 28 20:29:37 2022 +0200 @@ -90,6 +90,8 @@ { O2_SENSOR_SOURCE_OPTIC = 0, O2_SENSOR_SOURCE_ANALOG, + O2_SENSOR_SOURCE_DIGITAL, + O2_SENSOR_SOURCE_ANADIG, #ifdef ENABLE_SENTINEL_MODE O2_SENSOR_SOURCE_SENTINEL, #endif diff -r 8c48553a0176 -r 6d7c812fc173 Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Fri Oct 28 19:39:20 2022 +0200 +++ b/Discovery/Src/data_exchange_main.c Fri Oct 28 20:29:37 2022 +0200 @@ -393,11 +393,16 @@ - if(settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) + if((settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) { externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; } + if((settings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) + { + externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2; + } + #ifdef ENABLE_SENTINEL_MODE if(settings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) { @@ -947,7 +952,14 @@ } else { - pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] * pSettings->ppo2sensors_calibCoeff[idx]; + if((idx == 0) && ((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))) + { + pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] / 100.0; + } + else + { + pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] * pSettings->ppo2sensors_calibCoeff[idx]; + } } }