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