Mercurial > public > ostc4
annotate Common/Inc/data_exchange.h @ 640:f735f1123526
Development bugfix Viewport settings:
Settings of the viewport have been reset after every update. Root cause: plausibility check value has not been adapted to latest implementation.
In addition settings for frame have been overwritten while focus was changed because of an invalid and combination. Both issues have been solved
author | Ideenmodellierer |
---|---|
date | Thu, 11 Mar 2021 21:43:43 +0100 |
parents | 84a4e1200726 |
children | 1b995079c045 |
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 | |
34 enum MODE | |
35 { | |
36 MODE_SURFACE = 0, | |
37 MODE_DIVE = 1, | |
38 MODE_CALIB = 2, | |
39 MODE_SLEEP = 3, | |
40 MODE_SHUTDOWN = 4, | |
41 MODE_ENDDIVE = 5, | |
42 MODE_BOOT = 6, | |
43 MODE_CHARGESTART = 7, | |
44 MODE_TEST = 8, | |
45 MODE_POWERUP = 9, | |
46 }; | |
47 | |
48 enum ACCIDENT_BITS | |
49 { | |
50 ACCIDENT_DECOSTOP = 0x01, | |
51 ACCIDENT_CNS = 0x02, | |
52 ACCIDENT_CNSLVL2 = 0x02 + 0x04, | |
53 ACCIDENT_SPARE2 = 0x08, | |
54 ACCIDENT_SPARE3 = 0x10, | |
55 ACCIDENT_SPARE4 = 0x20, | |
56 ACCIDENT_SPARE5 = 0x40, | |
57 ACCIDENT_SPARE6 = 0x80 | |
58 }; | |
59 | |
60 typedef struct{ | |
61 uint8_t button:1; | |
62 uint8_t date:1; | |
63 uint8_t time:1; | |
64 uint8_t clearDeco:1; | |
65 uint8_t compass:1; | |
66 uint8_t devicedata:1; | |
67 uint8_t batterygauge:1; | |
68 uint8_t accident:1; | |
69 } confirmbit8_t; | |
70 | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
71 typedef struct{ |
559 | 72 uint8_t checkCompass:1; |
73 uint8_t checkADC:1; | |
74 uint8_t reserve:5; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
75 uint8_t extADC:1; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
76 uint8_t compass:8; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
77 } hw_Info_t; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
78 |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
79 |
38 | 80 #define CRBUTTON (0x01) |
81 #define CRDATE (0x02) | |
82 #define CRTIME (0x04) | |
83 #define CRCLEARDECO (0x08) | |
84 #define CRCOMPASS (0x10) | |
85 #define CRDEVICEDATA (0x20) | |
86 | |
87 typedef union{ | |
88 confirmbit8_t ub; | |
89 uint8_t uw; | |
90 } confirmbit8_Type; | |
91 | |
92 typedef struct | |
93 { | |
94 uint8_t checkCode[4]; | |
95 | |
96 } SDataExchangeHeader; | |
97 | |
98 typedef struct | |
99 { | |
100 uint8_t checkCode[4]; | |
101 | |
102 } SDataExchangeFooter; | |
103 | |
104 typedef struct | |
105 { | |
106 SDataExchangeHeader header; | |
107 SLifeData lifeData; | |
108 } SDataExchangeMasterToSlave; | |
109 | |
110 typedef struct | |
111 { | |
112 //pressure | |
113 float temperature; | |
114 float pressure_mbar; | |
115 float surface_mbar; | |
116 float ascent_rate_meter_per_min; | |
117 //toxic | |
118 float otu; | |
119 float cns; | |
120 uint16_t desaturation_time_minutes; | |
121 uint16_t no_fly_time_minutes; | |
122 //tisssue | |
123 float tissue_nitrogen_bar[16]; | |
124 float tissue_helium_bar[16]; | |
125 //maxcrushingpressure | |
126 float max_crushing_pressure_he[16]; | |
127 float max_crushing_pressure_n2[16]; | |
128 float adjusted_critical_radius_he[16]; | |
129 float adjusted_critical_radius_n2[16]; | |
130 // Compass | |
131 float compass_heading; | |
132 float compass_roll; | |
133 float compass_pitch; | |
134 int16_t compass_DX_f; | |
135 int16_t compass_DY_f; | |
136 int16_t compass_DZ_f; | |
137 //time | |
138 uint16_t counterSecondsShallowDepth; | |
139 uint32_t localtime_rtc_tr; | |
140 uint32_t localtime_rtc_dr; | |
141 uint32_t divetime_seconds; | |
142 uint32_t surfacetime_seconds; | |
143 uint32_t dive_time_seconds_without_surface_time; | |
144 //battery /* take care of uint8_t count to be in multiplies of 4 */ | |
145 float battery_voltage; | |
146 float battery_charge; | |
147 //ambient light | |
148 uint16_t ambient_light_level; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
149 uint16_t SPARE_ALIGN32; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
150 float extADC_voltage[3]; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
151 uint8_t SPARE_OldWireless[50]; /* 64 - 12 for extADC */ |
38 | 152 // PIC data |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
153 uint8_t button_setting[4]; /* see dependency to SLiveData->buttonPICdata */ |
38 | 154 uint8_t SPARE1; |
155 //debug | |
156 uint32_t pressure_uTick; | |
157 uint32_t compass_uTick; | |
158 | |
159 } SExchangeData; | |
160 | |
161 typedef struct | |
162 { | |
163 uint8_t VPMconservatism; | |
164 SGas actualGas; | |
165 | |
166 int8_t offsetPressureSensor_mbar; | |
167 int8_t offsetTemperatureSensor_centiDegree; | |
168 | |
169 uint8_t SPARE1; | |
170 uint8_t SPARE2; | |
171 | |
172 float UNUSED1[16-1];//VPM_adjusted_critical_radius_he[16]; | |
173 float UNUSED2[16];//VPM_adjusted_critical_radius_n2[16]; | |
174 float UNUSED3[16];//VPM_adjusted_crushing_pressure_he[16]; | |
175 float UNUSED4[16];//VPM_adjusted_crushing_pressure_n2[16]; | |
176 float UNUSED5[16];//VPM_initial_allowable_gradient_he[16]; | |
177 float UNUSED6[16];//VPM_initial_allowable_gradient_n2[16]; | |
178 float UNUSED7[16];//VPM_max_actual_gradient[16]; | |
179 | |
180 RTC_TimeTypeDef newTime; | |
181 RTC_DateTypeDef newDate; | |
182 | |
183 float ambient_pressure_mbar_ceiling; | |
184 float descend_rate_bar_per_minute; | |
185 float ascend_rate_bar_per_minute; | |
186 | |
187 uint16_t timeoutDiveReachedZeroDepth; | |
188 uint16_t divetimeToCreateLogbook; | |
189 | |
190 uint8_t buttonResponsiveness[4]; | |
191 | |
192 SDevice DeviceData; | |
193 | |
194 float newBatteryGaugePercentageFloat; | |
195 | |
196 } SReceiveData; | |
197 | |
198 | |
199 typedef struct | |
200 { | |
201 SDataExchangeHeader header; | |
202 | |
203 uint8_t mode; | |
204 uint8_t power_on_reset; | |
205 uint8_t RTE_VERSION_high; | |
206 uint8_t RTE_VERSION_low; | |
207 | |
208 uint8_t chargeStatus; | |
209 uint8_t boolPICdata; | |
210 confirmbit8_Type confirmRequest; // confirmbit8_Type | |
211 uint8_t boolWirelessData; | |
212 | |
213 uint8_t boolPressureData; | |
214 uint8_t boolCompassData; | |
215 uint8_t boolTisssueData; | |
216 uint8_t boolCrushingData; | |
217 | |
218 uint8_t boolToxicData; | |
219 uint8_t boolTimeData; | |
220 uint8_t boolBatteryData; | |
221 uint8_t boolAmbientLightData; | |
222 | |
223 uint8_t accidentFlags; | |
224 uint8_t sensorErrors; | |
225 uint8_t spare2; | |
226 uint8_t spare3; | |
227 | |
228 SExchangeData data[2]; | |
229 SDataExchangeFooter footer; | |
230 uint8_t CRC_feature_by_SPI[4]; | |
231 } SDataExchangeSlaveToMaster; | |
232 | |
233 | |
234 typedef struct | |
235 { | |
236 SDataExchangeHeader header; | |
237 | |
238 uint8_t mode; | |
239 uint8_t power_on_reset; | |
240 uint8_t RTE_VERSION_high; | |
241 uint8_t RTE_VERSION_low; | |
242 | |
243 uint8_t chargeStatus; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
244 hw_Info_t hw_Info; |
38 | 245 uint8_t spare1; |
246 | |
247 uint8_t boolDeviceData; | |
248 uint8_t boolVpmRepetitiveDataValid; | |
249 uint8_t bool3; | |
250 uint8_t bool4; | |
251 | |
252 uint8_t spare1_1; | |
253 uint8_t spare1_2; | |
254 uint8_t spare1_3; | |
255 uint8_t spare1_4; | |
256 | |
257 uint8_t spare2_1; | |
258 uint8_t spare2_2; | |
259 uint8_t spare2_3; | |
260 uint8_t spare2_4; | |
261 | |
262 SDevice DeviceData[2]; | |
263 SVpmRepetitiveData VpmRepetitiveData; | |
264 | |
265 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - ((2 * sizeof(SDevice)) + sizeof(SVpmRepetitiveData))]; | |
266 SDataExchangeFooter footer; | |
267 uint8_t CRC_feature_by_SPI[4]; | |
268 } SDataExchangeSlaveToMasterDeviceData; | |
269 | |
270 | |
271 typedef struct | |
272 { | |
273 SDataExchangeHeader header; | |
274 | |
275 uint8_t mode; | |
276 uint8_t getDeviceDataNow; | |
277 uint8_t diveModeInfo; | |
278 uint8_t setEndDive; | |
279 | |
280 uint8_t bool4; | |
281 uint8_t setButtonSensitivityNow; | |
282 uint8_t setDateNow; | |
283 uint8_t setTimeNow; | |
284 | |
285 uint8_t calibrateCompassNow; | |
286 uint8_t clearDecoNow; | |
287 uint8_t setBatteryGaugeNow; | |
288 uint8_t bool9; | |
289 | |
290 uint8_t revisionHardware; | |
291 uint8_t revisionCRCx0x7A; | |
292 uint8_t spare1_3; | |
293 uint8_t spare1_4; | |
294 | |
295 uint8_t setAccidentFlag; | |
296 uint8_t spare2_1; | |
297 uint8_t spare2_2; | |
298 uint8_t spare2_3; | |
299 | |
300 SReceiveData data; | |
301 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - sizeof(SReceiveData)]; | |
302 SDataExchangeFooter footer; | |
303 uint8_t CRC_feature_by_SPI[4]; | |
304 } SDataReceiveFromMaster; | |
305 | |
306 | |
307 /* Size of Transmission buffer */ | |
308 #define EXCHANGE_BUFFERSIZE (sizeof(SDataExchangeSlaveToMaster) - 2) | |
309 #define EXCHANGE_BUFFERSIZE2 (sizeof(SDataReceiveFromMaster) - 2) | |
310 // header: 5 | |
311 // mode+bool: 5 | |
312 // data 552 ( 69 * float/4 * 2 ) | |
313 // footer: 4 | |
314 // ______________ | |
315 // SUM 566 | |
316 // CRC_feature does not count into BUFFERSIZE! | |
317 | |
318 //(COUNTOF(struct SDataExchangeSlaveToMaster) + 1) | |
319 | |
320 /* Exported macro ------------------------------------------------------------*/ | |
321 //#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) | |
322 | |
323 #endif /* DATA_EXCHANGE_H */ | |
324 |