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