Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 1062:785772303f9c Icon_Integration
Added pressure sensors in Sentnel mode:
The Red Head/Provide pressure and tempstick information on a uart channel together with the O2 data. The support for receiving pressure data has been added to the Sentinel protocol function.
| author | Ideenmodellierer |
|---|---|
| date | Tue, 10 Feb 2026 19:36:05 +0100 |
| parents | d9290c76b840 |
| children | a3f42192da0f |
comparison
equal
deleted
inserted
replaced
| 1061:f501d7c35c8f | 1062:785772303f9c |
|---|---|
| 81 static uint16_t externalCO2Value; | 81 static uint16_t externalCO2Value; |
| 82 static uint16_t externalCO2SignalStrength; | 82 static uint16_t externalCO2SignalStrength; |
| 83 static uint16_t externalCO2Status = 0; | 83 static uint16_t externalCO2Status = 0; |
| 84 static float externalCO2Scale = 0.0; | 84 static float externalCO2Scale = 0.0; |
| 85 | 85 |
| 86 static uint8_t externalBottleBar[PRESSURE_BOTTLE_CNT] = {0,0}; | |
| 87 | |
| 86 static uint8_t lastSensorDataId = 0; | 88 static uint8_t lastSensorDataId = 0; |
| 87 static SSensorDataDiveO2 sensorDataDiveO2[EXT_INTERFACE_SENSOR_CNT]; | 89 static SSensorDataDiveO2 sensorDataDiveO2[EXT_INTERFACE_SENSOR_CNT]; |
| 88 static externalInterfaceAutoDetect_t externalAutoDetect = DETECTION_OFF; | 90 static externalInterfaceAutoDetect_t externalAutoDetect = DETECTION_OFF; |
| 89 static externalInterfaceSensorType SensorMap[EXT_INTERFACE_SENSOR_CNT] ={ SENSOR_OPTIC, SENSOR_OPTIC, SENSOR_OPTIC, SENSOR_NONE, SENSOR_NONE}; | 91 static externalInterfaceSensorType SensorMap[EXT_INTERFACE_SENSOR_CNT] ={ SENSOR_OPTIC, SENSOR_OPTIC, SENSOR_OPTIC, SENSOR_NONE, SENSOR_NONE}; |
| 90 static externalInterfaceSensorType tmpSensorMap[EXT_INTERFACE_SENSOR_CNT]; | 92 static externalInterfaceSensorType tmpSensorMap[EXT_INTERFACE_SENSOR_CNT]; |
| 137 externalUART_Protocol = 0; | 139 externalUART_Protocol = 0; |
| 138 externalCO2Value = 0; | 140 externalCO2Value = 0; |
| 139 externalCO2SignalStrength = 0; | 141 externalCO2SignalStrength = 0; |
| 140 externalCO2Status = 0; | 142 externalCO2Status = 0; |
| 141 externalCO2Scale = 0.0; | 143 externalCO2Scale = 0.0; |
| 144 externalBottleBar[0] = 0; | |
| 145 externalBottleBar[1] = 0; | |
| 142 externalAutoDetect = DETECTION_OFF; | 146 externalAutoDetect = DETECTION_OFF; |
| 143 | 147 |
| 144 for(index = 0; index < MAX_ADC_CHANNEL; index++) | 148 for(index = 0; index < MAX_ADC_CHANNEL; index++) |
| 145 { | 149 { |
| 146 externalChannel_mV[index] = 0.0; | 150 externalChannel_mV[index] = 0.0; |
| 507 uint16_t externalInterface_GetCO2State(void) | 511 uint16_t externalInterface_GetCO2State(void) |
| 508 { | 512 { |
| 509 return externalCO2Status; | 513 return externalCO2Status; |
| 510 } | 514 } |
| 511 | 515 |
| 516 void externalInterface_SetBottlePressure(uint8_t bottle, uint8_t bar) | |
| 517 { | |
| 518 if(bottle < PRESSURE_BOTTLE_CNT) | |
| 519 { | |
| 520 externalBottleBar[bottle] = bar; | |
| 521 } | |
| 522 } | |
| 523 | |
| 524 uint8_t externalInterface_GetBottlePressure(uint8_t bottle) | |
| 525 { | |
| 526 uint8_t ret = 0; | |
| 527 | |
| 528 if(bottle < PRESSURE_BOTTLE_CNT) | |
| 529 { | |
| 530 ret = externalBottleBar[bottle]; | |
| 531 } | |
| 532 return ret; | |
| 533 } | |
| 534 | |
| 512 | 535 |
| 513 uint8_t externalInterface_GetSensorData(uint8_t sensorId, uint8_t* pDataStruct) | 536 uint8_t externalInterface_GetSensorData(uint8_t sensorId, uint8_t* pDataStruct) |
| 514 { | 537 { |
| 515 uint8_t index = 0; | 538 uint8_t index = 0; |
| 516 uint8_t localId = sensorId; | 539 uint8_t localId = sensorId; |
| 989 else | 1012 else |
| 990 { | 1013 { |
| 991 if(cntUARTSensor != 0) | 1014 if(cntUARTSensor != 0) |
| 992 { | 1015 { |
| 993 externalInterfaceMuxReqIntervall = REQUEST_INT_SENSOR_MS / cntUARTSensor; | 1016 externalInterfaceMuxReqIntervall = REQUEST_INT_SENSOR_MS / cntUARTSensor; |
| 1017 if(foundSensorMap[0] == SENSOR_SENTINELM) /* special case: Sentinel sends combined data */ | |
| 1018 { | |
| 1019 externalInterfaceMuxReqIntervall = 4000; | |
| 1020 } | |
| 994 } | 1021 } |
| 995 } | 1022 } |
| 996 memcpy(SensorMap, foundSensorMap, sizeof(foundSensorMap)); | 1023 memcpy(SensorMap, foundSensorMap, sizeof(foundSensorMap)); |
| 997 memset(externalInterface_SensorState, UART_COMMON_INIT, sizeof(externalInterface_SensorState)); | 1024 memset(externalInterface_SensorState, UART_COMMON_INIT, sizeof(externalInterface_SensorState)); |
| 998 break; | 1025 break; |
| 1021 case EXT_INTERFACE_COPY_SENSORMAP: if(externalAutoDetect == DETECTION_OFF) | 1048 case EXT_INTERFACE_COPY_SENSORMAP: if(externalAutoDetect == DETECTION_OFF) |
| 1022 { | 1049 { |
| 1023 memcpy(SensorMap, MasterSensorMap, sizeof(MasterSensorMap)); | 1050 memcpy(SensorMap, MasterSensorMap, sizeof(MasterSensorMap)); |
| 1024 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++) | 1051 for(index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++) |
| 1025 { | 1052 { |
| 1026 if((SensorMap[index] == SENSOR_DIGO2) || (SensorMap[index] == SENSOR_CO2) || (SensorMap[index] == SENSOR_GNSS)) | 1053 if((SensorMap[index] == SENSOR_DIGO2) || (SensorMap[index] == SENSOR_CO2) || (SensorMap[index] == SENSOR_GNSS) || (SensorMap[index] == SENSOR_SENTINEL)) |
| 1027 { | 1054 { |
| 1028 cntUARTSensor++; | 1055 cntUARTSensor++; |
| 1029 } | 1056 } |
| 1030 } | 1057 } |
| 1031 externalInface_MapUartToLegacyADC(SensorMap); | 1058 externalInface_MapUartToLegacyADC(SensorMap); |
| 1032 if(cntUARTSensor > 0) | 1059 if(cntUARTSensor > 0) |
| 1033 { | 1060 { |
| 1034 externalInterfaceMuxReqIntervall = REQUEST_INT_SENSOR_MS / cntUARTSensor; | 1061 externalInterfaceMuxReqIntervall = REQUEST_INT_SENSOR_MS / cntUARTSensor; |
| 1035 activeUartChannel = 0xFF; | 1062 activeUartChannel = 0xFF; |
| 1063 | |
| 1064 if(SensorMap[0] == SENSOR_SENTINELM) /* special case: Sentinel sends compined data */ | |
| 1065 { | |
| 1066 externalInterfaceMuxReqIntervall = 4000; | |
| 1067 } | |
| 1036 } | 1068 } |
| 1037 else | 1069 else |
| 1038 { | 1070 { |
| 1039 externalInterfaceMuxReqIntervall = 0xFFFF; | 1071 externalInterfaceMuxReqIntervall = 0xFFFF; |
| 1040 } | 1072 } |
| 1164 lastRequestTick = tick; | 1196 lastRequestTick = tick; |
| 1165 TriggerTick = tick - 10; /* just to make sure control is triggered */ | 1197 TriggerTick = tick - 10; /* just to make sure control is triggered */ |
| 1166 timeToTrigger = 1; | 1198 timeToTrigger = 1; |
| 1167 retryRequest = 0; | 1199 retryRequest = 0; |
| 1168 } | 1200 } |
| 1169 else if(((retryRequest == 0) /* timeout or error */ | 1201 else if(((retryRequest == 0) && (pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET] != SENSOR_SENTINEL) /* timeout or error */ |
| 1170 && (((time_elapsed_ms(lastRequestTick,tick) > (TIMEOUT_SENSOR_ANSWER)) && (externalInterface_SensorState[activeSensorId] != UART_O2_IDLE)) /* retry if no answer after half request interval */ | 1202 && (((time_elapsed_ms(lastRequestTick,tick) > (TIMEOUT_SENSOR_ANSWER)) && (externalInterface_SensorState[activeSensorId] != UART_O2_IDLE)) /* retry if no answer after half request interval */ |
| 1171 || (externalInterface_SensorState[activeSensorId] == UART_O2_ERROR)))) | 1203 || (externalInterface_SensorState[activeSensorId] == UART_O2_ERROR)))) |
| 1172 { | 1204 { |
| 1173 /* The channel switch will cause the sensor to respond with an error message. */ | 1205 /* The channel switch will cause the sensor to respond with an error message. */ |
| 1174 /* The sensor needs ~30ms to recover before he is ready to receive the next command => transmission delay needed */ | 1206 /* The sensor needs ~30ms to recover before he is ready to receive the next command => transmission delay needed */ |
| 1187 | 1219 |
| 1188 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ | 1220 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ |
| 1189 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) | 1221 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) |
| 1190 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) | 1222 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) |
| 1191 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) | 1223 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) |
| 1192 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) | 1224 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT) |
| 1225 || (externalInterface_SensorState[activeSensorId] == UART_SENTINEL_OPERATING)) | |
| 1193 { | 1226 { |
| 1194 forceMuxChannel = 1; | 1227 forceMuxChannel = 1; |
| 1195 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; | 1228 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; |
| 1196 switch(pmap[activeSensorId]) | 1229 switch(pmap[activeSensorId]) |
| 1197 { | 1230 { |
| 1198 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); | 1231 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); |
| 1199 break; | 1232 break; |
| 1200 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); | 1233 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); |
| 1201 externalInterface_SetCO2State(0); | 1234 externalInterface_SetCO2State(0); |
| 1235 break; | |
| 1236 case SENSOR_SENTINEL: setExternalInterfaceChannel(0,0.0); | |
| 1237 setExternalInterfaceChannel(1,0.0); | |
| 1238 setExternalInterfaceChannel(2,0.0); | |
| 1239 externalInterface_SetBottlePressure(0,0); | |
| 1240 externalInterface_SetBottlePressure(1,0); | |
| 1202 break; | 1241 break; |
| 1203 default: | 1242 default: |
| 1204 break; | 1243 break; |
| 1205 } | 1244 } |
| 1206 } | 1245 } |
| 1262 default: | 1301 default: |
| 1263 break; | 1302 break; |
| 1264 } | 1303 } |
| 1265 } | 1304 } |
| 1266 } | 1305 } |
| 1267 | 1306 } |
| 1268 #if 0 | |
| 1269 #ifdef ENABLE_SENTINEL_MODE | |
| 1270 if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL)) | |
| 1271 { | |
| 1272 UART_HandleSentinelData(); | |
| 1273 } | |
| 1274 #endif | |
| 1275 #endif | |
| 1276 } |
