Mercurial > public > ostc4
annotate Common/Inc/data_exchange.h @ 684:9bc817e9e221 Betatest
Ignore automatic setpoint changes during ascend:
In the previous version setpoint changes which have been configured for descending were considered for deco calculation in case one or more additional diluents have been activated.
This procedure does not fit to the common way to keep setpoint high till end of the dive in order to get rid of the deco time.
In the new implementation the OSTC assumes that the current setpoint is used till the end of the dive.
author | Ideenmodellierer |
---|---|
date | Thu, 02 Jun 2022 20:24:59 +0200 |
parents | 1b995079c045 |
children | 52d68cf9994c |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Common/Inc/data_exchange.h | |
5 /// \brief Data exchange between RTE and Discovery processors. | |
6 /// \author Heinrichs Weikamp | |
7 /// \date 2018 | |
8 /// | |
9 /// $Id$ | |
10 /////////////////////////////////////////////////////////////////////////////// | |
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
12 /// | |
13 /// This program is free software: you can redistribute it and/or modify | |
14 /// it under the terms of the GNU General Public License as published by | |
15 /// the Free Software Foundation, either version 3 of the License, or | |
16 /// (at your option) any later version. | |
17 /// | |
18 /// This program is distributed in the hope that it will be useful, | |
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 /// GNU General Public License for more details. | |
22 /// | |
23 /// You should have received a copy of the GNU General Public License | |
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 ////////////////////////////////////////////////////////////////////////////// | |
26 | |
27 #ifndef DATA_EXCHANGE_H | |
28 #define DATA_EXCHANGE_H | |
29 | |
30 #include "data_central.h" | |
31 #include "settings.h" | |
32 #include "stm32f4xx_hal.h" | |
33 | |
662 | 34 /* Command definitions for contral of external interface */ |
35 #define EXT_INTERFACE_33V_ON (0x8000u) /* Bit set to enable 3.3V power interface */ | |
36 #define EXT_INTERFACE_CO2_CALIB (0x0001u) /* Request calibration of CO2Sensor */ | |
37 | |
38 | 38 enum MODE |
39 { | |
40 MODE_SURFACE = 0, | |
41 MODE_DIVE = 1, | |
42 MODE_CALIB = 2, | |
43 MODE_SLEEP = 3, | |
44 MODE_SHUTDOWN = 4, | |
45 MODE_ENDDIVE = 5, | |
46 MODE_BOOT = 6, | |
47 MODE_CHARGESTART = 7, | |
48 MODE_TEST = 8, | |
49 MODE_POWERUP = 9, | |
50 }; | |
51 | |
52 enum ACCIDENT_BITS | |
53 { | |
54 ACCIDENT_DECOSTOP = 0x01, | |
55 ACCIDENT_CNS = 0x02, | |
56 ACCIDENT_CNSLVL2 = 0x02 + 0x04, | |
57 ACCIDENT_SPARE2 = 0x08, | |
58 ACCIDENT_SPARE3 = 0x10, | |
59 ACCIDENT_SPARE4 = 0x20, | |
60 ACCIDENT_SPARE5 = 0x40, | |
61 ACCIDENT_SPARE6 = 0x80 | |
62 }; | |
63 | |
64 typedef struct{ | |
65 uint8_t button:1; | |
66 uint8_t date:1; | |
67 uint8_t time:1; | |
68 uint8_t clearDeco:1; | |
69 uint8_t compass:1; | |
70 uint8_t devicedata:1; | |
71 uint8_t batterygauge:1; | |
72 uint8_t accident:1; | |
73 } confirmbit8_t; | |
74 | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
75 typedef struct{ |
559 | 76 uint8_t checkCompass:1; |
77 uint8_t checkADC:1; | |
78 uint8_t reserve:5; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
79 uint8_t extADC:1; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
80 uint8_t compass:8; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
81 } hw_Info_t; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
82 |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
83 |
38 | 84 #define CRBUTTON (0x01) |
85 #define CRDATE (0x02) | |
86 #define CRTIME (0x04) | |
662 | 87 #define CRCLEARDECO (0x08) |
88 #define CRCOMPASS (0x10) | |
89 #define CRDEVICEDATA (0x20) | |
90 #define CRBATTERY (0x40) | |
91 #define CRACCIDENT (0x80) | |
38 | 92 |
93 typedef union{ | |
94 confirmbit8_t ub; | |
95 uint8_t uw; | |
96 } confirmbit8_Type; | |
97 | |
98 typedef struct | |
99 { | |
100 uint8_t checkCode[4]; | |
101 | |
102 } SDataExchangeHeader; | |
103 | |
104 typedef struct | |
105 { | |
106 uint8_t checkCode[4]; | |
107 | |
108 } SDataExchangeFooter; | |
109 | |
110 typedef struct | |
111 { | |
112 SDataExchangeHeader header; | |
113 SLifeData lifeData; | |
114 } SDataExchangeMasterToSlave; | |
115 | |
116 typedef struct | |
117 { | |
118 //pressure | |
119 float temperature; | |
120 float pressure_mbar; | |
121 float surface_mbar; | |
122 float ascent_rate_meter_per_min; | |
123 //toxic | |
124 float otu; | |
125 float cns; | |
126 uint16_t desaturation_time_minutes; | |
127 uint16_t no_fly_time_minutes; | |
128 //tisssue | |
129 float tissue_nitrogen_bar[16]; | |
130 float tissue_helium_bar[16]; | |
131 //maxcrushingpressure | |
132 float max_crushing_pressure_he[16]; | |
133 float max_crushing_pressure_n2[16]; | |
134 float adjusted_critical_radius_he[16]; | |
135 float adjusted_critical_radius_n2[16]; | |
136 // Compass | |
137 float compass_heading; | |
138 float compass_roll; | |
139 float compass_pitch; | |
140 int16_t compass_DX_f; | |
141 int16_t compass_DY_f; | |
142 int16_t compass_DZ_f; | |
143 //time | |
144 uint16_t counterSecondsShallowDepth; | |
145 uint32_t localtime_rtc_tr; | |
146 uint32_t localtime_rtc_dr; | |
147 uint32_t divetime_seconds; | |
148 uint32_t surfacetime_seconds; | |
149 uint32_t dive_time_seconds_without_surface_time; | |
150 //battery /* take care of uint8_t count to be in multiplies of 4 */ | |
151 float battery_voltage; | |
152 float battery_charge; | |
153 //ambient light | |
154 uint16_t ambient_light_level; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
155 uint16_t SPARE_ALIGN32; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
156 float extADC_voltage[3]; |
662 | 157 uint16_t CO2_ppm; |
158 uint16_t CO2_signalStrength; | |
159 uint16_t externalInterface_CmdAnswer; | |
160 uint8_t SPARE_OldWireless[44]; /* 64 - 12 for extADC - 6 for CO2 */ | |
38 | 161 // PIC data |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
162 uint8_t button_setting[4]; /* see dependency to SLiveData->buttonPICdata */ |
38 | 163 uint8_t SPARE1; |
164 //debug | |
165 uint32_t pressure_uTick; | |
166 uint32_t compass_uTick; | |
167 | |
168 } SExchangeData; | |
169 | |
170 typedef struct | |
171 { | |
172 uint8_t VPMconservatism; | |
173 SGas actualGas; | |
174 | |
175 int8_t offsetPressureSensor_mbar; | |
176 int8_t offsetTemperatureSensor_centiDegree; | |
177 | |
662 | 178 uint16_t externalInterface_Cmd; |
38 | 179 |
180 float UNUSED1[16-1];//VPM_adjusted_critical_radius_he[16]; | |
181 float UNUSED2[16];//VPM_adjusted_critical_radius_n2[16]; | |
182 float UNUSED3[16];//VPM_adjusted_crushing_pressure_he[16]; | |
183 float UNUSED4[16];//VPM_adjusted_crushing_pressure_n2[16]; | |
184 float UNUSED5[16];//VPM_initial_allowable_gradient_he[16]; | |
185 float UNUSED6[16];//VPM_initial_allowable_gradient_n2[16]; | |
186 float UNUSED7[16];//VPM_max_actual_gradient[16]; | |
187 | |
188 RTC_TimeTypeDef newTime; | |
189 RTC_DateTypeDef newDate; | |
190 | |
191 float ambient_pressure_mbar_ceiling; | |
192 float descend_rate_bar_per_minute; | |
193 float ascend_rate_bar_per_minute; | |
194 | |
195 uint16_t timeoutDiveReachedZeroDepth; | |
196 uint16_t divetimeToCreateLogbook; | |
197 | |
198 uint8_t buttonResponsiveness[4]; | |
199 | |
200 SDevice DeviceData; | |
201 | |
202 float newBatteryGaugePercentageFloat; | |
203 | |
204 } SReceiveData; | |
205 | |
206 | |
207 typedef struct | |
208 { | |
209 SDataExchangeHeader header; | |
210 | |
211 uint8_t mode; | |
212 uint8_t power_on_reset; | |
213 uint8_t RTE_VERSION_high; | |
214 uint8_t RTE_VERSION_low; | |
215 | |
216 uint8_t chargeStatus; | |
217 uint8_t boolPICdata; | |
218 confirmbit8_Type confirmRequest; // confirmbit8_Type | |
219 uint8_t boolWirelessData; | |
220 | |
221 uint8_t boolPressureData; | |
222 uint8_t boolCompassData; | |
223 uint8_t boolTisssueData; | |
224 uint8_t boolCrushingData; | |
225 | |
226 uint8_t boolToxicData; | |
227 uint8_t boolTimeData; | |
228 uint8_t boolBatteryData; | |
229 uint8_t boolAmbientLightData; | |
230 | |
231 uint8_t accidentFlags; | |
232 uint8_t sensorErrors; | |
233 uint8_t spare2; | |
234 uint8_t spare3; | |
235 | |
236 SExchangeData data[2]; | |
237 SDataExchangeFooter footer; | |
238 uint8_t CRC_feature_by_SPI[4]; | |
239 } SDataExchangeSlaveToMaster; | |
240 | |
241 | |
242 typedef struct | |
243 { | |
244 SDataExchangeHeader header; | |
245 | |
246 uint8_t mode; | |
247 uint8_t power_on_reset; | |
248 uint8_t RTE_VERSION_high; | |
249 uint8_t RTE_VERSION_low; | |
250 | |
251 uint8_t chargeStatus; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
252 hw_Info_t hw_Info; |
38 | 253 uint8_t spare1; |
254 | |
255 uint8_t boolDeviceData; | |
256 uint8_t boolVpmRepetitiveDataValid; | |
257 uint8_t bool3; | |
258 uint8_t bool4; | |
259 | |
260 uint8_t spare1_1; | |
261 uint8_t spare1_2; | |
262 uint8_t spare1_3; | |
263 uint8_t spare1_4; | |
264 | |
265 uint8_t spare2_1; | |
266 uint8_t spare2_2; | |
267 uint8_t spare2_3; | |
268 uint8_t spare2_4; | |
269 | |
270 SDevice DeviceData[2]; | |
271 SVpmRepetitiveData VpmRepetitiveData; | |
272 | |
273 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - ((2 * sizeof(SDevice)) + sizeof(SVpmRepetitiveData))]; | |
274 SDataExchangeFooter footer; | |
275 uint8_t CRC_feature_by_SPI[4]; | |
276 } SDataExchangeSlaveToMasterDeviceData; | |
277 | |
278 | |
279 typedef struct | |
280 { | |
281 SDataExchangeHeader header; | |
282 | |
283 uint8_t mode; | |
284 uint8_t getDeviceDataNow; | |
285 uint8_t diveModeInfo; | |
286 uint8_t setEndDive; | |
287 | |
288 uint8_t bool4; | |
289 uint8_t setButtonSensitivityNow; | |
290 uint8_t setDateNow; | |
291 uint8_t setTimeNow; | |
292 | |
293 uint8_t calibrateCompassNow; | |
294 uint8_t clearDecoNow; | |
295 uint8_t setBatteryGaugeNow; | |
296 uint8_t bool9; | |
297 | |
298 uint8_t revisionHardware; | |
299 uint8_t revisionCRCx0x7A; | |
300 uint8_t spare1_3; | |
301 uint8_t spare1_4; | |
302 | |
303 uint8_t setAccidentFlag; | |
304 uint8_t spare2_1; | |
305 uint8_t spare2_2; | |
306 uint8_t spare2_3; | |
307 | |
308 SReceiveData data; | |
309 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - sizeof(SReceiveData)]; | |
310 SDataExchangeFooter footer; | |
311 uint8_t CRC_feature_by_SPI[4]; | |
312 } SDataReceiveFromMaster; | |
313 | |
314 | |
315 /* Size of Transmission buffer */ | |
316 #define EXCHANGE_BUFFERSIZE (sizeof(SDataExchangeSlaveToMaster) - 2) | |
317 #define EXCHANGE_BUFFERSIZE2 (sizeof(SDataReceiveFromMaster) - 2) | |
318 // header: 5 | |
319 // mode+bool: 5 | |
320 // data 552 ( 69 * float/4 * 2 ) | |
321 // footer: 4 | |
322 // ______________ | |
323 // SUM 566 | |
324 // CRC_feature does not count into BUFFERSIZE! | |
325 | |
326 //(COUNTOF(struct SDataExchangeSlaveToMaster) + 1) | |
327 | |
328 /* Exported macro ------------------------------------------------------------*/ | |
329 //#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) | |
330 | |
331 #endif /* DATA_EXCHANGE_H */ | |
332 |