Mercurial > public > ostc4
diff Discovery/Src/data_exchange_main.c @ 981:c6c781a2e85b default tip
Merge into default
author | heinrichsweikamp |
---|---|
date | Tue, 11 Feb 2025 18:12:00 +0100 (45 hours ago) |
parents | 3420e3ba698d |
children |
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/data_exchange_main.c Tue Feb 11 18:12:00 2025 +0100 @@ -72,6 +72,8 @@ #include "timer.h" #include "buehlmann.h" #include "externLogbookFlash.h" +#include "vpm.h" +#include "check_warning.h" /* #define TESTBENCH */ @@ -410,6 +412,10 @@ break; case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; break; +#if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT + case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1; + break; +#endif #ifdef ENABLE_SENTINEL_MODE case SENSOR_SENTINEL: SensorActive[SENSOR_SENTINEL] = 1; break; @@ -423,23 +429,26 @@ { externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; } - if(SensorActive[SENSOR_DIGO2]) + if((SensorActive[SENSOR_DIGO2]) || (SensorActive[SENSOR_CO2])|| (SensorActive[SENSOR_GNSS])) { - externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2; - } - else if(SensorActive[SENSOR_CO2]) /* TODO: at the moment only one serial sensor is supported => else condition. to be changed once multiplexing is available */ - { - externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_CO2; /* CO2 sensor has to be activated via auto detection */ + externalInterface_Cmd |= EXT_INTERFACE_33V_ON; } #ifdef ENABLE_SENTINEL_MODE if(SensorActive[SENSOR_SENTINEL]) { - externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_SENTINEL; + externalInterface_Cmd |= EXT_INTERFACE_33V_ON; externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON); } #endif +#ifdef ENABLE_GPIO_V2 + if(getBuzzerActivationState()) + { + externalInterface_Cmd |= EXT_INTERFACE_BUZZER_ON; + } +#endif + dataOut.data.externalInterface_Cmd = externalInterface_Cmd; externalInterface_Cmd = 0; @@ -473,7 +482,7 @@ settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness); setButtonResponsiveness(settings->ButtonResponsiveness); - DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP); + DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP, 0); } } @@ -483,16 +492,17 @@ if(decoLock == DECO_CALC_running) return; - if(decoLock == DECO_CALC_init_as_is_start_of_dive) - { + if(decoLock == DECO_CALC_init_as_is_start_of_dive) + { + vpm_table_init(); vpm_init(&stateUsedWrite->vpm, stateUsedWrite->diveSettings.vpm_conservatism, 0, 0); buehlmann_init(); timer_init(); resetEvents(stateUsedWrite); stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; - } + } - if(decoLock == DECO_CALC_FINSHED_Buehlmann) + if(decoLock == DECO_CALC_FINSHED_Buehlmann) { } @@ -534,6 +544,7 @@ //Copy Inputdata from stateReal to stateDeco memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData)); memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings)); + memcpy(&stateDeco.decolistVPM,&stateUsedWrite->decolistVPM,sizeof(SDecoinfo)); stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached; // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm)); @@ -544,7 +555,7 @@ stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i]; stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i]; } - decoLock = DECO_CALC_ready; + decoLock = DECO_CALC_ready; } @@ -580,13 +591,16 @@ RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; + const SFirmwareData *pFirmwareInfo; + pFirmwareInfo = firmwareDataGetPointer(); + stimestructure.Hours = UNKNOWN_TIME_HOURS; stimestructure.Minutes = UNKNOWN_TIME_MINUTES; stimestructure.Seconds = UNKNOWN_TIME_SECOND; sdatestructure.Date = UNKNOWN_DATE_DAY; sdatestructure.Month = UNKNOWN_DATE_MONTH; - sdatestructure.Year = UNKNOWN_DATE_YEAR; + sdatestructure.Year = pFirmwareInfo->release_year; setWeekday(&sdatestructure); DataEX_helper_SetTime(stimestructure, &lineWrite->time_rtc_tr); @@ -1010,6 +1024,8 @@ pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; + + memcpy(&pStateReal->lifeData.gnssData, &dataIn.data[0].gnssInfo, sizeof(dataIn.data[0].gnssInfo)); } if(pStateReal->data_old__lost_connection_to_slave == 0) @@ -1033,6 +1049,8 @@ //Init dive Mode decoLock = DECO_CALC_init_as_is_start_of_dive; pStateReal->lifeData.boolResetAverageDepth = 1; + + memcpy(pStateReal->scrubberDataDive, pSettings->scrubberData, sizeof(pStateReal->scrubberDataDive)); } pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; @@ -1060,6 +1078,8 @@ } if(pStateReal->warnings.decoMissed) dataOut.setAccidentFlag += ACCIDENT_DECOSTOP; + + memcpy(pSettings->scrubberData, pStateReal->scrubberDataDive, sizeof(pStateReal->scrubberDataDive)); /* Store value of current usage */ } pStateReal->mode = dataIn.mode; pStateReal->chargeStatus = dataIn.chargeStatus; @@ -1159,7 +1179,7 @@ pStateReal->sensorErrorsRTE = dataIn.sensorErrors; /* data from CO2 sensor */ - pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm * 10; /* Scale factor depends on sensor */ + pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm; pStateReal->lifeData.CO2_data.signalStrength = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_signalStrength; #ifdef ENABLE_EXTERNAL_PRESSURE @@ -1343,9 +1363,14 @@ return retval; } -void DataEX_setExtInterface_Cmd(uint16_t Cmd) +void DataEX_setExtInterface_Cmd(uint16_t Cmd, uint8_t sensorId) { - externalInterface_Cmd = Cmd; + if(sensorId < EXT_INTERFACE_SENSOR_CNT - 1) + { + externalInterface_Cmd |= Cmd; + externalInterface_Cmd |= sensorId << 8; + } + return; }