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