comparison Discovery/Src/data_exchange_main.c @ 728:5143e927219f

Added sensor map to Firmware <=> RTE inferface: The sensor map contains a list of up to five sensors which may be connected to the external interface. The update includes the definition of the type as well as the data structure. to ensure compatibility the RTE and needed RTE version has been set to 3.0
author Ideenmodellierer
date Sat, 14 Jan 2023 20:41:36 +0100
parents 74cfd91199bd
children 190e5814b2f5
comparison
equal deleted inserted replaced
727:1dca3bb187d7 728:5143e927219f
371 void DateEx_copy_to_dataOut(void) 371 void DateEx_copy_to_dataOut(void)
372 { 372 {
373 const SDiveState * pStateReal = stateRealGetPointer(); 373 const SDiveState * pStateReal = stateRealGetPointer();
374 SSettings *settings = settingsGetPointer(); 374 SSettings *settings = settingsGetPointer();
375 375
376 uint8_t SensorActive[SENSOR_END];
377 uint8_t index = 0;
378
379
376 if(get_globalState() == StStop) 380 if(get_globalState() == StStop)
377 dataOut.mode = MODE_SHUTDOWN; 381 dataOut.mode = MODE_SHUTDOWN;
378 else 382 else
379 dataOut.mode = 0; 383 dataOut.mode = 0;
380 384
390 394
391 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar; 395 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar;
392 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad; 396 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad;
393 397
394 398
395 399 memcpy(dataOut.data.externalInterface_SensorMap, settings->ext_sensor_map, 5);
396 if((settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) 400
397 { 401 memset(SensorActive, 0, sizeof(SensorActive));
398 externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; 402 for (index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++)
399 } 403 {
400 404 switch(settings->ext_sensor_map[index])
401 if((settings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) 405 {
402 { 406 case SENSOR_ANALOG: SensorActive[SENSOR_ANALOG] = 1;
403 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2; 407 break;
408 case SENSOR_DIGO2: SensorActive[SENSOR_DIGO2] = 1;
409 break;
410 case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1;
411 break;
412 default:
413 break;
414 }
415 }
416
417 if(SensorActive[SENSOR_ANALOG])
418 {
419 externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON;
420 }
421 if(SensorActive[SENSOR_DIGO2])
422 {
423 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2;
424 }
425 else if(SensorActive[SENSOR_CO2]) /* TODO: at the moment only one serial sensor is supported => else condition. to be changed once multiplexing is available */
426 {
427 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_CO2; /* CO2 sensor has to be activated via auto detection */
404 } 428 }
405 429
406 #ifdef ENABLE_SENTINEL_MODE 430 #ifdef ENABLE_SENTINEL_MODE
407 if(settings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) 431 if(settings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
408 { 432 {
409 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_SENTINEL; 433 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_SENTINEL;
410 externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON); 434 externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON);
411 } 435 }
412 #endif 436 #endif
413 437
414 if(settings->ext_uart_protocol)
415 {
416 externalInterface_Cmd |= (settings->ext_uart_protocol << 8);
417 }
418 if(settings->co2_sensor_active)
419 {
420 externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_CO2;
421 }
422 dataOut.data.externalInterface_Cmd = externalInterface_Cmd; 438 dataOut.data.externalInterface_Cmd = externalInterface_Cmd;
423 externalInterface_Cmd = 0; 439 externalInterface_Cmd = 0;
424 440
425 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15)))) 441 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15))))
426 { 442 {
450 if(!wasUpdateNotPowerOn) 466 if(!wasUpdateNotPowerOn)
451 wasPowerOn = 1; 467 wasPowerOn = 1;
452 468
453 settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness); 469 settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness);
454 setButtonResponsiveness(settings->ButtonResponsiveness); 470 setButtonResponsiveness(settings->ButtonResponsiveness);
471 DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP);
455 } 472 }
456 } 473 }
457 474
458 475
459 void DataEX_copy_to_deco(void) 476 void DataEX_copy_to_deco(void)
951 pStateReal->lifeData.sensorVoltage_mV[idx] = 0.0; 968 pStateReal->lifeData.sensorVoltage_mV[idx] = 0.0;
952 pStateReal->lifeData.ppO2Sensor_bar[idx] = 0; 969 pStateReal->lifeData.ppO2Sensor_bar[idx] = 0;
953 } 970 }
954 else 971 else
955 { 972 {
956 if((idx == 0) && ((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))) 973 if(dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map[idx] == SENSOR_DIGO2)
957 { 974 {
958 pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] / 100.0; 975 pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] / 100.0;
959 } 976 }
960 else 977 else
961 { 978 {
966 pStateReal->lifeData.extIf_sensor_Id = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].externalInterface_SensorID; 983 pStateReal->lifeData.extIf_sensor_Id = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].externalInterface_SensorID;
967 if(pStateReal->lifeData.extIf_sensor_Id != 0) 984 if(pStateReal->lifeData.extIf_sensor_Id != 0)
968 { 985 {
969 memcpy(pStateReal->lifeData.extIf_sensor_data, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_data, 32); 986 memcpy(pStateReal->lifeData.extIf_sensor_data, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_data, 32);
970 } 987 }
988 memcpy(pStateReal->lifeData.extIf_sensor_map, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map, EXT_INTERFACE_SENSOR_CNT);
971 } 989 }
972 } 990 }
973 991
974 if(pStateReal->data_old__lost_connection_to_slave == 0) 992 if(pStateReal->data_old__lost_connection_to_slave == 0)
975 { 993 {