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