Mercurial > public > ostc4
annotate Discovery/Src/tCCR.c @ 447:adc4ccbebbb5 minor_improvments
Added compile switch var firmware variant which does trust the memory log => does not check the log consistency at startu (used for test purpose)
author | ideenmodellierer |
---|---|
date | Mon, 23 Mar 2020 21:10:02 +0100 |
parents | f1257a32f2d4 |
children | 91a939915bfa |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tCCR.c | |
5 /// \brief HUD data via optical port | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 18-Dec-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include <string.h> | |
31 #include "tCCR.h" | |
32 #include "ostc.h" | |
33 #include "data_central.h" | |
34 #include "data_exchange.h" | |
35 #include "check_warning.h" | |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
36 #include "configuration.h" |
38 | 37 |
38 /* Private types -------------------------------------------------------------*/ | |
39 typedef struct | |
40 { | |
41 uint8_t hud_firmwareVersion; | |
42 bit8_Type status_byte; | |
43 uint16_t sensor_voltage_100uV[3]; | |
44 uint8_t sensor_ppo2_cbar[3]; | |
45 uint8_t temp1; | |
46 uint16_t battery_voltage_mV; | |
47 uint16_t checksum; | |
48 } SIrLink; | |
49 | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
50 #define HUD_BABBLING_IDIOT (30u) /* 30 Bytes received without break */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
51 #define HUD_RX_FRAME_LENGTH (15u) /* Length of a HUD data frame */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
52 #define HUD_RX_FRAME_BREAK_MS (100u) /* Time used to detect a gap between two byte receptions => frame start */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
53 #define HUD_RX_START_DELAY_MS (500u) /* Delay for start of RX function to avoid start of reception while a transmission is ongoing. */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
54 /* Based on an assumed cycle time by the sensor of 1 second. Started at time of last RX */ |
38 | 55 |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
56 /* Private variables ---------------------------------------------------------*/ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
57 static SIrLink receiveHUD[2]; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
58 static uint8_t boolHUDdata = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
59 static uint8_t data_old__lost_connection_to_HUD = 1; |
38 | 60 |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
61 static uint8_t receiveHUDraw[16]; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
62 |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
63 static uint8_t StartListeningToUART_HUD = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
64 static uint16_t HUDTimeoutCount = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
65 |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
66 static __IO ITStatus UartReadyHUD = RESET; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
67 static uint32_t LastReceivedTick_HUD = 0; |
38 | 68 |
69 /* Private variables with external access via get_xxx() function -------------*/ | |
70 | |
71 /* Private function prototypes -----------------------------------------------*/ | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
72 static void tCCR_fallbackToFixedSetpoint(void); |
38 | 73 |
74 #ifndef USART_IR_HUD | |
75 | |
76 void tCCR_init(void) | |
77 { | |
78 } | |
79 void tCCR_control(void) | |
80 { | |
81 } | |
82 void tCCR_test(void) | |
83 { | |
84 } | |
85 void tCCR_restart(void) | |
86 { | |
87 } | |
88 float get_ppO2Sensor_bar(uint8_t sensor_id) | |
89 { | |
90 } | |
91 float get_sensorVoltage_mV(uint8_t sensor_id) | |
92 { | |
93 } | |
94 float get_HUD_battery_voltage_V(void) | |
95 { | |
96 } | |
97 void tCCR_tick(void) | |
98 { | |
99 } | |
100 | |
101 #else | |
102 /* Exported functions --------------------------------------------------------*/ | |
103 | |
104 float get_ppO2Sensor_bar(uint8_t sensor_id) | |
105 { | |
106 if((sensor_id > 2) || data_old__lost_connection_to_HUD) | |
107 return 0; | |
108 | |
109 return (float)(receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id]) / 100.0f; | |
110 } | |
111 | |
112 float get_sensorVoltage_mV(uint8_t sensor_id) | |
113 { | |
114 if((sensor_id > 2) || data_old__lost_connection_to_HUD) | |
115 return 0; | |
116 | |
117 return (float)(receiveHUD[boolHUDdata].sensor_voltage_100uV[sensor_id]) / 10.0f; | |
118 } | |
119 | |
120 float get_HUD_battery_voltage_V(void) | |
121 { | |
122 if(data_old__lost_connection_to_HUD) | |
123 return 0; | |
124 | |
125 return (float)(receiveHUD[boolHUDdata].battery_voltage_mV) / 1000.0f; | |
126 } | |
127 | |
128 | |
129 void test_HUD_sensor_values_outOfBounds(int8_t * outOfBouds1, int8_t * outOfBouds2, int8_t * outOfBouds3) | |
130 { | |
131 uint8_t sensorNotActiveBinary; | |
132 uint8_t sensorActive[3]; | |
133 | |
134 // test1: user deactivation | |
135 sensorNotActiveBinary = stateUsed->diveSettings.ppo2sensors_deactivated; | |
136 | |
137 for(int i=0;i<3;i++) | |
138 sensorActive[i] = 1; | |
139 | |
140 if(sensorNotActiveBinary) | |
141 { | |
142 if(sensorNotActiveBinary & 1) | |
143 sensorActive[0] = 0; | |
144 | |
145 if(sensorNotActiveBinary & 2) | |
146 sensorActive[1] = 0; | |
147 | |
148 if(sensorNotActiveBinary & 4) | |
149 sensorActive[2] = 0; | |
150 } | |
151 | |
152 // test2: mV of remaining sensors | |
153 for(int i=0;i<3;i++) | |
154 { | |
155 if(sensorActive[i]) | |
156 { | |
157 if( (receiveHUD[boolHUDdata].sensor_voltage_100uV[i] < 80) || | |
158 (receiveHUD[boolHUDdata].sensor_voltage_100uV[i] > 2500)) | |
159 { | |
160 sensorActive[i] = 0; | |
161 switch(i) | |
162 { | |
163 case 0: | |
164 sensorNotActiveBinary |= 1; | |
165 break; | |
166 case 1: | |
167 sensorNotActiveBinary |= 2; | |
168 break; | |
169 case 2: | |
170 sensorNotActiveBinary |= 4; | |
171 break; | |
172 } | |
173 } | |
174 } | |
175 } | |
176 | |
177 *outOfBouds1 = 0; | |
178 *outOfBouds2 = 0; | |
179 *outOfBouds3 = 0; | |
180 | |
181 /* with two, one or no sensor, there is nothing to compare anymore | |
182 */ | |
183 if(sensorNotActiveBinary) | |
184 { | |
185 // set outOfBounds for both tests | |
186 if(!sensorActive[0]) | |
187 *outOfBouds1 = 1; | |
188 | |
189 if(!sensorActive[1]) | |
190 *outOfBouds2 = 1; | |
191 | |
192 if(!sensorActive[2]) | |
193 *outOfBouds3 = 1; | |
194 | |
195 return; | |
196 } | |
197 else | |
198 { | |
199 uint8_t sensor_id_ordered[3]; | |
200 uint8_t difference[2]; | |
201 | |
202 if((receiveHUD[boolHUDdata].sensor_ppo2_cbar[1]) > (receiveHUD[boolHUDdata].sensor_ppo2_cbar[0])) | |
203 { | |
204 sensor_id_ordered[0] = 0; | |
205 sensor_id_ordered[1] = 1; | |
206 } | |
207 else | |
208 { | |
209 sensor_id_ordered[0] = 1; | |
210 sensor_id_ordered[1] = 0; | |
211 } | |
212 if(receiveHUD[boolHUDdata].sensor_ppo2_cbar[2] > receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]]) | |
213 { | |
214 sensor_id_ordered[2] = 2; | |
215 } | |
216 else | |
217 { | |
218 sensor_id_ordered[2] = sensor_id_ordered[1]; | |
219 if(receiveHUD[boolHUDdata].sensor_ppo2_cbar[2] > receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[0]]) | |
220 { | |
221 sensor_id_ordered[1] = 2; | |
222 } | |
223 else | |
224 { | |
225 sensor_id_ordered[1] = sensor_id_ordered[0]; | |
226 sensor_id_ordered[0] = 2; | |
227 } | |
228 } | |
229 | |
230 difference[0] = receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]]- receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[0]]; | |
231 difference[1] = receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[2]]- receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]]; | |
232 | |
233 if((difference[0] > difference[1]) && (difference[0] > 15)) | |
234 { | |
235 switch(sensor_id_ordered[0]) | |
236 { | |
237 case 0: | |
238 *outOfBouds1 = 1; | |
239 break; | |
240 case 1: | |
241 *outOfBouds2 = 1; | |
242 break; | |
243 case 2: | |
244 *outOfBouds3 = 1; | |
245 break; | |
246 } | |
247 } | |
248 else | |
249 if((difference[0] < difference[1]) && (difference[1] > 15)) | |
250 { | |
251 switch(sensor_id_ordered[2]) | |
252 { | |
253 case 0: | |
254 *outOfBouds1 = 1; | |
255 break; | |
256 case 1: | |
257 *outOfBouds2 = 1; | |
258 break; | |
259 case 2: | |
260 *outOfBouds3 = 1; | |
261 break; | |
262 } | |
263 } | |
264 } | |
265 } | |
266 | |
267 | |
268 uint8_t get_ppO2SensorWeightedResult_cbar(void) | |
269 { | |
270 int8_t sensorOutOfBound[3]; | |
271 uint16_t result = 0; | |
272 uint8_t count = 0; | |
273 | |
274 test_HUD_sensor_values_outOfBounds(&sensorOutOfBound[0], &sensorOutOfBound[1], &sensorOutOfBound[2]); | |
275 | |
276 for(int i=0;i<3;i++) | |
277 { | |
278 if(!sensorOutOfBound[i]) | |
279 { | |
280 result += receiveHUD[boolHUDdata].sensor_ppo2_cbar[i]; | |
281 count++; | |
282 } | |
283 } | |
284 if(count == 0) // all sensors out of bounds! | |
285 return 0; | |
286 else | |
287 return (uint8_t)(result / count); | |
288 } | |
289 | |
290 | |
291 void tCCR_init(void) | |
292 { | |
293 StartListeningToUART_HUD = 1; | |
294 } | |
295 | |
296 | |
297 /* after 3 seconds without update from HUD | |
298 * data is considered old | |
299 */ | |
300 void tCCR_tick(void) | |
301 { | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
302 if(HUDTimeoutCount < 3 * 10) |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
303 HUDTimeoutCount++; |
38 | 304 else |
305 { | |
306 data_old__lost_connection_to_HUD = 1; | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
307 if(HUDTimeoutCount < 20 * 10) |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
308 HUDTimeoutCount++; |
38 | 309 else |
310 tCCR_fallbackToFixedSetpoint(); | |
311 } | |
312 } | |
313 | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
314 void tCCR_SetRXIndication(void) |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
315 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
316 static uint8_t floatingRXCount = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
317 |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
318 if((UartIR_HUD_Handle.RxXferSize == HUD_RX_FRAME_LENGTH) || (UartIR_HUD_Handle.RxXferSize == HUD_RX_FRAME_LENGTH - 1)) /* we expected a complete frame */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
319 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
320 UartReadyHUD = SET; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
321 LastReceivedTick_HUD = HAL_GetTick(); |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
322 floatingRXCount = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
323 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
324 else /* follow up of error handling */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
325 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
326 if(time_elapsed_ms(LastReceivedTick_HUD, HAL_GetTick()) > HUD_RX_FRAME_BREAK_MS) /* Reception took a while => frame start detected */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
327 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
328 HAL_UART_Receive_IT(&UartIR_HUD_Handle, &receiveHUDraw[1], 14); /* We have already the first byte => get the missing 14 */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
329 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
330 else |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
331 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
332 if(floatingRXCount++ < HUD_BABBLING_IDIOT) |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
333 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
334 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1); /* Start polling of incoming bytes */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
335 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
336 else /* Significant amount of data comming in without break => disable input */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
337 { /* by not reactivation HUD RX, no recovery fromthis state */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
338 stateUsedWrite->diveSettings.ppo2sensors_deactivated = 0x07; /* Display deactivation */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
339 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
340 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
341 } |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
342 |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
343 } |
38 | 344 |
345 void tCCR_restart(void) | |
346 { | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
347 HAL_UART_AbortReceive_IT(&UartIR_HUD_Handle); /* Called by the error handler. RX will be restarted by control function */ |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
348 StartListeningToUART_HUD = 1; |
38 | 349 } |
350 | |
351 | |
352 void tCCR_control(void) | |
353 { | |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
354 uint16_t checksum = 0; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
355 SDiveState *pLivedata = stateRealGetPointerWrite(); |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
356 |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
357 |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
358 if((UartReadyHUD == RESET) && StartListeningToUART_HUD && (time_elapsed_ms(LastReceivedTick_HUD, HAL_GetTick()) > HUD_RX_START_DELAY_MS)) |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
359 { |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
360 StartListeningToUART_HUD = 0; |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
361 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, HUD_RX_FRAME_LENGTH); |
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
362 } |
38 | 363 |
364 if(UartReadyHUD == SET) | |
365 { | |
366 UartReadyHUD = RESET; | |
322
31e471d60797
Added start of frame detection for HUD data
ideenmodellierer
parents:
272
diff
changeset
|
367 StartListeningToUART_HUD = 1; |
38 | 368 |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
369 /* check if received package is valid */ |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
370 for(int i=0;i<13;i++) |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
371 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
372 checksum += receiveHUDraw[i]; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
373 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
374 receiveHUD[!boolHUDdata].checksum = receiveHUDraw[13] + (256 * receiveHUDraw[14]); |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
375 if(checksum == receiveHUD[!boolHUDdata].checksum) |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
376 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
377 #ifdef ENABLE_BOTTLE_SENSOR |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
378 if(receiveHUDraw[0] == 0xA5) /* code for pressure sensor */ |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
379 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
380 pLivedata->lifeData.bottle_bar[pLivedata->lifeData.actualGas.GasIdInSettings] = receiveHUDraw[10]; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
381 pLivedata->lifeData.bottle_bar_age_MilliSeconds[pLivedata->lifeData.actualGas.GasIdInSettings] = 0; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
382 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
383 else |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
384 #endif |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
385 /* handle O2 sensor data */ |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
386 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
387 memcpy(&receiveHUD[!boolHUDdata], receiveHUDraw, 11); |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
388 receiveHUD[!boolHUDdata].battery_voltage_mV = receiveHUDraw[11] + (256 * receiveHUDraw[12]); |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
389 } |
38 | 390 |
446
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
391 boolHUDdata = !boolHUDdata; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
392 HUDTimeoutCount = 0; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
393 data_old__lost_connection_to_HUD = 0; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
394 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
395 else |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
396 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
397 if(data_old__lost_connection_to_HUD) /* we lost connection, maybe due to RX shift => start single byte read to resynchronize */ |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
398 { |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
399 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1); |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
400 StartListeningToUART_HUD = 0; |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
401 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
402 } |
f1257a32f2d4
Introduced configuration header for variant managment:
ideenmodellierer
parents:
322
diff
changeset
|
403 memset(receiveHUDraw,0,sizeof(receiveHUDraw)); |
38 | 404 } |
405 } | |
406 | |
407 #endif | |
408 /* Private functions ---------------------------------------------------------*/ | |
409 | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
410 static void tCCR_fallbackToFixedSetpoint(void) |
38 | 411 { |
412 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption)) | |
413 { | |
414 uint8_t setpointCbar, actualGasID; | |
415 | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
416 setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar; |
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
417 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint; |
38 | 418 |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
419 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings; |
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
420 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar); |
38 | 421 |
422 set_warning_fallback(); | |
423 } | |
424 } |