Mercurial > public > ostc4
comparison Discovery/Src/data_exchange_main.c @ 662:1b995079c045 Betatest
PSCR Mode
author | heinrichs weikamp |
---|---|
date | Tue, 14 Dec 2021 15:36:10 +0100 |
parents | 830de438e0b0 |
children | 52d68cf9994c |
comparison
equal
deleted
inserted
replaced
661:87bee7cc77b3 | 662:1b995079c045 |
---|---|
70 #include "tCCR.h" | 70 #include "tCCR.h" |
71 #include "timer.h" | 71 #include "timer.h" |
72 #include "buehlmann.h" | 72 #include "buehlmann.h" |
73 #include "externLogbookFlash.h" | 73 #include "externLogbookFlash.h" |
74 | 74 |
75 //#define TESTBENCH | 75 /* #define TESTBENCH */ |
76 | 76 |
77 /* Exported variables --------------------------------------------------------*/ | 77 /* Exported variables --------------------------------------------------------*/ |
78 static uint8_t wasPowerOn = 0; | 78 static uint8_t wasPowerOn = 0; |
79 static confirmbit8_Type requestNecessary = { .uw = 0 }; | 79 static confirmbit8_Type requestNecessary = { .uw = 0 }; |
80 static uint8_t wasUpdateNotPowerOn = 0; | 80 static uint8_t wasUpdateNotPowerOn = 0; |
91 static uint8_t data_old__lost_connection_to_slave_counter_temp = 0; | 91 static uint8_t data_old__lost_connection_to_slave_counter_temp = 0; |
92 static uint8_t data_old__lost_connection_to_slave_counter_retry = 0; | 92 static uint8_t data_old__lost_connection_to_slave_counter_retry = 0; |
93 static uint32_t data_old__lost_connection_to_slave_counter_total = 0; | 93 static uint32_t data_old__lost_connection_to_slave_counter_total = 0; |
94 | 94 |
95 static uint8_t DeviceDataUpdated = 0; | 95 static uint8_t DeviceDataUpdated = 0; |
96 | |
97 static uint16_t externalInterface_Cmd = 0; | |
96 | 98 |
97 /* Private types -------------------------------------------------------------*/ | 99 /* Private types -------------------------------------------------------------*/ |
98 #define UNKNOWN_TIME_HOURS 1 | 100 #define UNKNOWN_TIME_HOURS 1 |
99 #define UNKNOWN_TIME_MINUTES 0 | 101 #define UNKNOWN_TIME_MINUTES 0 |
100 #define UNKNOWN_TIME_SECOND 0 | 102 #define UNKNOWN_TIME_SECOND 0 |
179 static uint8_t setEndDiveWasSend = 0; | 181 static uint8_t setEndDiveWasSend = 0; |
180 | 182 |
181 if(getDeviceDataWasSend) | 183 if(getDeviceDataWasSend) |
182 { | 184 { |
183 dataOut.getDeviceDataNow = 0; | 185 dataOut.getDeviceDataNow = 0; |
184 requestNecessary.ub.devicedata = 1; | |
185 } | 186 } |
186 getDeviceDataWasSend = 0; | 187 getDeviceDataWasSend = 0; |
187 if(dataOut.getDeviceDataNow) | 188 if(dataOut.getDeviceDataNow) |
188 { | 189 { |
189 getDeviceDataWasSend = 1; | 190 getDeviceDataWasSend = 1; |
191 requestNecessary.ub.devicedata = 1; | |
190 } | 192 } |
191 | 193 |
192 if(setEndDiveWasSend) | 194 if(setEndDiveWasSend) |
193 { | 195 { |
194 dataOut.setEndDive = 0; | 196 dataOut.setEndDive = 0; |
201 } | 203 } |
202 | 204 |
203 if(setAccidentFlagWasSend) | 205 if(setAccidentFlagWasSend) |
204 { | 206 { |
205 dataOut.setAccidentFlag = 0; | 207 dataOut.setAccidentFlag = 0; |
206 requestNecessary.ub.accident = 1; | |
207 } | 208 } |
208 setAccidentFlagWasSend = 0; | 209 setAccidentFlagWasSend = 0; |
209 if(dataOut.setAccidentFlag) | 210 if(dataOut.setAccidentFlag) |
210 { | 211 { |
211 setAccidentFlagWasSend = 1; | 212 setAccidentFlagWasSend = 1; |
213 requestNecessary.ub.accident = 1; | |
212 } | 214 } |
213 | 215 |
214 if(setDateWasSend) | 216 if(setDateWasSend) |
215 { | 217 { |
216 dataOut.setDateNow = 0; | 218 dataOut.setDateNow = 0; |
217 requestNecessary.ub.date = 1; | |
218 } | 219 } |
219 setDateWasSend = 0; | 220 setDateWasSend = 0; |
220 if(dataOut.setDateNow) | 221 if(dataOut.setDateNow) |
221 { | 222 { |
222 setDateWasSend = 1; | 223 setDateWasSend = 1; |
224 requestNecessary.ub.date = 1; | |
223 } | 225 } |
224 | 226 |
225 if(setTimeWasSend) | 227 if(setTimeWasSend) |
226 { | 228 { |
227 dataOut.setTimeNow = 0; | 229 dataOut.setTimeNow = 0; |
228 requestNecessary.ub.time = 1; | |
229 } | 230 } |
230 setTimeWasSend = 0; | 231 setTimeWasSend = 0; |
231 if(dataOut.setTimeNow) | 232 if(dataOut.setTimeNow) |
232 { | 233 { |
233 setTimeWasSend = 1; | 234 setTimeWasSend = 1; |
235 requestNecessary.ub.time = 1; | |
234 } | 236 } |
235 | 237 |
236 if(calibrateCompassWasSend) | 238 if(calibrateCompassWasSend) |
237 { | 239 { |
238 dataOut.calibrateCompassNow = 0; | 240 dataOut.calibrateCompassNow = 0; |
239 requestNecessary.ub.compass = 1; | |
240 } | 241 } |
241 calibrateCompassWasSend = 0; | 242 calibrateCompassWasSend = 0; |
242 if(dataOut.calibrateCompassNow) | 243 if(dataOut.calibrateCompassNow) |
243 { | 244 { |
244 calibrateCompassWasSend = 1; | 245 calibrateCompassWasSend = 1; |
245 } | 246 } |
246 | 247 |
247 if(clearDecoWasSend) | 248 if(clearDecoWasSend) |
248 { | 249 { |
249 dataOut.clearDecoNow = 0; | 250 dataOut.clearDecoNow = 0; |
251 requestNecessary.ub.compass = 1; | |
252 } | |
253 if(dataOut.clearDecoNow) | |
254 { | |
255 clearDecoWasSend = 1; | |
250 requestNecessary.ub.clearDeco = 1; | 256 requestNecessary.ub.clearDeco = 1; |
251 } | 257 } |
252 if(dataOut.clearDecoNow) | |
253 { | |
254 clearDecoWasSend = 1; | |
255 } | |
256 | 258 |
257 if(setButtonSensitivityWasSend) | 259 if(setButtonSensitivityWasSend) |
258 { | 260 { |
259 dataOut.setButtonSensitivityNow = 0; | 261 dataOut.setButtonSensitivityNow = 0; |
260 requestNecessary.ub.button = 1; | |
261 } | 262 } |
262 setButtonSensitivityWasSend = 0; | 263 setButtonSensitivityWasSend = 0; |
263 if(dataOut.setButtonSensitivityNow) | 264 if(dataOut.setButtonSensitivityNow) |
264 { | 265 { |
265 setButtonSensitivityWasSend = 1; | 266 setButtonSensitivityWasSend = 1; |
267 requestNecessary.ub.button = 1; | |
266 } | 268 } |
267 } | 269 } |
268 | 270 |
269 | 271 |
270 uint8_t DataEX_call(void) | 272 uint8_t DataEX_call(void) |
386 dataOut.data.divetimeToCreateLogbook = settings->divetimeToCreateLogbook; | 388 dataOut.data.divetimeToCreateLogbook = settings->divetimeToCreateLogbook; |
387 dataOut.data.timeoutDiveReachedZeroDepth = settings->timeoutDiveReachedZeroDepth; | 389 dataOut.data.timeoutDiveReachedZeroDepth = settings->timeoutDiveReachedZeroDepth; |
388 | 390 |
389 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar; | 391 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar; |
390 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad; | 392 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad; |
393 | |
394 if(settings->co2_sensor_active) | |
395 { | |
396 externalInterface_Cmd |= EXT_INTERFACE_33V_ON; | |
397 } | |
398 dataOut.data.externalInterface_Cmd = externalInterface_Cmd; | |
399 externalInterface_Cmd = 0; | |
391 | 400 |
392 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15)))) | 401 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15)))) |
393 { | 402 { |
394 dataOut.revisionHardware = 0x00; | 403 dataOut.revisionHardware = 0x00; |
395 dataOut.revisionCRCx0x7A = 0x7A; | 404 dataOut.revisionCRCx0x7A = 0x7A; |
771 return temp; | 780 return temp; |
772 } | 781 } |
773 | 782 |
774 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) | 783 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) |
775 { | 784 { |
785 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; | |
786 | |
776 SDiveState *pStateReal = stateRealGetPointerWrite(); | 787 SDiveState *pStateReal = stateRealGetPointerWrite(); |
777 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; | |
778 uint8_t idx; | 788 uint8_t idx; |
789 float meter = 0; | |
790 SSettings *pSettings; | |
791 | |
792 | |
779 | 793 |
780 // wireless - �ltere daten aufr�umen | 794 // wireless - �ltere daten aufr�umen |
781 #if 0 | 795 #if 0 |
782 for(int i=0;i<(2*NUM_GASES+1);i++) | 796 for(int i=0;i<(2*NUM_GASES+1);i++) |
783 { | 797 { |
834 dataOut.getDeviceDataNow = 1; | 848 dataOut.getDeviceDataNow = 1; |
835 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */ | 849 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */ |
836 } | 850 } |
837 } | 851 } |
838 | 852 |
839 /* new 151207 hw */ | 853 if((requestNecessary.uw != 0) && (dataIn.confirmRequest.uw != 0)) |
840 if(requestNecessary.uw != 0) | |
841 { | 854 { |
842 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0) | 855 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0) |
843 { | 856 { |
844 requestNecessary.ub.button = 0; | 857 requestNecessary.ub.button = 0; |
845 } | 858 } |
846 | 859 if(((dataIn.confirmRequest.uw) & CRCLEARDECO) != 0) |
847 if(requestNecessary.ub.button == 1) | 860 { |
861 requestNecessary.ub.clearDeco = 0; | |
862 } | |
863 if(((dataIn.confirmRequest.uw) & CRDATE) != 0) | |
864 { | |
865 requestNecessary.ub.date = 0; | |
866 } | |
867 if(((dataIn.confirmRequest.uw) & CRTIME) != 0) | |
868 { | |
869 requestNecessary.ub.time = 0; | |
870 } | |
871 if(((dataIn.confirmRequest.uw) & CRCOMPASS) != 0) | |
872 { | |
873 requestNecessary.ub.compass = 0; | |
874 } | |
875 if(((dataIn.confirmRequest.uw) & CRDEVICEDATA) != 0) | |
876 { | |
877 requestNecessary.ub.devicedata = 0; | |
878 } | |
879 if(((dataIn.confirmRequest.uw) & CRBATTERY) != 0) | |
880 { | |
881 requestNecessary.ub.batterygauge = 0; | |
882 } | |
883 if(((dataIn.confirmRequest.uw) & CRACCIDENT) != 0) | |
884 { | |
885 requestNecessary.ub.accident = 0; | |
886 } | |
887 | |
888 if(requestNecessary.ub.button == 1) /* send button values to RTE */ | |
848 { | 889 { |
849 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | 890 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); |
850 } | 891 } |
851 } | 892 } |
852 requestNecessary.uw = 0; // clear all | |
853 | |
854 float meter = 0; | |
855 SSettings *pSettings; | |
856 | 893 |
857 /* uint8_t IAmStolenPleaseKillMe; | 894 /* uint8_t IAmStolenPleaseKillMe; |
858 */ | 895 */ |
859 pSettings = settingsGetPointer(); | 896 pSettings = settingsGetPointer(); |
860 | 897 |
907 pStateReal->pressure_uTick_local_new = HAL_GetTick(); | 944 pStateReal->pressure_uTick_local_new = HAL_GetTick(); |
908 | 945 |
909 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; | 946 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; |
910 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; | 947 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; |
911 } | 948 } |
912 dataOut.setAccidentFlag = 0; | |
913 | 949 |
914 if(pStateReal->data_old__lost_connection_to_slave == 0) | 950 if(pStateReal->data_old__lost_connection_to_slave == 0) |
915 { | 951 { |
916 //Start of diveMode? | 952 //Start of diveMode? |
917 if(pStateReal->mode != MODE_DIVE && dataIn.mode == MODE_DIVE) | 953 if(pStateReal->mode != MODE_DIVE && dataIn.mode == MODE_DIVE) |
969 { | 1005 { |
970 if(meter > pStateReal->lifeData.max_depth_meter) | 1006 if(meter > pStateReal->lifeData.max_depth_meter) |
971 pStateReal->lifeData.max_depth_meter = meter; | 1007 pStateReal->lifeData.max_depth_meter = meter; |
972 } | 1008 } |
973 | 1009 |
974 if(dataIn.accidentFlags & ACCIDENT_DECOSTOP) | 1010 if(requestNecessary.ub.clearDeco == 0) /* No "reset deco" is send to RTE ? */ |
975 pStateReal->decoMissed_at_the_end_of_dive = 1; | 1011 { |
976 if(dataIn.accidentFlags & ACCIDENT_CNS) | 1012 if(dataIn.accidentFlags & ACCIDENT_DECOSTOP) |
977 pStateReal->cnsHigh_at_the_end_of_dive = 1; | 1013 { |
978 | 1014 pStateReal->decoMissed_at_the_end_of_dive = 1; |
1015 } | |
1016 else | |
1017 { | |
1018 pStateReal->decoMissed_at_the_end_of_dive = 0; | |
1019 } | |
1020 if(dataIn.accidentFlags & ACCIDENT_CNS) | |
1021 { | |
1022 pStateReal->cnsHigh_at_the_end_of_dive = 1; | |
1023 } | |
1024 else | |
1025 { | |
1026 pStateReal->cnsHigh_at_the_end_of_dive = 0; | |
1027 } | |
1028 } | |
979 pStateReal->lifeData.dive_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].divetime_seconds; | 1029 pStateReal->lifeData.dive_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].divetime_seconds; |
980 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time; | 1030 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time; |
981 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth; | 1031 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth; |
982 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds; | 1032 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds; |
983 | 1033 |
1028 } | 1078 } |
1029 | 1079 |
1030 /* sensorErrors | 1080 /* sensorErrors |
1031 */ | 1081 */ |
1032 pStateReal->sensorErrorsRTE = dataIn.sensorErrors; | 1082 pStateReal->sensorErrorsRTE = dataIn.sensorErrors; |
1083 | |
1084 /* data from CO2 sensor */ | |
1085 pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[0].CO2_ppm; | |
1086 pStateReal->lifeData.CO2_data.signalStrength = dataIn.data[0].CO2_signalStrength; | |
1033 } | 1087 } |
1034 | 1088 |
1035 /* apnea specials | 1089 /* apnea specials |
1036 */ | 1090 */ |
1037 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) | 1091 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) |
1203 uint8_t retval; | 1257 uint8_t retval; |
1204 retval = hw_Info.extADC; | 1258 retval = hw_Info.extADC; |
1205 | 1259 |
1206 return retval; | 1260 return retval; |
1207 } | 1261 } |
1262 | |
1263 void DataEX_setExtInterface_Cmd(uint16_t Cmd) | |
1264 { | |
1265 externalInterface_Cmd = Cmd; | |
1266 return; | |
1267 } | |
1268 |