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