Mercurial > public > ostc4
changeset 702:6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Added functionality to pass the o2 signals from a digital sensor (via UART)
author | Ideenmodellierer |
---|---|
date | Fri, 28 Oct 2022 20:29:37 +0200 |
parents | 8c48553a0176 |
children | 2f457024049b |
files | Common/Inc/data_exchange.h Common/Inc/settings.h Discovery/Src/data_exchange_main.c |
diffstat | 3 files changed, 22 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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
--- 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]; + } } }