Mercurial > public > ostc4
annotate Discovery/Src/data_exchange_main.c @ 953:d565812061f4 Evo_2_23
Bugfix ascent graph in simulator:
The ascent graph in simulator mode was not show if a depth < 5m was reached. Rootcause was a wrong source for current depth. This has be fixed now.
author | Ideenmodellierer |
---|---|
date | Wed, 01 Jan 2025 17:28:36 +0100 |
parents | e9c37071933b |
children | 3420e3ba698d |
rev | line source |
---|---|
38 | 1 /** |
2 ****************************************************************************** | |
3 * @file data_exchange_main.c | |
4 * @author heinrichs weikamp gmbh | |
5 * @date 13-Oct-2014 | |
6 * @version V0.0.3 | |
7 * @since 17-Feb-2016 | |
8 | |
9 * @brief Communication with the second CPU == RTE system | |
10 * | |
11 @verbatim | |
12 ============================================================================== | |
13 ##### Version Changes ##### | |
14 ============================================================================== | |
15 160217 V0.0.3 pStateUsed->decolistXXXXX.tickstamp = HAL_GetTick(); added | |
16 150627 V0.0.2 | |
17 | |
18 ============================================================================== | |
19 ##### How to use ##### | |
20 ============================================================================== | |
21 | |
22 ============================================================================== | |
23 ##### Button, Set Time, Clear Deco etc Request ##### | |
24 ============================================================================== | |
25 was updated (151207) for buttons and clear deco at the moment only | |
26 using requestNecessary and checking in DataEX_copy_to_LifeData() | |
27 Hence if there is no confirm from the smallCPU on the data after the request | |
28 the request will be send again. | |
29 | |
30 ============================================================================== | |
31 ##### Device Data ##### | |
32 ============================================================================== | |
33 | |
34 main CPU always sends the device data info that it has at the moment | |
35 | |
36 on start it is INT32_MIN, INT32_MAX and 0 | |
37 as initialized in data_central.c variable declaration | |
38 | |
39 second small CPU gets request to send its device data | |
40 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
41 on reception the data is merged with the data in externLogbookFlash, |
38 | 42 stored on the externLogbookFlash and from now on send to small CPU |
43 | |
44 ============================================================================== | |
45 ##### Magnet Reset ##### | |
46 ============================================================================== | |
47 | |
48 @endverbatim | |
49 ****************************************************************************** | |
50 * @attention | |
51 * | |
52 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
53 * | |
54 ****************************************************************************** | |
55 */ | |
56 | |
57 /* Includes ------------------------------------------------------------------*/ | |
133
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
58 #include <stdlib.h> |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
59 #include <string.h> // for memcpy |
747
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
60 #include <math.h> |
38 | 61 #include "stm32f4xx_hal.h" |
62 #include "stdio.h" | |
63 #include "ostc.h" | |
64 #include "settings.h" | |
65 #include "data_central.h" | |
66 #include "data_exchange_main.h" | |
67 #include "base.h" | |
68 #include "decom.h" | |
69 #include "calc_crush.h" /* for vpm_init */ | |
70 #include "simulation.h" | |
71 #include "tCCR.h" | |
72 #include "timer.h" | |
73 #include "buehlmann.h" | |
74 #include "externLogbookFlash.h" | |
911 | 75 #include "vpm.h" |
951 | 76 #include "check_warning.h" |
38 | 77 |
662 | 78 /* #define TESTBENCH */ |
38 | 79 |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
80 /* Exported variables --------------------------------------------------------*/ |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
81 static uint8_t wasPowerOn = 0; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
82 static confirmbit8_Type requestNecessary = { .uw = 0 }; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
83 static uint8_t wasUpdateNotPowerOn = 0; |
38 | 84 |
85 /* Private variables with external access ------------------------------------*/ | |
86 | |
87 /* Private variables ---------------------------------------------------------*/ | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
88 static uint8_t told_reset_logik_alles_ok = 0; |
559 | 89 static hw_Info_t hw_Info; |
38 | 90 |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
91 static SDataReceiveFromMaster dataOut; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
92 static SDataExchangeSlaveToMaster dataIn; |
38 | 93 |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
94 static uint8_t data_old__lost_connection_to_slave_counter_temp = 0; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
95 static uint8_t data_old__lost_connection_to_slave_counter_retry = 0; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
96 static uint32_t data_old__lost_connection_to_slave_counter_total = 0; |
38 | 97 |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
98 static uint8_t DeviceDataUpdated = 0; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
99 |
662 | 100 static uint16_t externalInterface_Cmd = 0; |
101 | |
38 | 102 /* Private types -------------------------------------------------------------*/ |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
103 #define UNKNOWN_TIME_HOURS 1 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
104 #define UNKNOWN_TIME_MINUTES 0 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
105 #define UNKNOWN_TIME_SECOND 0 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
106 #define UNKNOWN_DATE_DAY 1 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
107 #define UNKNOWN_DATE_MONTH 1 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
108 #define UNKNOWN_DATE_YEAR 16 |
38 | 109 |
577
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
110 |
38 | 111 /* Private function prototypes -----------------------------------------------*/ |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
112 static uint8_t DataEX_check_header_and_footer_ok(void); |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
113 static uint8_t DataEX_check_header_and_footer_shifted(void); |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
114 static uint8_t DataEX_check_header_and_footer_devicedata(void); |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
115 static void DataEX_check_DeviceData(void); |
38 | 116 |
117 /* Exported functions --------------------------------------------------------*/ | |
118 uint8_t DataEX_was_power_on(void) | |
119 { | |
120 return wasPowerOn; | |
121 } | |
122 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
123 static uint8_t count_DataEX_Error_Handler = 0; |
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
124 static uint8_t last_error_DataEX_Error_Handler = 0; |
38 | 125 |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
126 static void DataEX_Error_Handler(uint8_t answer) |
38 | 127 { |
128 count_DataEX_Error_Handler++; | |
129 last_error_DataEX_Error_Handler = answer; | |
133
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
130 |
156
1fbdb45db701
Removed special indicator for DMA transfer error
Ideenmodellierer
parents:
154
diff
changeset
|
131 /* A wrong footer indicates a communication interrupt. State machine is waiting for new data which is not received because no new transmission is triggered */ |
133
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
132 /* ==> Abort data exchange to enable a new RX / TX cycle */ |
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
133 if(answer == HAL_BUSY) |
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
134 { |
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
135 HAL_SPI_Abort_IT(&cpu2DmaSpi); |
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
136 } |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
137 |
38 | 138 return; |
139 } | |
140 | |
141 | |
142 uint32_t DataEX_lost_connection_count(void) | |
143 { | |
144 return data_old__lost_connection_to_slave_counter_total; | |
145 } | |
146 | |
147 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
148 SDataReceiveFromMaster *dataOutGetPointer(void) |
38 | 149 { |
150 return &dataOut; | |
151 } | |
152 | |
153 void DataEX_init(void) | |
154 { | |
155 SDiveState * pStateReal = stateRealGetPointerWrite(); | |
99 | 156 pStateReal->data_old__lost_connection_to_slave = 0; //initial value |
38 | 157 data_old__lost_connection_to_slave_counter_temp = 0; |
158 data_old__lost_connection_to_slave_counter_total = 0; | |
407
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
159 DeviceDataUpdated = 0; |
38 | 160 |
161 memset((void *)&dataOut, 0, sizeof(SDataReceiveFromMaster)); | |
162 | |
163 dataOut.header.checkCode[0] = 0xBB; | |
208 | 164 dataOut.header.checkCode[1] = SPI_RX_STATE_OK; |
165 dataOut.header.checkCode[2] = SPI_RX_STATE_OK; | |
38 | 166 dataOut.header.checkCode[3] = 0xBB; |
167 | |
168 dataOut.footer.checkCode[0] = 0xF4; | |
169 dataOut.footer.checkCode[1] = 0xF3; | |
170 dataOut.footer.checkCode[2] = 0xF2; | |
171 dataOut.footer.checkCode[3] = 0xF1; | |
172 } | |
173 | |
174 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
175 static void DataEx_call_helper_requests(void) |
38 | 176 { |
177 static uint8_t setDateWasSend = 0; | |
178 static uint8_t setTimeWasSend = 0; | |
179 static uint8_t calibrateCompassWasSend = 0; | |
180 static uint8_t setButtonSensitivityWasSend = 0; | |
181 static uint8_t clearDecoWasSend = 0; | |
182 static uint8_t getDeviceDataWasSend = 0; | |
183 static uint8_t setAccidentFlagWasSend = 0; | |
184 static uint8_t setEndDiveWasSend = 0; | |
185 | |
186 if(getDeviceDataWasSend) | |
187 { | |
188 dataOut.getDeviceDataNow = 0; | |
189 } | |
190 getDeviceDataWasSend = 0; | |
191 if(dataOut.getDeviceDataNow) | |
192 { | |
193 getDeviceDataWasSend = 1; | |
662 | 194 requestNecessary.ub.devicedata = 1; |
38 | 195 } |
196 | |
197 if(setEndDiveWasSend) | |
198 { | |
199 dataOut.setEndDive = 0; | |
200 //requestNecessary.ub.XXX = 1; not implemented and no space here | |
201 } | |
202 setEndDiveWasSend = 0; | |
203 if(dataOut.setEndDive) | |
204 { | |
205 setEndDiveWasSend = 1; | |
206 } | |
207 | |
208 if(setAccidentFlagWasSend) | |
209 { | |
210 dataOut.setAccidentFlag = 0; | |
211 } | |
212 setAccidentFlagWasSend = 0; | |
213 if(dataOut.setAccidentFlag) | |
214 { | |
215 setAccidentFlagWasSend = 1; | |
662 | 216 requestNecessary.ub.accident = 1; |
38 | 217 } |
218 | |
219 if(setDateWasSend) | |
220 { | |
221 dataOut.setDateNow = 0; | |
222 } | |
223 setDateWasSend = 0; | |
224 if(dataOut.setDateNow) | |
225 { | |
226 setDateWasSend = 1; | |
662 | 227 requestNecessary.ub.date = 1; |
38 | 228 } |
229 | |
230 if(setTimeWasSend) | |
231 { | |
232 dataOut.setTimeNow = 0; | |
233 } | |
234 setTimeWasSend = 0; | |
235 if(dataOut.setTimeNow) | |
236 { | |
237 setTimeWasSend = 1; | |
662 | 238 requestNecessary.ub.time = 1; |
38 | 239 } |
240 | |
241 if(calibrateCompassWasSend) | |
242 { | |
243 dataOut.calibrateCompassNow = 0; | |
244 } | |
245 calibrateCompassWasSend = 0; | |
246 if(dataOut.calibrateCompassNow) | |
247 { | |
248 calibrateCompassWasSend = 1; | |
249 } | |
250 | |
251 if(clearDecoWasSend) | |
252 { | |
253 dataOut.clearDecoNow = 0; | |
662 | 254 requestNecessary.ub.compass = 1; |
38 | 255 } |
256 if(dataOut.clearDecoNow) | |
257 { | |
258 clearDecoWasSend = 1; | |
662 | 259 requestNecessary.ub.clearDeco = 1; |
38 | 260 } |
261 | |
262 if(setButtonSensitivityWasSend) | |
263 { | |
264 dataOut.setButtonSensitivityNow = 0; | |
265 } | |
266 setButtonSensitivityWasSend = 0; | |
267 if(dataOut.setButtonSensitivityNow) | |
268 { | |
269 setButtonSensitivityWasSend = 1; | |
662 | 270 requestNecessary.ub.button = 1; |
38 | 271 } |
272 } | |
273 | |
274 | |
275 uint8_t DataEX_call(void) | |
276 { | |
208 | 277 static uint32_t RTEOfflineCnt = 0; |
278 static uint8_t SusppressCom = 0; | |
279 | |
38 | 280 uint8_t SPI_DMA_answer = 0; |
141 | 281 |
208 | 282 if(SusppressCom) |
38 | 283 { |
208 | 284 SusppressCom--; |
38 | 285 } |
149 | 286 else |
287 { | |
763
aa6006975e76
increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents:
747
diff
changeset
|
288 if(data_old__lost_connection_to_slave_counter_temp >= 2) /* error reaction is triggered whenever communication could not be reestablished within two cycles */ |
208 | 289 { |
290 data_old__lost_connection_to_slave_counter_temp = 0; | |
291 if(DataEX_check_header_and_footer_shifted()) | |
292 { | |
293 if(RTEOfflineCnt > 1) /* RTE restarted communication after a longer silent time => restart error handling to recover */ | |
294 { | |
295 data_old__lost_connection_to_slave_counter_retry = 0; | |
296 RTEOfflineCnt = 0; | |
297 } | |
38 | 298 |
208 | 299 /* We received shifted data. Step one. Reset DMA to see if the problem is located at main */ |
300 if (data_old__lost_connection_to_slave_counter_retry == 0) | |
301 { | |
302 HAL_SPI_Abort_IT(&cpu2DmaSpi); | |
303 } | |
763
aa6006975e76
increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents:
747
diff
changeset
|
304 /* reset of own DMA does not work ==> request reset of slave dma by indicating shifted reception */ |
208 | 305 if (data_old__lost_connection_to_slave_counter_retry == 1) |
306 { | |
307 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_SHIFTED; | |
308 } | |
309 | |
310 /* stop communication with RTE to trigger RTE timeout reaction */ | |
311 if (data_old__lost_connection_to_slave_counter_retry == 2) | |
312 { | |
313 SusppressCom = 3; | |
314 } | |
38 | 315 |
208 | 316 data_old__lost_connection_to_slave_counter_retry++; |
317 } | |
318 else | |
319 { | |
320 RTEOfflineCnt++; /* based on footer status the RTE does not seem to provide data in time */ | |
321 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OFFLINE; | |
322 } | |
323 } | |
324 #if USE_OLD_SYNC_METHOD | |
325 /* one cycle with NotChipSelect true to clear slave spi buffer */ | |
326 else | |
327 { | |
328 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET); | |
329 } | |
330 #endif | |
133
acc98f5bd8c4
Intoduced transfer abort function for data exchange recovery
Ideenmodellierer
parents:
115
diff
changeset
|
331 |
208 | 332 DataEx_call_helper_requests(); |
333 | |
334 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */ | |
335 | |
336 if(SusppressCom == 0) | |
337 { | |
338 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET); | |
339 | |
340 SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE); | |
341 if(SPI_DMA_answer != HAL_OK) | |
342 { | |
343 DataEX_Error_Handler(SPI_DMA_answer); | |
344 } | |
345 } | |
346 } | |
104 | 347 // HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); |
38 | 348 //HAL_Delay(3); |
349 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_SET); /* only for testing with Oscilloscope */ | |
350 | |
351 return 1; | |
352 } | |
353 | |
82 | 354 |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
355 static uint32_t SPI_CALLBACKS; |
82 | 356 uint32_t get_num_SPI_CALLBACKS(void){ |
357 return SPI_CALLBACKS; | |
358 } | |
359 | |
360 SDataExchangeSlaveToMaster* get_dataInPointer(void){ | |
361 return &dataIn; | |
362 } | |
363 | |
364 void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) | |
365 { | |
366 if(hspi == &cpu2DmaSpi) | |
367 { | |
154 | 368 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); |
82 | 369 SPI_CALLBACKS+=1; |
370 } | |
371 } | |
372 | |
373 | |
38 | 374 void DateEx_copy_to_dataOut(void) |
375 { | |
376 const SDiveState * pStateReal = stateRealGetPointer(); | |
377 SSettings *settings = settingsGetPointer(); | |
378 | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
379 uint8_t SensorActive[SENSOR_END]; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
380 uint8_t index = 0; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
381 |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
382 |
38 | 383 if(get_globalState() == StStop) |
384 dataOut.mode = MODE_SHUTDOWN; | |
385 else | |
386 dataOut.mode = 0; | |
387 | |
388 dataOut.diveModeInfo = pStateReal->diveSettings.diveMode; // hw 170215 | |
389 | |
390 memcpy(&dataOut.data.DeviceData, stateDeviceGetPointer(), sizeof(SDevice)); | |
391 | |
392 dataOut.data.VPMconservatism = pStateReal->diveSettings.vpm_conservatism; | |
393 dataOut.data.actualGas = pStateReal->lifeData.actualGas; | |
394 dataOut.data.ambient_pressure_mbar_ceiling = (pStateReal->decolistBuehlmann.output_ceiling_meter * 100) + (pStateReal->lifeData.pressure_surface_bar * 1000); | |
395 dataOut.data.divetimeToCreateLogbook = settings->divetimeToCreateLogbook; | |
396 dataOut.data.timeoutDiveReachedZeroDepth = settings->timeoutDiveReachedZeroDepth; | |
397 | |
398 dataOut.data.offsetPressureSensor_mbar = settings->offsetPressure_mbar; | |
399 dataOut.data.offsetTemperatureSensor_centiDegree = settings->offsetTemperature_centigrad; | |
400 | |
691 | 401 |
796 | 402 memcpy(dataOut.data.externalInterface_SensorMap, settings->ext_sensor_map, EXT_INTERFACE_SENSOR_CNT); |
691 | 403 |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
404 memset(SensorActive, 0, sizeof(SensorActive)); |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
405 for (index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++) |
691 | 406 { |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
407 switch(settings->ext_sensor_map[index]) |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
408 { |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
409 case SENSOR_ANALOG: SensorActive[SENSOR_ANALOG] = 1; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
410 break; |
796 | 411 case SENSOR_DIGO2M: SensorActive[SENSOR_DIGO2] = 1; |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
412 break; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
413 case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
414 break; |
927 | 415 #if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT |
920 | 416 case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1; |
417 break; | |
418 #endif | |
747
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
419 #ifdef ENABLE_SENTINEL_MODE |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
420 case SENSOR_SENTINEL: SensorActive[SENSOR_SENTINEL] = 1; |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
421 break; |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
422 #endif |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
423 default: |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
424 break; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
425 } |
691 | 426 } |
427 | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
428 if(SensorActive[SENSOR_ANALOG]) |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
429 { |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
430 externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
431 } |
920 | 432 if((SensorActive[SENSOR_DIGO2]) || (SensorActive[SENSOR_CO2])|| (SensorActive[SENSOR_GNSS])) |
702
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
433 { |
839 | 434 externalInterface_Cmd |= EXT_INTERFACE_33V_ON; |
702
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
435 } |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
436 |
691 | 437 #ifdef ENABLE_SENTINEL_MODE |
747
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
438 if(SensorActive[SENSOR_SENTINEL]) |
691 | 439 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
839
diff
changeset
|
440 externalInterface_Cmd |= EXT_INTERFACE_33V_ON; |
691 | 441 externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON); |
442 } | |
443 #endif | |
444 | |
951 | 445 #ifdef ENABLE_GPIO_V2 |
446 if(getBuzzerActivationState()) | |
447 { | |
448 externalInterface_Cmd |= EXT_INTERFACE_BUZZER_ON; | |
449 } | |
450 #endif | |
451 | |
662 | 452 dataOut.data.externalInterface_Cmd = externalInterface_Cmd; |
453 externalInterface_Cmd = 0; | |
454 | |
38 | 455 if((hardwareDataGetPointer()->primarySerial <= 32) || (((hardwareDataGetPointer()->primarySerial == 72) && (hardwareDataGetPointer()->secondarySerial == 15)))) |
456 { | |
457 dataOut.revisionHardware = 0x00; | |
458 dataOut.revisionCRCx0x7A = 0x7A; | |
459 } | |
460 else | |
461 if(hardwareDataGetPointer()->primarySerial < 0xFFFF) | |
462 { | |
463 dataOut.revisionHardware = hardwareDataGetPointer()->revision8bit; | |
464 dataOut.revisionCRCx0x7A = hardwareDataGetPointer()->revision8bit ^ 0x7A; | |
465 } | |
466 else | |
467 { | |
468 dataOut.revisionHardware = 0xFF; | |
469 dataOut.revisionCRCx0x7A = 0xFF; | |
470 } | |
471 | |
472 if(DataEX_check_header_and_footer_ok() && !told_reset_logik_alles_ok) | |
473 { | |
474 MX_tell_reset_logik_alles_ok(); | |
475 told_reset_logik_alles_ok = 1; | |
476 } | |
477 | |
478 if(DataEX_check_header_and_footer_ok() && (dataIn.power_on_reset == 1)) | |
479 { | |
480 if(!wasUpdateNotPowerOn) | |
481 wasPowerOn = 1; | |
482 | |
483 settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness); | |
484 setButtonResponsiveness(settings->ButtonResponsiveness); | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
716
diff
changeset
|
485 DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP); |
38 | 486 } |
487 } | |
488 | |
489 | |
490 void DataEX_copy_to_deco(void) | |
491 { | |
492 if(decoLock == DECO_CALC_running) | |
493 return; | |
494 | |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
495 if(decoLock == DECO_CALC_init_as_is_start_of_dive) |
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
496 { |
907 | 497 vpm_table_init(); |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
498 vpm_init(&stateUsedWrite->vpm, stateUsedWrite->diveSettings.vpm_conservatism, 0, 0); |
38 | 499 buehlmann_init(); |
500 timer_init(); | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
501 resetEvents(stateUsedWrite); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
502 stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
503 } |
38 | 504 |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
505 if(decoLock == DECO_CALC_FINSHED_Buehlmann) |
38 | 506 { |
507 | |
508 } | |
509 switch(decoLock) | |
510 { | |
511 | |
512 //Deco_calculation finished | |
513 case DECO_CALC_FINSHED_vpm: | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
514 memcpy(&stateUsedWrite->decolistVPM,&stateDeco.decolistVPM,sizeof(SDecoinfo)); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
515 stateUsedWrite->decolistVPM.tickstamp = HAL_GetTick(); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
516 stateUsedWrite->vpm.deco_zone_reached = stateDeco.vpm.deco_zone_reached; |
38 | 517 for(int i = 0; i< 16; i++) |
518 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
519 stateUsedWrite->vpm.adjusted_critical_radius_he[i] = stateDeco.vpm.adjusted_critical_radius_he[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
520 stateUsedWrite->vpm.adjusted_critical_radius_n2[i] = stateDeco.vpm.adjusted_critical_radius_n2[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
521 stateUsedWrite->vpm.adjusted_crushing_pressure_he[i] = stateDeco.vpm.adjusted_crushing_pressure_he[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
522 stateUsedWrite->vpm.adjusted_crushing_pressure_n2[i] = stateDeco.vpm.adjusted_crushing_pressure_n2[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
523 stateUsedWrite->vpm.initial_allowable_gradient_he[i] = stateDeco.vpm.initial_allowable_gradient_he[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
524 stateUsedWrite->vpm.initial_allowable_gradient_n2[i] = stateDeco.vpm.initial_allowable_gradient_n2[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
525 stateUsedWrite->vpm.max_actual_gradient[i] = stateDeco.vpm.max_actual_gradient[i]; |
38 | 526 } |
527 break; | |
528 case DECO_CALC_FINSHED_Buehlmann: | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
529 memcpy(&stateUsedWrite->decolistBuehlmann,&stateDeco.decolistBuehlmann,sizeof(SDecoinfo)); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
530 stateUsedWrite->decolistBuehlmann.tickstamp = HAL_GetTick(); |
38 | 531 //Copy Data to be stored if regular Buehlmann, not FutureBuehlmann |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
532 stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = stateDeco.diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero; |
38 | 533 break; |
534 case DECO_CALC_FINSHED_FutureBuehlmann: | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
535 memcpy(&stateUsedWrite->decolistFutureBuehlmann,&stateDeco.decolistFutureBuehlmann,sizeof(SDecoinfo)); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
536 stateUsedWrite->decolistFutureBuehlmann.tickstamp = HAL_GetTick(); |
38 | 537 break; |
538 case DECO_CALC_FINSHED_Futurevpm: | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
539 memcpy(&stateUsedWrite->decolistFutureVPM,&stateDeco.decolistFutureVPM,sizeof(SDecoinfo)); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
540 stateUsedWrite->decolistFutureVPM.tickstamp = HAL_GetTick(); |
38 | 541 break; |
542 } | |
543 | |
544 //Copy Inputdata from stateReal to stateDeco | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
545 memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData)); |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
546 memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings)); |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
547 memcpy(&stateDeco.decolistVPM,&stateUsedWrite->decolistVPM,sizeof(SDecoinfo)); |
38 | 548 |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
549 stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached; |
38 | 550 // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm)); |
551 for(int i = 0; i< 16; i++) | |
552 { | |
288
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
553 stateDeco.vpm.max_crushing_pressure_he[i] = stateUsedWrite->vpm.max_crushing_pressure_he[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
554 stateDeco.vpm.max_crushing_pressure_n2[i] = stateUsedWrite->vpm.max_crushing_pressure_n2[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
555 stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i]; |
ba229a012ac7
cleanup: no useless checks for simulator state
Jan Mulder <jlmulder@xs4all.nl>
parents:
278
diff
changeset
|
556 stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i]; |
38 | 557 } |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
558 decoLock = DECO_CALC_ready; |
38 | 559 } |
560 | |
561 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
562 static void DataEX_helper_copy_deviceData(SDeviceLine *lineWrite, const SDeviceLine *lineRead) |
38 | 563 { |
564 lineWrite->date_rtc_dr = lineRead->date_rtc_dr; | |
565 lineWrite->time_rtc_tr = lineRead->time_rtc_tr; | |
566 lineWrite->value_int32 = lineRead->value_int32; | |
567 } | |
568 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
569 static void DataEX_helper_SetTime(RTC_TimeTypeDef inStimestructure, uint32_t *outTimetmpreg) |
38 | 570 { |
571 inStimestructure.TimeFormat = RTC_HOURFORMAT_24; | |
572 | |
573 *outTimetmpreg = (uint32_t)(((uint32_t)RTC_ByteToBcd2(inStimestructure.Hours) << 16U) | \ | |
574 ((uint32_t)RTC_ByteToBcd2(inStimestructure.Minutes) << 8U) | \ | |
575 ((uint32_t)RTC_ByteToBcd2(inStimestructure.Seconds)) | \ | |
576 (((uint32_t)inStimestructure.TimeFormat) << 16U)); | |
577 } | |
578 | |
579 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
580 static void DataEX_helper_SetDate(RTC_DateTypeDef inSdatestructure, uint32_t *outDatetmpreg) |
38 | 581 { |
582 *outDatetmpreg = (((uint32_t)RTC_ByteToBcd2(inSdatestructure.Year) << 16U) | \ | |
583 ((uint32_t)RTC_ByteToBcd2(inSdatestructure.Month) << 8U) | \ | |
584 ((uint32_t)RTC_ByteToBcd2(inSdatestructure.Date)) | \ | |
585 ((uint32_t)inSdatestructure.WeekDay << 13U)); | |
586 } | |
587 | |
588 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
589 static void DataEX_helper_set_Unknown_Date_deviceData(SDeviceLine *lineWrite) |
38 | 590 { |
591 RTC_DateTypeDef sdatestructure; | |
592 RTC_TimeTypeDef stimestructure; | |
593 | |
951 | 594 const SFirmwareData *pFirmwareInfo; |
595 pFirmwareInfo = firmwareDataGetPointer(); | |
596 | |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
597 stimestructure.Hours = UNKNOWN_TIME_HOURS; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
598 stimestructure.Minutes = UNKNOWN_TIME_MINUTES; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
599 stimestructure.Seconds = UNKNOWN_TIME_SECOND; |
38 | 600 |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
601 sdatestructure.Date = UNKNOWN_DATE_DAY; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
602 sdatestructure.Month = UNKNOWN_DATE_MONTH; |
951 | 603 sdatestructure.Year = pFirmwareInfo->release_year; |
38 | 604 setWeekday(&sdatestructure); |
605 | |
606 DataEX_helper_SetTime(stimestructure, &lineWrite->time_rtc_tr); | |
607 DataEX_helper_SetDate(sdatestructure, &lineWrite->date_rtc_dr); | |
608 } | |
609 | |
610 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
611 static uint8_t DataEX_helper_Check_And_Correct_Date_deviceData(SDeviceLine *lineWrite) |
38 | 612 { |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
613 uint8_t retval = 0; |
38 | 614 RTC_DateTypeDef sdatestructure; |
615 RTC_TimeTypeDef stimestructure; | |
616 | |
617 // from lineWrite to structure | |
618 translateDate(lineWrite->date_rtc_dr, &sdatestructure); | |
619 translateTime(lineWrite->time_rtc_tr, &stimestructure); | |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
620 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
621 /* Check if date is out of range */ |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
622 if(!( (sdatestructure.Year >= 15) |
38 | 623 && (sdatestructure.Year <= 30) |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
624 && (sdatestructure.Month <= 12))) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
625 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
626 DataEX_helper_set_Unknown_Date_deviceData(lineWrite); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
627 retval = 1; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
628 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
629 return retval; |
38 | 630 } |
631 | |
632 | |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
633 static uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to, uint8_t defaulttofrom) |
38 | 634 { |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
635 uint8_t retval = 0; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
636 RTC_DateTypeDef sdatestructure; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
637 |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
638 /* Is value out of valid range? */ |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
639 if(!(lineWrite->value_int32 >= from && lineWrite->value_int32 <= to)) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
640 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
641 if(defaulttofrom) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
642 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
643 lineWrite->value_int32 = from; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
644 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
645 else |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
646 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
647 lineWrite->value_int32 = to; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
648 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
649 DataEX_helper_set_Unknown_Date_deviceData(lineWrite); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
650 } |
38 | 651 |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
652 /* This is just a repair function to restore metric if a corruption occurred in an older fw version */ |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
653 if(((lineWrite->value_int32 == to) && defaulttofrom ) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
654 || ((lineWrite->value_int32 == from) && !defaulttofrom )) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
655 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
656 translateDate(lineWrite->date_rtc_dr, &sdatestructure); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
657 if(sdatestructure.Year == UNKNOWN_DATE_YEAR) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
658 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
659 if(defaulttofrom) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
660 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
661 lineWrite->value_int32 = from; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
662 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
663 else |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
664 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
665 lineWrite->value_int32 = to; |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
666 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
667 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
668 } |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
669 return retval; |
38 | 670 } |
671 | |
672 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
673 static void DataEX_check_DeviceData(void) |
38 | 674 { |
675 SDevice *DeviceData = stateDeviceGetPointerWrite(); | |
676 | |
677 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->batteryChargeCompleteCycles); | |
678 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->batteryChargeCycles); | |
679 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->depthMaximum); | |
680 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->diveCycles); | |
681 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->hoursOfOperation); | |
682 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->temperatureMaximum); | |
683 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->temperatureMinimum); | |
684 DataEX_helper_Check_And_Correct_Date_deviceData(&DeviceData->voltageMinimum); | |
685 | |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
686 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->batteryChargeCompleteCycles, 0, 10000,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
687 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->batteryChargeCycles, 0, 20000,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
688 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->depthMaximum, 0, (500*100)+1000,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
689 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->diveCycles, 0, 20000,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
690 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->hoursOfOperation, 0, 1000000,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
691 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->temperatureMaximum, -30*100, 150*100,1); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
692 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->temperatureMinimum, -30*100, 150*100,0); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
693 DataEX_helper_Check_And_Correct_Value_deviceData(&DeviceData->voltageMinimum, 2*1000, 6*1000,0); |
38 | 694 } |
695 | |
696 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
697 static void DataEX_merge_DeviceData_and_store(void) |
38 | 698 { |
699 uint16_t dataLengthRead; | |
700 SDevice DeviceDataFlash; | |
701 SDevice *DeviceData = stateDeviceGetPointerWrite(); | |
702 | |
703 dataLengthRead = ext_flash_read_devicedata((uint8_t *)&DeviceDataFlash,sizeof(SDevice)); | |
704 | |
705 if(dataLengthRead == 0) | |
706 { | |
421
3f7d80f37bfc
Enable sequentionel writing of device data:
ideenmodellierer
parents:
407
diff
changeset
|
707 ext_flash_write_devicedata(false); |
38 | 708 return; |
709 } | |
710 | |
711 /* max values */ | |
712 if(DeviceData->batteryChargeCompleteCycles.value_int32 < DeviceDataFlash.batteryChargeCompleteCycles.value_int32) | |
713 { | |
714 DataEX_helper_copy_deviceData(&DeviceData->batteryChargeCompleteCycles, &DeviceDataFlash.batteryChargeCompleteCycles); | |
715 } | |
716 if(DeviceData->batteryChargeCycles.value_int32 < DeviceDataFlash.batteryChargeCycles.value_int32) | |
717 { | |
718 DataEX_helper_copy_deviceData(&DeviceData->batteryChargeCycles, &DeviceDataFlash.batteryChargeCycles); | |
719 } | |
720 if(DeviceData->temperatureMaximum.value_int32 < DeviceDataFlash.temperatureMaximum.value_int32) | |
721 { | |
722 DataEX_helper_copy_deviceData(&DeviceData->temperatureMaximum, &DeviceDataFlash.temperatureMaximum); | |
723 } | |
724 if(DeviceData->depthMaximum.value_int32 < DeviceDataFlash.depthMaximum.value_int32) | |
725 { | |
726 DataEX_helper_copy_deviceData(&DeviceData->depthMaximum, &DeviceDataFlash.depthMaximum); | |
727 } | |
728 if(DeviceData->diveCycles.value_int32 < DeviceDataFlash.diveCycles.value_int32) | |
729 { | |
730 DataEX_helper_copy_deviceData(&DeviceData->diveCycles, &DeviceDataFlash.diveCycles); | |
731 } | |
406
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
732 if(DeviceData->hoursOfOperation.value_int32 < DeviceDataFlash.hoursOfOperation.value_int32) |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
733 { |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
734 DataEX_helper_copy_deviceData(&DeviceData->hoursOfOperation, &DeviceDataFlash.hoursOfOperation); |
439874690f85
Bugfix Min max values for device data checks:
ideenmodellierer
parents:
342
diff
changeset
|
735 } |
38 | 736 |
407
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
737 |
38 | 738 /* min values */ |
739 if(DeviceData->temperatureMinimum.value_int32 > DeviceDataFlash.temperatureMinimum.value_int32) | |
740 { | |
741 DataEX_helper_copy_deviceData(&DeviceData->temperatureMinimum, &DeviceDataFlash.temperatureMinimum); | |
742 } | |
743 if(DeviceData->voltageMinimum.value_int32 > DeviceDataFlash.voltageMinimum.value_int32) | |
744 { | |
745 DataEX_helper_copy_deviceData(&DeviceData->voltageMinimum, &DeviceDataFlash.voltageMinimum); | |
746 } | |
747 | |
748 DataEX_check_DeviceData (); | |
421
3f7d80f37bfc
Enable sequentionel writing of device data:
ideenmodellierer
parents:
407
diff
changeset
|
749 ext_flash_write_devicedata(false); |
38 | 750 } |
751 | |
752 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
753 static void DataEX_copy_to_DeviceData(void) |
38 | 754 { |
755 SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn; | |
756 SDevice * pDeviceState = stateDeviceGetPointerWrite(); | |
757 | |
758 memcpy(pDeviceState, &dataInDevice->DeviceData[dataInDevice->boolDeviceData], sizeof(SDevice)); | |
559 | 759 memcpy(&hw_Info, &dataInDevice->hw_Info, sizeof(dataInDevice->hw_Info)); |
760 | |
407
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
761 DeviceDataUpdated = 1; /* indicate new data to be written to flash by background task (at last op hour count will be updated) */ |
38 | 762 } |
763 | |
764 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
765 static void DataEX_copy_to_VpmRepetitiveData(void) |
38 | 766 { |
767 SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn; | |
768 SVpmRepetitiveData * pVpmState = stateVpmRepetitiveDataGetPointerWrite(); | |
769 | |
770 if(dataInDevice->boolVpmRepetitiveDataValid) | |
771 { | |
772 memcpy(pVpmState, &dataInDevice->VpmRepetitiveData, sizeof(SVpmRepetitiveData)); | |
773 pVpmState->is_data_from_RTE_CPU = 1; | |
774 } | |
775 } | |
776 | |
777 | |
778 void DataEX_control_connection_while_asking_for_sleep(void) | |
779 { | |
780 if(!DataEX_check_header_and_footer_ok()) | |
781 { | |
782 if(DataEX_check_header_and_footer_devicedata()) | |
783 { | |
784 data_old__lost_connection_to_slave_counter_retry = 0; | |
785 data_old__lost_connection_to_slave_counter_temp = 0; | |
786 stateRealGetPointerWrite()->data_old__lost_connection_to_slave = 0; | |
208 | 787 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK; |
38 | 788 } |
789 else | |
790 { | |
791 stateRealGetPointerWrite()->data_old__lost_connection_to_slave = 1; | |
792 data_old__lost_connection_to_slave_counter_temp += 1; | |
793 data_old__lost_connection_to_slave_counter_total += 1; | |
794 } | |
795 } | |
796 } | |
797 | |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
798 static float getSampleDepth(SDataExchangeSlaveToMaster *d, SDiveState *ds) |
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
799 { |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
800 float ambient = 0; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
801 float surface = 0; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
802 float depth = 0; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
803 float density = 0; |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
804 |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
805 ambient = d->data[d->boolPressureData].pressure_mbar / 1000.0f; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
806 surface = d->data[d->boolPressureData].surface_mbar / 1000.0f; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
807 density = ((float)( 100 + settingsGetPointer()->salinity)) / 100.0f; |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
808 |
497
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
809 #ifdef TESTBENCH |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
810 /* do plausibility check (typically only needed at debug hardware) */ |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
811 if(ambient < 0) |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
812 { |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
813 ambient = 1.0; |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
814 } |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
815 if(surface < 0) |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
816 { |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
817 surface = 1.0; |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
818 } |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
819 #endif |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
820 ds->lifeData.pressure_ambient_bar = ambient; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
821 ds->lifeData.pressure_surface_bar = surface; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
822 depth = (ambient - surface) / (0.09807f * density); |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
823 ds->lifeData.bool_temp1 = d->data[d->boolPressureData].SPARE1; |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
824 |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
825 return depth; |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
826 } |
38 | 827 |
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
828 static float getTemperature(SDataExchangeSlaveToMaster *d) |
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
829 { |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
830 float temp = 0; |
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
831 temp = d->data[d->boolPressureData].temperature; |
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
832 |
497
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
833 #ifdef TESTBENCH |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
834 /* do plausibility check (typically only needed at debug hardware */ |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
835 if(temp < -40.0) |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
836 { |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
837 temp = 20.0; |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
838 } |
5757edda56b7
Added worst case plausibility check (disabled by compile switch)
Ideenmodellierer
parents:
451
diff
changeset
|
839 #endif |
342
ea3fda8eb93e
Removed averaging of pressure and temperatur values
ideenmodellierer
parents:
309
diff
changeset
|
840 return temp; |
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
841 } |
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
842 |
38 | 843 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) |
844 { | |
662 | 845 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; |
846 | |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
847 SDiveState *pStateReal = stateRealGetPointerWrite(); |
577
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
848 uint8_t idx; |
662 | 849 float meter = 0; |
850 SSettings *pSettings; | |
747
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
851 |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
852 #ifdef ENABLE_EXTERNAL_PRESSURE |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
853 float CO2Corr = 0.0; |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
854 #endif |
662 | 855 |
38 | 856 // wireless - �ltere daten aufr�umen |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
436
diff
changeset
|
857 #if 0 |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
858 for(int i=0;i<(2*NUM_GASES+1);i++) |
38 | 859 { |
860 if(pStateReal->lifeData.bottle_bar[i]) | |
861 { | |
862 if((pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] == 0) || (pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] > 60000)) | |
863 { | |
864 pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] = 0; | |
865 pStateReal->lifeData.bottle_bar[i] = 0; | |
866 } | |
867 else | |
868 pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] += 100; | |
869 } | |
870 } | |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
436
diff
changeset
|
871 #else |
451
c2e02b87774f
Allocate received bar value to active gas (was static allocated to gas[1])
ideenmodellierer
parents:
446
diff
changeset
|
872 if(stateRealGetPointer()->lifeData.bottle_bar_age_MilliSeconds[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings] < 6000) /* max age after ten minutes */ |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
436
diff
changeset
|
873 { |
451
c2e02b87774f
Allocate received bar value to active gas (was static allocated to gas[1])
ideenmodellierer
parents:
446
diff
changeset
|
874 stateRealGetPointerWrite()->lifeData.bottle_bar_age_MilliSeconds[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings]++; |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
436
diff
changeset
|
875 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
436
diff
changeset
|
876 #endif |
38 | 877 if(!DataEX_check_header_and_footer_ok()) |
878 { | |
879 if(DataEX_check_header_and_footer_devicedata()) | |
880 { | |
881 DataEX_copy_to_DeviceData(); | |
882 DataEX_copy_to_VpmRepetitiveData(); | |
883 data_old__lost_connection_to_slave_counter_temp = 0; | |
884 data_old__lost_connection_to_slave_counter_retry = 0; | |
275
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
885 /* Do not yet reset state. Wait till common data has been received in next cycle. Otherwise invalid data may be forwarded for processing */ |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
886 /* pStateReal->data_old__lost_connection_to_slave = 0; */ |
208 | 887 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK; |
38 | 888 } |
889 else | |
890 { | |
891 pStateReal->data_old__lost_connection_to_slave = 1; | |
892 data_old__lost_connection_to_slave_counter_temp += 1; | |
893 data_old__lost_connection_to_slave_counter_total += 1; | |
894 } | |
895 return; | |
896 } | |
141 | 897 else /* RX data OK */ |
898 { | |
899 data_old__lost_connection_to_slave_counter_temp = 0; | |
900 data_old__lost_connection_to_slave_counter_retry = 0; | |
901 pStateReal->data_old__lost_connection_to_slave = 0; | |
208 | 902 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK; |
141 | 903 } |
38 | 904 |
905 if(getDeviceDataAfterStartOfMainCPU) | |
906 { | |
907 getDeviceDataAfterStartOfMainCPU--; | |
908 if(getDeviceDataAfterStartOfMainCPU == 0) | |
909 { | |
910 dataOut.getDeviceDataNow = 1; | |
141 | 911 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */ |
38 | 912 } |
913 } | |
914 | |
662 | 915 if((requestNecessary.uw != 0) && (dataIn.confirmRequest.uw != 0)) |
38 | 916 { |
917 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0) | |
918 { | |
919 requestNecessary.ub.button = 0; | |
920 } | |
662 | 921 if(((dataIn.confirmRequest.uw) & CRCLEARDECO) != 0) |
922 { | |
923 requestNecessary.ub.clearDeco = 0; | |
924 } | |
925 if(((dataIn.confirmRequest.uw) & CRDATE) != 0) | |
926 { | |
927 requestNecessary.ub.date = 0; | |
928 } | |
929 if(((dataIn.confirmRequest.uw) & CRTIME) != 0) | |
930 { | |
931 requestNecessary.ub.time = 0; | |
932 } | |
933 if(((dataIn.confirmRequest.uw) & CRCOMPASS) != 0) | |
934 { | |
935 requestNecessary.ub.compass = 0; | |
936 } | |
937 if(((dataIn.confirmRequest.uw) & CRDEVICEDATA) != 0) | |
938 { | |
939 requestNecessary.ub.devicedata = 0; | |
940 } | |
941 if(((dataIn.confirmRequest.uw) & CRBATTERY) != 0) | |
942 { | |
943 requestNecessary.ub.batterygauge = 0; | |
944 } | |
945 if(((dataIn.confirmRequest.uw) & CRACCIDENT) != 0) | |
946 { | |
947 requestNecessary.ub.accident = 0; | |
948 } | |
38 | 949 |
662 | 950 if(requestNecessary.ub.button == 1) /* send button values to RTE */ |
38 | 951 { |
952 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); | |
953 } | |
954 } | |
149 | 955 |
38 | 956 /* uint8_t IAmStolenPleaseKillMe; |
957 */ | |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
958 pSettings = settingsGetPointer(); |
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
959 |
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
960 if(pSettings->IAmStolenPleaseKillMe > 3) |
38 | 961 { |
962 pSettings->salinity = 0; | |
963 dataIn.data[dataIn.boolPressureData].surface_mbar = 999; | |
964 dataIn.data[dataIn.boolPressureData].pressure_mbar = 98971; | |
965 dataIn.mode = MODE_DIVE; | |
966 } | |
967 | |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
968 |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
969 /* internal sensor: HUD data */ |
559 | 970 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
971 { |
716
74cfd91199bd
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
972 pStateReal->lifeData.extIf_sensor_Id = 0; |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
973 for(int i=0;i<3;i++) |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
974 { |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
975 pStateReal->lifeData.ppO2Sensor_bar[i] = get_ppO2Sensor_bar(i); |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
976 pStateReal->lifeData.sensorVoltage_mV[i] = get_sensorVoltage_mV(i); |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
977 } |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
978 pStateReal->lifeData.HUD_battery_voltage_V = get_HUD_battery_voltage_V(); |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
979 } |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
980 else /* use data from external ADC */ |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
981 { |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
982 if(pStateReal->data_old__lost_connection_to_slave == 0) |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
983 { |
577
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
984 for(idx = 0; idx < 3; idx++) |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
985 { |
691 | 986 pStateReal->lifeData.sensorVoltage_mV[idx] = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].extADC_voltage[idx]; |
577
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
987 if(pStateReal->lifeData.sensorVoltage_mV[idx] < IGNORE_O2_VOLTAGE_LEVEL_MV) |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
988 { |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
989 pStateReal->lifeData.sensorVoltage_mV[idx] = 0.0; |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
990 pStateReal->lifeData.ppO2Sensor_bar[idx] = 0; |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
991 } |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
992 else |
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
993 { |
796 | 994 if(dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map[idx] == SENSOR_DIGO2M) |
702
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
995 { |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
996 pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] / 100.0; |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
997 } |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
998 else |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
999 { |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
1000 pStateReal->lifeData.ppO2Sensor_bar[idx] = pStateReal->lifeData.sensorVoltage_mV[idx] * pSettings->ppo2sensors_calibCoeff[idx]; |
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
1001 } |
577
9bb9a52d6ae5
Handle o2 voltage values < 0.5mV as invalid:
Ideenmodellierer
parents:
559
diff
changeset
|
1002 } |
716
74cfd91199bd
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
1003 } |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1004 } |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1005 } |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1006 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1007 if(pStateReal->data_old__lost_connection_to_slave == 0) |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1008 { |
734
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1009 |
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1010 pStateReal->lifeData.extIf_sensor_Id = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].externalInterface_SensorID; |
786 | 1011 if(pStateReal->lifeData.extIf_sensor_Id < 3) |
734
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1012 { |
780 | 1013 |
786 | 1014 memcpy(pStateReal->lifeData.extIf_sensor_data[pStateReal->lifeData.extIf_sensor_Id], dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_data, 32); |
734
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1015 } |
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1016 memcpy(pStateReal->lifeData.extIf_sensor_map, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map, EXT_INTERFACE_SENSOR_CNT); |
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1017 |
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
728
diff
changeset
|
1018 |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
1019 meter = getSampleDepth(&dataIn, pStateReal); |
38 | 1020 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1021 pStateReal->pressure_uTick_old = pStateReal->pressure_uTick_new; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1022 pStateReal->pressure_uTick_new = dataIn.data[dataIn.boolPressureData].pressure_uTick; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1023 pStateReal->pressure_uTick_local_new = HAL_GetTick(); |
38 | 1024 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1025 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1026 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; |
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
842
diff
changeset
|
1027 |
931 | 1028 memcpy(&pStateReal->lifeData.gnssData, &dataIn.data[0].gnssInfo, sizeof(dataIn.data[0].gnssInfo)); |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1029 } |
38 | 1030 |
141 | 1031 if(pStateReal->data_old__lost_connection_to_slave == 0) |
38 | 1032 { |
141 | 1033 //Start of diveMode? |
1034 if(pStateReal->mode != MODE_DIVE && dataIn.mode == MODE_DIVE) | |
1035 { | |
1036 if(modeChangeFlag) | |
1037 { | |
1038 *modeChangeFlag = 1; | |
1039 } | |
1040 if(stateUsed == stateSimGetPointer()) | |
38 | 1041 { |
1042 simulation_exit(); | |
1043 } | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
796
diff
changeset
|
1044 disableTimer(); |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
796
diff
changeset
|
1045 |
141 | 1046 // new 170508 |
38 | 1047 settingsGetPointer()->bluetoothActive = 0; |
1048 MX_Bluetooth_PowerOff(); | |
1049 //Init dive Mode | |
141 | 1050 decoLock = DECO_CALC_init_as_is_start_of_dive; |
1051 pStateReal->lifeData.boolResetAverageDepth = 1; | |
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
920
diff
changeset
|
1052 |
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
920
diff
changeset
|
1053 memcpy(pStateReal->scrubberDataDive, pSettings->scrubberData, sizeof(pStateReal->scrubberDataDive)); |
38 | 1054 } |
141 | 1055 |
197
c853f5d23bb7
cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
1056 pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; |
c853f5d23bb7
cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
1057 pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu; |
c853f5d23bb7
cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
1058 pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes; |
c853f5d23bb7
cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
1059 pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes; |
c853f5d23bb7
cleanup: fix (harmless) use before assign
Jan Mulder <jlmulder@xs4all.nl>
parents:
189
diff
changeset
|
1060 |
141 | 1061 //End of diveMode? |
1062 if(pStateReal->mode == MODE_DIVE && dataIn.mode != MODE_DIVE) | |
1063 { | |
1064 if(modeChangeFlag) | |
1065 { | |
1066 *modeChangeFlag = 1; | |
1067 } | |
1068 createDiveSettings(); | |
38 | 1069 |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
796
diff
changeset
|
1070 disableTimer(); |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
796
diff
changeset
|
1071 |
141 | 1072 if(pStateReal->warnings.cnsHigh) |
1073 { | |
1074 if(pStateReal->lifeData.cns >= 130) | |
1075 dataOut.setAccidentFlag += ACCIDENT_CNSLVL2; | |
1076 else if(pStateReal->lifeData.cns >= 100) | |
1077 dataOut.setAccidentFlag += ACCIDENT_CNS; | |
1078 } | |
1079 if(pStateReal->warnings.decoMissed) | |
1080 dataOut.setAccidentFlag += ACCIDENT_DECOSTOP; | |
924
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
920
diff
changeset
|
1081 |
4d98fb2a178e
Bugfix real scrubber time decreased in sim mode:
Ideenmodellierer
parents:
920
diff
changeset
|
1082 memcpy(pSettings->scrubberData, pStateReal->scrubberDataDive, sizeof(pStateReal->scrubberDataDive)); /* Store value of current usage */ |
141 | 1083 } |
1084 pStateReal->mode = dataIn.mode; | |
1085 pStateReal->chargeStatus = dataIn.chargeStatus; | |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1086 |
306
2f43419102c8
bugfix, cleanup: do not clip depth to 0
Jan Mulder <jlmulder@xs4all.nl>
parents:
288
diff
changeset
|
1087 pStateReal->lifeData.depth_meter = meter; |
141 | 1088 |
189
8b8074080d7b
Bugfix: average temperature on arrival from RTE instead of display time
Jan Mulder <jlmulder@xs4all.nl>
parents:
173
diff
changeset
|
1089 pStateReal->lifeData.temperature_celsius = getTemperature(&dataIn); |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1090 pStateReal->lifeData.ascent_rate_meter_per_min = dataIn.data[dataIn.boolPressureData].ascent_rate_meter_per_min; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1091 if(pStateReal->mode != MODE_DIVE) |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1092 pStateReal->lifeData.max_depth_meter = 0; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1093 else |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1094 { |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1095 if(meter > pStateReal->lifeData.max_depth_meter) |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1096 pStateReal->lifeData.max_depth_meter = meter; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1097 } |
38 | 1098 |
662 | 1099 if(requestNecessary.ub.clearDeco == 0) /* No "reset deco" is send to RTE ? */ |
1100 { | |
1101 if(dataIn.accidentFlags & ACCIDENT_DECOSTOP) | |
1102 { | |
1103 pStateReal->decoMissed_at_the_end_of_dive = 1; | |
1104 } | |
1105 else | |
1106 { | |
1107 pStateReal->decoMissed_at_the_end_of_dive = 0; | |
1108 } | |
1109 if(dataIn.accidentFlags & ACCIDENT_CNS) | |
1110 { | |
1111 pStateReal->cnsHigh_at_the_end_of_dive = 1; | |
1112 } | |
1113 else | |
1114 { | |
1115 pStateReal->cnsHigh_at_the_end_of_dive = 0; | |
1116 } | |
1117 } | |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1118 pStateReal->lifeData.dive_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].divetime_seconds; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1119 pStateReal->lifeData.dive_time_seconds_without_surface_time = (int32_t)dataIn.data[dataIn.boolTimeData].dive_time_seconds_without_surface_time; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1120 pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1121 pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds; |
38 | 1122 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1123 pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading; |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1124 if (pStateReal->lifeData.compass_heading != -1) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1125 if (pSettings->FlipDisplay) { /* consider that diver is targeting into the opposite direction */ |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1126 pStateReal->lifeData.compass_heading -= 180.0; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1127 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1128 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1129 if (pSettings->compassDeclinationDeg != 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1130 pStateReal->lifeData.compass_heading = pStateReal->lifeData.compass_heading + pSettings->compassDeclinationDeg - 360.0; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1131 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1132 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1133 while (pStateReal->lifeData.compass_heading < 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1134 pStateReal->lifeData.compass_heading += 360.0; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1135 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
763
diff
changeset
|
1136 } |
109
65a6e352ce08
Consider computer heading in case of a flipped display
Ideenmodellierer
parents:
51
diff
changeset
|
1137 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1138 pStateReal->lifeData.compass_roll = dataIn.data[dataIn.boolCompassData].compass_roll; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1139 pStateReal->lifeData.compass_pitch = dataIn.data[dataIn.boolCompassData].compass_pitch; |
38 | 1140 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1141 pStateReal->lifeData.compass_DX_f = dataIn.data[dataIn.boolCompassData].compass_DX_f; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1142 pStateReal->lifeData.compass_DY_f = dataIn.data[dataIn.boolCompassData].compass_DY_f; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1143 pStateReal->lifeData.compass_DZ_f = dataIn.data[dataIn.boolCompassData].compass_DZ_f; |
38 | 1144 |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1145 pStateReal->compass_uTick_old = pStateReal->compass_uTick_new; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1146 pStateReal->compass_uTick_new = dataIn.data[dataIn.boolCompassData].compass_uTick; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1147 pStateReal->compass_uTick_local_new = HAL_GetTick(); |
539
d784f281833a
Added inertia simulation for compass heading:
Ideenmodellierer
parents:
497
diff
changeset
|
1148 compass_Inertia(pStateReal->lifeData.compass_heading); |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1149 |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1150 memcpy(pStateReal->lifeData.tissue_nitrogen_bar, dataIn.data[dataIn.boolTisssueData].tissue_nitrogen_bar,sizeof(pStateReal->lifeData.tissue_nitrogen_bar)); |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1151 memcpy(pStateReal->lifeData.tissue_helium_bar, dataIn.data[dataIn.boolTisssueData].tissue_helium_bar,sizeof(pStateReal->lifeData.tissue_helium_bar)); |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1152 |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1153 if(pStateReal->mode == MODE_DIVE) |
38 | 1154 { |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1155 for(int i= 0; i <16; i++) |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1156 { |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1157 pStateReal->vpm.max_crushing_pressure_he[i] = dataIn.data[dataIn.boolCrushingData].max_crushing_pressure_he[i]; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1158 pStateReal->vpm.max_crushing_pressure_n2[i] = dataIn.data[dataIn.boolCrushingData].max_crushing_pressure_n2[i]; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1159 pStateReal->vpm.adjusted_critical_radius_he[i] = dataIn.data[dataIn.boolCrushingData].adjusted_critical_radius_he[i]; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1160 pStateReal->vpm.adjusted_critical_radius_n2[i] = dataIn.data[dataIn.boolCrushingData].adjusted_critical_radius_n2[i]; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1161 } |
38 | 1162 } |
1163 | |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1164 /* battery and ambient light sensors |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1165 */ |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1166 pStateReal->lifeData.ambient_light_level = dataIn.data[dataIn.boolAmbientLightData].ambient_light_level; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1167 pStateReal->lifeData.battery_charge = dataIn.data[dataIn.boolBatteryData].battery_charge; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1168 pStateReal->lifeData.battery_voltage = dataIn.data[dataIn.boolBatteryData].battery_voltage; |
275
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1169 |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1170 /* PIC data |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1171 */ |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1172 for(int i=0;i<4;i++) |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1173 { |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1174 pStateReal->lifeData.buttonPICdata[i] = dataIn.data[dataIn.boolPICdata].button_setting[i]; |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1175 } |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1176 |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1177 /* sensorErrors |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1178 */ |
189387bf23a8
Do not mark data as valid if devicedata is received.
ideenmodellierer
parents:
232
diff
changeset
|
1179 pStateReal->sensorErrorsRTE = dataIn.sensorErrors; |
662 | 1180 |
1181 /* data from CO2 sensor */ | |
831 | 1182 pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm; |
691 | 1183 pStateReal->lifeData.CO2_data.signalStrength = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_signalStrength; |
747
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1184 |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1185 #ifdef ENABLE_EXTERNAL_PRESSURE |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1186 CO2Corr = 2.811*pow(10,-38)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,6)- 9.817*pow(10,-32)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,5)+1.304*pow(10,-25)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,4) |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1187 -8.216*pow(10,-20)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,3)+2.311*pow(10,-14)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,2) - 2.195*pow(10,-9)*pStateReal->lifeData.CO2_data.CO2_ppm - 1.471*pow(10,-3); |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1188 pStateReal->lifeData.CO2_data.CO2_ppm = pStateReal->lifeData.CO2_data.CO2_ppm / (1.0 + (CO2Corr * ((stateRealGetPointer()->lifeData.pressure_surface_bar * 1000) - ((stateRealGetPointer()->lifeData.ppO2Sensor_bar[2] *1000))))); |
df0d43da1614
Added pressure compensation to CO2 detection:
Ideenmodellierer
parents:
734
diff
changeset
|
1189 #endif |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1190 } |
38 | 1191 |
1192 /* apnea specials | |
1193 */ | |
1194 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) | |
1195 { | |
1196 if(pStateReal->mode != MODE_DIVE) | |
1197 { | |
1198 pStateReal->lifeData.apnea_total_max_depth_meter = 0; | |
1199 pStateReal->lifeData.apnea_last_dive_time_seconds = 0; | |
1200 pStateReal->lifeData.apnea_last_max_depth_meter = 0; | |
1201 } | |
1202 else | |
1203 { | |
1204 if(pStateReal->lifeData.max_depth_meter > pStateReal->lifeData.apnea_total_max_depth_meter) | |
1205 pStateReal->lifeData.apnea_total_max_depth_meter = pStateReal->lifeData.max_depth_meter; | |
1206 } | |
1207 | |
1208 if(pStateReal->lifeData.dive_time_seconds > 15) | |
1209 { | |
1210 pStateReal->lifeData.apnea_last_dive_time_seconds = pStateReal->lifeData.dive_time_seconds; | |
1211 } | |
1212 | |
1213 if(pStateReal->lifeData.counterSecondsShallowDepth) | |
1214 { | |
1215 if(pStateReal->lifeData.max_depth_meter > 1.5f) | |
1216 { | |
1217 pStateReal->lifeData.apnea_last_max_depth_meter = pStateReal->lifeData.max_depth_meter; | |
1218 } | |
173
05c770dc2911
Bugfix: make max depth move with current depth (part 1)
Jan Mulder <jlmulder@xs4all.nl>
parents:
156
diff
changeset
|
1219 // reset max_depth_meter, average_depth_meter and internal values |
38 | 1220 pStateReal->lifeData.max_depth_meter = 0; |
1221 pStateReal->lifeData.boolResetAverageDepth = 1; | |
1222 } | |
1223 } | |
1224 | |
308
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1225 setAvgDepth(pStateReal); |
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1226 } |
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1227 |
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1228 void setAvgDepth(SDiveState *pStateReal) { |
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1229 |
38 | 1230 float *AvgDepthValue = &pStateReal->lifeData.average_depth_meter; |
1231 float DepthNow = pStateReal->lifeData.depth_meter; | |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1232 static uint32_t AvgDepthCount = 0; |
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1233 static uint32_t AvgDepthTimer = 0; |
38 | 1234 uint32_t AvgSecondsSinceLast; |
1235 uint32_t DiveTime = pStateReal->lifeData.dive_time_seconds_without_surface_time; | |
308
1203255481e4
cleanup: introduce function setAvgDepth
Jan Mulder <jlmulder@xs4all.nl>
parents:
307
diff
changeset
|
1236 |
38 | 1237 if(pStateReal->lifeData.boolResetAverageDepth) |
1238 { | |
1239 *AvgDepthValue = DepthNow; | |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1240 AvgDepthCount = 0; |
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1241 AvgDepthTimer = DiveTime; |
38 | 1242 pStateReal->lifeData.boolResetAverageDepth = 0; |
1243 } | |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1244 else if (DiveTime > AvgDepthTimer) |
38 | 1245 { |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1246 AvgSecondsSinceLast = DiveTime - AvgDepthTimer; |
38 | 1247 for(int i=0;i<AvgSecondsSinceLast;i++) |
1248 { | |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1249 *AvgDepthValue = (*AvgDepthValue * AvgDepthCount + DepthNow) / (AvgDepthCount + 1); |
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1250 AvgDepthCount += 1; |
38 | 1251 } |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1252 AvgDepthTimer = DiveTime; |
38 | 1253 } |
309
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1254 if(AvgDepthCount == 0) |
b0045281cb2d
cleanup: factor out SHelper typedef (and more)
Jan Mulder <jlmulder@xs4all.nl>
parents:
308
diff
changeset
|
1255 *AvgDepthValue = DepthNow; |
38 | 1256 } |
1257 | |
1258 | |
1259 uint8_t DataEX_check_RTE_version__needs_update(void) | |
1260 { | |
1261 if(data_old__lost_connection_to_slave_counter_retry > 10) | |
1262 return 1; | |
1263 else | |
1264 { | |
1265 if(stateRealGetPointer()->data_old__lost_connection_to_slave == 0) | |
1266 { | |
1267 setActualRTEversion(dataIn.RTE_VERSION_high, dataIn.RTE_VERSION_low); | |
1268 | |
1269 if(RTEminimum_required_high() < dataIn.RTE_VERSION_high) | |
1270 return 0; | |
1271 else | |
1272 if((RTEminimum_required_high() == dataIn.RTE_VERSION_high) && (RTEminimum_required_low() <= dataIn.RTE_VERSION_low)) | |
1273 return 0; | |
1274 else | |
1275 return 1; | |
1276 } | |
1277 else | |
1278 return 0; | |
1279 } | |
1280 } | |
1281 | |
1282 | |
1283 /* Private functions ---------------------------------------------------------*/ | |
1284 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
1285 /* Check if there is an empty frame provided by RTE (all 0) or even no data provided by RTE (all 0xFF) |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1286 * If that is not the case the DMA is somehow not in sync |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1287 */ |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
1288 static uint8_t DataEX_check_header_and_footer_shifted() |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1289 { |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1290 uint8_t ret = 1; |
141 | 1291 if((dataIn.footer.checkCode[0] == 0x00) |
1292 && (dataIn.footer.checkCode[1] == 0x00) | |
1293 && (dataIn.footer.checkCode[2] == 0x00) | |
1294 && (dataIn.footer.checkCode[3] == 0x00)) { ret = 0; } | |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1295 |
141 | 1296 if((dataIn.footer.checkCode[0] == 0xff) |
1297 && (dataIn.footer.checkCode[1] == 0xff) | |
1298 && (dataIn.footer.checkCode[2] == 0xff) | |
1299 && (dataIn.footer.checkCode[3] == 0xff)) { ret = 0; } | |
137
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1300 |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1301 return ret; |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1302 } |
9eda5a75c5fd
Only copy data if data connection to RTE is valid
Ideenmodellierer
parents:
133
diff
changeset
|
1303 |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
1304 static uint8_t DataEX_check_header_and_footer_ok(void) |
38 | 1305 { |
1306 if(dataIn.header.checkCode[0] != 0xA1) | |
1307 return 0; | |
141 | 1308 #if USE_OLD_HEADER_FORMAT |
38 | 1309 if(dataIn.header.checkCode[1] != 0xA2) |
1310 return 0; | |
1311 if(dataIn.header.checkCode[2] != 0xA3) | |
1312 return 0; | |
141 | 1313 #endif |
38 | 1314 if(dataIn.header.checkCode[3] != 0xA4) |
1315 return 0; | |
1316 if(dataIn.footer.checkCode[0] != 0xE1) | |
1317 return 0; | |
1318 if(dataIn.footer.checkCode[1] != 0xE2) | |
1319 return 0; | |
1320 if(dataIn.footer.checkCode[2] != 0xE3) | |
1321 return 0; | |
1322 if(dataIn.footer.checkCode[3] != 0xE4) | |
1323 return 0; | |
1324 | |
1325 return 1; | |
1326 } | |
1327 | |
198
878dc9e0dbc5
cleanup: another cleanup session (data_exchange_main.c)
Jan Mulder <jlmulder@xs4all.nl>
parents:
197
diff
changeset
|
1328 static uint8_t DataEX_check_header_and_footer_devicedata(void) |
38 | 1329 { |
1330 if(dataIn.header.checkCode[0] != 0xDF) | |
1331 return 0; | |
1332 if(dataIn.header.checkCode[1] != 0xDE) | |
1333 return 0; | |
1334 if(dataIn.header.checkCode[2] != 0xDD) | |
1335 return 0; | |
1336 if(dataIn.header.checkCode[3] != 0xDC) | |
1337 return 0; | |
1338 if(dataIn.footer.checkCode[0] != 0xE1) | |
1339 return 0; | |
1340 if(dataIn.footer.checkCode[1] != 0xE2) | |
1341 return 0; | |
1342 if(dataIn.footer.checkCode[2] != 0xE3) | |
1343 return 0; | |
1344 if(dataIn.footer.checkCode[3] != 0xE4) | |
1345 return 0; | |
1346 | |
1347 return 1; | |
1348 } | |
407
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1349 |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1350 void DataEX_merge_devicedata(void) |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1351 { |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1352 if(DeviceDataUpdated) |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1353 { |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1354 DeviceDataUpdated = 0; |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1355 DataEX_merge_DeviceData_and_store(); |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1356 } |
b11e50415982
Bugfix parallel call of external flash functions:
ideenmodellierer
parents:
406
diff
changeset
|
1357 } |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1358 uint8_t DataEX_external_ADC_Present(void) |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1359 { |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1360 uint8_t retval; |
559 | 1361 retval = hw_Info.extADC; |
556
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1362 |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1363 return retval; |
eb2060caca7d
Switch source of o2 sensor data depending on availability of external ADC:
Ideenmodellierer
parents:
539
diff
changeset
|
1364 } |
662 | 1365 |
1366 void DataEX_setExtInterface_Cmd(uint16_t Cmd) | |
1367 { | |
1368 externalInterface_Cmd = Cmd; | |
1369 return; | |
1370 } | |
1371 |