Mercurial > public > ostc4
annotate Common/Inc/data_exchange.h @ 955:9b29995d6619 Evo_2_23 tip
GNSS backup position:
In the previous implementation a position had to be provided by the module in order to be stored in the log. This may cause a wrong position entry (default) in the log, for example if signal is lost while preparing for the dive in the water. To avoid this the last received position will be used for ~2 hours => Diver may take the dive side position before starting with the dive preparation. The last known position will be display in the GNSS position search window as well.
author | Ideenmodellierer |
---|---|
date | Wed, 01 Jan 2025 20:37:17 +0100 |
parents | e9c37071933b |
children |
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 */ | |
951 | 41 #define EXT_INTERFACE_BUZZER_ON (0x2000u) /* Bit set to enable the buzzer */ |
702
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
42 |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
43 /* Command subset */ |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
44 #define EXT_INTERFACE_AUTODETECT (0x0001u) /* Start auto detection of connected sensors */ |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
45 #define EXT_INTERFACE_COPY_SENSORMAP (0x0002u) /* Use the sensor map provided by master for internal operations */ |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
46 #define EXT_INTERFACE_CO2_CALIB (0x0010u) /* Request calibration of CO2Sensor */ |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
47 #define EXT_INTERFACE_O2_INDICATE (0x0020u) /* Request LED to blink*/ |
702
6d7c812fc173
Added digital o2 sensor to settings and data exchange:
Ideenmodellierer
parents:
691
diff
changeset
|
48 |
691 | 49 #define DATA_BUFFER_ADC (0x01u) |
50 #define DATA_BUFFER_CO2 (0x02u) | |
662 | 51 |
714
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
52 #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
|
53 |
756 | 54 #define CO2_WARNING_LEVEL_PPM (2000u) /* Early warning to indicate unexpected high co2 concentration (yellow) */ |
55 #define CO2_ALARM_LEVEL_PPM (5000u) /* starting by this level CO2 has a negative impact on health (long exposure) */ | |
56 | |
949 | 57 #define GNSS_ALIVE_STATE_ALIVE (0x01u) /* Communication to module active */ |
58 #define GNSS_ALIVE_STATE_TIME (0x02u) /* Time information valid */ | |
955 | 59 #define GNSS_ALIVE_BACKUP_POS (0x04u) /* Backup position not older than x hours */ |
949 | 60 |
38 | 61 enum MODE |
62 { | |
63 MODE_SURFACE = 0, | |
64 MODE_DIVE = 1, | |
65 MODE_CALIB = 2, | |
66 MODE_SLEEP = 3, | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
67 MODE_SHUTDOWN = 4, |
38 | 68 MODE_ENDDIVE = 5, |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
69 MODE_BOOT = 6, |
38 | 70 MODE_CHARGESTART = 7, |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
71 MODE_TEST = 8, |
38 | 72 MODE_POWERUP = 9, |
73 }; | |
74 | |
75 enum ACCIDENT_BITS | |
76 { | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
77 ACCIDENT_DECOSTOP = 0x01, |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
78 ACCIDENT_CNS = 0x02, |
38 | 79 ACCIDENT_CNSLVL2 = 0x02 + 0x04, |
80 ACCIDENT_SPARE2 = 0x08, | |
81 ACCIDENT_SPARE3 = 0x10, | |
82 ACCIDENT_SPARE4 = 0x20, | |
83 ACCIDENT_SPARE5 = 0x40, | |
84 ACCIDENT_SPARE6 = 0x80 | |
85 }; | |
86 | |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
87 |
38 | 88 typedef struct{ |
89 uint8_t button:1; | |
90 uint8_t date:1; | |
91 uint8_t time:1; | |
92 uint8_t clearDeco:1; | |
93 uint8_t compass:1; | |
94 uint8_t devicedata:1; | |
95 uint8_t batterygauge:1; | |
96 uint8_t accident:1; | |
97 } confirmbit8_t; | |
98 | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
99 typedef struct{ |
559 | 100 uint8_t checkCompass:1; |
101 uint8_t checkADC:1; | |
102 uint8_t reserve:5; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
103 uint8_t extADC:1; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
104 uint8_t compass:8; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
105 } hw_Info_t; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
106 |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
107 |
38 | 108 #define CRBUTTON (0x01) |
109 #define CRDATE (0x02) | |
110 #define CRTIME (0x04) | |
662 | 111 #define CRCLEARDECO (0x08) |
112 #define CRCOMPASS (0x10) | |
113 #define CRDEVICEDATA (0x20) | |
114 #define CRBATTERY (0x40) | |
115 #define CRACCIDENT (0x80) | |
38 | 116 |
117 typedef union{ | |
118 confirmbit8_t ub; | |
119 uint8_t uw; | |
120 } confirmbit8_Type; | |
121 | |
122 typedef struct | |
123 { | |
124 uint8_t checkCode[4]; | |
125 | |
126 } SDataExchangeHeader; | |
127 | |
128 typedef struct | |
129 { | |
130 uint8_t checkCode[4]; | |
131 | |
132 } SDataExchangeFooter; | |
133 | |
134 typedef struct | |
135 { | |
136 SDataExchangeHeader header; | |
137 SLifeData lifeData; | |
138 } SDataExchangeMasterToSlave; | |
139 | |
140 typedef struct | |
141 { | |
714
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
142 int32_t temperature; |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
143 uint32_t status; |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
144 uint64_t sensorId; |
723 | 145 int32_t intensity; |
146 int32_t ambient; | |
147 int32_t pressure; | |
148 int32_t humidity; | |
714
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
149 } SSensorDataDiveO2; |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
150 |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
151 typedef struct |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
152 { |
38 | 153 //pressure |
154 float temperature; | |
155 float pressure_mbar; | |
156 float surface_mbar; | |
157 float ascent_rate_meter_per_min; | |
158 //toxic | |
159 float otu; | |
160 float cns; | |
161 uint16_t desaturation_time_minutes; | |
162 uint16_t no_fly_time_minutes; | |
163 //tisssue | |
164 float tissue_nitrogen_bar[16]; | |
165 float tissue_helium_bar[16]; | |
166 //maxcrushingpressure | |
167 float max_crushing_pressure_he[16]; | |
168 float max_crushing_pressure_n2[16]; | |
169 float adjusted_critical_radius_he[16]; | |
170 float adjusted_critical_radius_n2[16]; | |
171 // Compass | |
172 float compass_heading; | |
173 float compass_roll; | |
174 float compass_pitch; | |
175 int16_t compass_DX_f; | |
176 int16_t compass_DY_f; | |
177 int16_t compass_DZ_f; | |
178 //time | |
179 uint16_t counterSecondsShallowDepth; | |
180 uint32_t localtime_rtc_tr; | |
181 uint32_t localtime_rtc_dr; | |
182 uint32_t divetime_seconds; | |
183 uint32_t surfacetime_seconds; | |
184 uint32_t dive_time_seconds_without_surface_time; | |
185 //battery /* take care of uint8_t count to be in multiplies of 4 */ | |
186 float battery_voltage; | |
187 float battery_charge; | |
188 //ambient light | |
189 uint16_t ambient_light_level; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
190 uint16_t SPARE_ALIGN32; |
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
191 float extADC_voltage[3]; |
662 | 192 uint16_t CO2_ppm; |
193 uint16_t CO2_signalStrength; | |
194 uint16_t externalInterface_CmdAnswer; | |
714
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
195 uint8_t alignmentdummy; |
045ff7800501
Added customizable data area for specific sensor data:
Ideenmodellierer
parents:
702
diff
changeset
|
196 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
|
197 uint8_t sensor_data[EXTIF_SENSOR_INFO_SIZE]; /* sensor specific data array. Content may vary from sensor type to sensor type */ |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
198 uint8_t sensor_map[EXT_INTERFACE_SENSOR_CNT]; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
199 uint8_t SPARE_OldWireless[5]; /* 64 - 12 for extADC - 6 for CO2 - 34 for sensor (+dummmy) - sensor map*/ |
38 | 200 // PIC data |
763
aa6006975e76
increase HAL_Delay to 10ms for cold-start-button reset
heinrichsweikamp
parents:
756
diff
changeset
|
201 uint8_t button_setting[4]; /* see dependency to SlaveData->buttonPICdata */ |
38 | 202 uint8_t SPARE1; |
203 //debug | |
204 uint32_t pressure_uTick; | |
205 uint32_t compass_uTick; | |
931 | 206 SGnssInfo gnssInfo; |
38 | 207 |
208 } SExchangeData; | |
209 | |
210 typedef struct | |
211 { | |
212 uint8_t VPMconservatism; | |
213 SGas actualGas; | |
214 | |
215 int8_t offsetPressureSensor_mbar; | |
216 int8_t offsetTemperatureSensor_centiDegree; | |
217 | |
662 | 218 uint16_t externalInterface_Cmd; |
38 | 219 |
728
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
220 uint8_t externalInterface_SensorMap[EXT_INTERFACE_SENSOR_CNT]; |
5143e927219f
Added sensor map to Firmware <=> RTE inferface:
Ideenmodellierer
parents:
723
diff
changeset
|
221 |
38 | 222 float UNUSED1[16-1];//VPM_adjusted_critical_radius_he[16]; |
223 float UNUSED2[16];//VPM_adjusted_critical_radius_n2[16]; | |
224 float UNUSED3[16];//VPM_adjusted_crushing_pressure_he[16]; | |
225 float UNUSED4[16];//VPM_adjusted_crushing_pressure_n2[16]; | |
226 float UNUSED5[16];//VPM_initial_allowable_gradient_he[16]; | |
227 float UNUSED6[16];//VPM_initial_allowable_gradient_n2[16]; | |
228 float UNUSED7[16];//VPM_max_actual_gradient[16]; | |
229 | |
230 RTC_TimeTypeDef newTime; | |
231 RTC_DateTypeDef newDate; | |
232 | |
233 float ambient_pressure_mbar_ceiling; | |
234 float descend_rate_bar_per_minute; | |
235 float ascend_rate_bar_per_minute; | |
236 | |
237 uint16_t timeoutDiveReachedZeroDepth; | |
238 uint16_t divetimeToCreateLogbook; | |
239 | |
240 uint8_t buttonResponsiveness[4]; | |
241 | |
242 SDevice DeviceData; | |
243 | |
244 float newBatteryGaugePercentageFloat; | |
245 | |
246 } SReceiveData; | |
247 | |
248 | |
249 typedef struct | |
250 { | |
251 SDataExchangeHeader header; | |
252 | |
253 uint8_t mode; | |
254 uint8_t power_on_reset; | |
255 uint8_t RTE_VERSION_high; | |
256 uint8_t RTE_VERSION_low; | |
257 | |
258 uint8_t chargeStatus; | |
259 uint8_t boolPICdata; | |
260 confirmbit8_Type confirmRequest; // confirmbit8_Type | |
691 | 261 uint8_t boolADCO2Data; |
38 | 262 |
263 uint8_t boolPressureData; | |
264 uint8_t boolCompassData; | |
265 uint8_t boolTisssueData; | |
266 uint8_t boolCrushingData; | |
267 | |
268 uint8_t boolToxicData; | |
269 uint8_t boolTimeData; | |
270 uint8_t boolBatteryData; | |
271 uint8_t boolAmbientLightData; | |
272 | |
273 uint8_t accidentFlags; | |
274 uint8_t sensorErrors; | |
275 uint8_t spare2; | |
276 uint8_t spare3; | |
277 | |
278 SExchangeData data[2]; | |
279 SDataExchangeFooter footer; | |
280 uint8_t CRC_feature_by_SPI[4]; | |
281 } SDataExchangeSlaveToMaster; | |
282 | |
283 | |
284 typedef struct | |
285 { | |
286 SDataExchangeHeader header; | |
287 | |
288 uint8_t mode; | |
289 uint8_t power_on_reset; | |
290 uint8_t RTE_VERSION_high; | |
291 uint8_t RTE_VERSION_low; | |
292 | |
293 uint8_t chargeStatus; | |
555
573a2bc796c8
Added HW_Info to Discovery <=> RTE data exchange:
Ideenmodellierer
parents:
51
diff
changeset
|
294 hw_Info_t hw_Info; |
38 | 295 uint8_t spare1; |
296 | |
297 uint8_t boolDeviceData; | |
298 uint8_t boolVpmRepetitiveDataValid; | |
299 uint8_t bool3; | |
300 uint8_t bool4; | |
301 | |
302 uint8_t spare1_1; | |
303 uint8_t spare1_2; | |
304 uint8_t spare1_3; | |
305 uint8_t spare1_4; | |
306 | |
307 uint8_t spare2_1; | |
308 uint8_t spare2_2; | |
309 uint8_t spare2_3; | |
310 uint8_t spare2_4; | |
311 | |
312 SDevice DeviceData[2]; | |
313 SVpmRepetitiveData VpmRepetitiveData; | |
314 | |
315 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - ((2 * sizeof(SDevice)) + sizeof(SVpmRepetitiveData))]; | |
316 SDataExchangeFooter footer; | |
317 uint8_t CRC_feature_by_SPI[4]; | |
318 } SDataExchangeSlaveToMasterDeviceData; | |
319 | |
320 | |
321 typedef struct | |
322 { | |
323 SDataExchangeHeader header; | |
324 | |
325 uint8_t mode; | |
326 uint8_t getDeviceDataNow; | |
327 uint8_t diveModeInfo; | |
328 uint8_t setEndDive; | |
329 | |
330 uint8_t bool4; | |
331 uint8_t setButtonSensitivityNow; | |
332 uint8_t setDateNow; | |
333 uint8_t setTimeNow; | |
334 | |
335 uint8_t calibrateCompassNow; | |
336 uint8_t clearDecoNow; | |
337 uint8_t setBatteryGaugeNow; | |
338 uint8_t bool9; | |
339 | |
340 uint8_t revisionHardware; | |
341 uint8_t revisionCRCx0x7A; | |
342 uint8_t spare1_3; | |
343 uint8_t spare1_4; | |
344 | |
345 uint8_t setAccidentFlag; | |
346 uint8_t spare2_1; | |
347 uint8_t spare2_2; | |
348 uint8_t spare2_3; | |
349 | |
350 SReceiveData data; | |
351 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - sizeof(SReceiveData)]; | |
352 SDataExchangeFooter footer; | |
353 uint8_t CRC_feature_by_SPI[4]; | |
354 } SDataReceiveFromMaster; | |
355 | |
356 | |
357 /* Size of Transmission buffer */ | |
358 #define EXCHANGE_BUFFERSIZE (sizeof(SDataExchangeSlaveToMaster) - 2) | |
359 #define EXCHANGE_BUFFERSIZE2 (sizeof(SDataReceiveFromMaster) - 2) | |
360 // header: 5 | |
361 // mode+bool: 5 | |
362 // data 552 ( 69 * float/4 * 2 ) | |
363 // footer: 4 | |
364 // ______________ | |
365 // SUM 566 | |
366 // CRC_feature does not count into BUFFERSIZE! | |
367 | |
368 //(COUNTOF(struct SDataExchangeSlaveToMaster) + 1) | |
369 | |
370 /* Exported macro ------------------------------------------------------------*/ | |
371 //#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) | |
372 | |
373 #endif /* DATA_EXCHANGE_H */ | |
374 |