Mercurial > public > ostc4
annotate Common/Inc/data_exchange.h @ 549:469e93f8633e
Only execute motion detection functions if features is enabled:
Added compile switch around function and, in case the switch is on, an additional check if the features is activated by the settings.
Added function to add an additional level of brightness to the backlight:
The new interface allows to increase the brightness of the display on top of the normal setting. This may be used to indicate focus state to the user if motion detection is enabled
author | Ideenmodellierer |
---|---|
date | Sun, 08 Nov 2020 18:36:02 +0100 |
parents | 8f8ea3a32e82 |
children | 573a2bc796c8 |
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 | |
71 #define CRBUTTON (0x01) | |
72 #define CRDATE (0x02) | |
73 #define CRTIME (0x04) | |
74 #define CRCLEARDECO (0x08) | |
75 #define CRCOMPASS (0x10) | |
76 #define CRDEVICEDATA (0x20) | |
77 | |
78 typedef union{ | |
79 confirmbit8_t ub; | |
80 uint8_t uw; | |
81 } confirmbit8_Type; | |
82 | |
83 typedef struct | |
84 { | |
85 uint8_t checkCode[4]; | |
86 | |
87 } SDataExchangeHeader; | |
88 | |
89 typedef struct | |
90 { | |
91 uint8_t checkCode[4]; | |
92 | |
93 } SDataExchangeFooter; | |
94 | |
95 typedef struct | |
96 { | |
97 SDataExchangeHeader header; | |
98 SLifeData lifeData; | |
99 } SDataExchangeMasterToSlave; | |
100 | |
101 typedef struct | |
102 { | |
103 //pressure | |
104 float temperature; | |
105 float pressure_mbar; | |
106 float surface_mbar; | |
107 float ascent_rate_meter_per_min; | |
108 //toxic | |
109 float otu; | |
110 float cns; | |
111 uint16_t desaturation_time_minutes; | |
112 uint16_t no_fly_time_minutes; | |
113 //tisssue | |
114 float tissue_nitrogen_bar[16]; | |
115 float tissue_helium_bar[16]; | |
116 //maxcrushingpressure | |
117 float max_crushing_pressure_he[16]; | |
118 float max_crushing_pressure_n2[16]; | |
119 float adjusted_critical_radius_he[16]; | |
120 float adjusted_critical_radius_n2[16]; | |
121 // Compass | |
122 float compass_heading; | |
123 float compass_roll; | |
124 float compass_pitch; | |
125 int16_t compass_DX_f; | |
126 int16_t compass_DY_f; | |
127 int16_t compass_DZ_f; | |
128 //time | |
129 uint16_t counterSecondsShallowDepth; | |
130 uint32_t localtime_rtc_tr; | |
131 uint32_t localtime_rtc_dr; | |
132 uint32_t divetime_seconds; | |
133 uint32_t surfacetime_seconds; | |
134 uint32_t dive_time_seconds_without_surface_time; | |
135 //battery /* take care of uint8_t count to be in multiplies of 4 */ | |
136 float battery_voltage; | |
137 float battery_charge; | |
138 //ambient light | |
139 uint16_t ambient_light_level; | |
140 // wireless data | |
141 SDataWireless wireless_data[4]; | |
142 // PIC data | |
51
8f8ea3a32e82
Resolved warnings pointing to possible invalid memory access
Ideenmodellierer
parents:
38
diff
changeset
|
143 uint8_t button_setting[4]; /* see dependency to SLiveData->buttonPICdata */ |
38 | 144 uint8_t SPARE1; |
145 //debug | |
146 uint32_t pressure_uTick; | |
147 uint32_t compass_uTick; | |
148 | |
149 } SExchangeData; | |
150 | |
151 typedef struct | |
152 { | |
153 uint8_t VPMconservatism; | |
154 SGas actualGas; | |
155 | |
156 int8_t offsetPressureSensor_mbar; | |
157 int8_t offsetTemperatureSensor_centiDegree; | |
158 | |
159 uint8_t SPARE1; | |
160 uint8_t SPARE2; | |
161 | |
162 float UNUSED1[16-1];//VPM_adjusted_critical_radius_he[16]; | |
163 float UNUSED2[16];//VPM_adjusted_critical_radius_n2[16]; | |
164 float UNUSED3[16];//VPM_adjusted_crushing_pressure_he[16]; | |
165 float UNUSED4[16];//VPM_adjusted_crushing_pressure_n2[16]; | |
166 float UNUSED5[16];//VPM_initial_allowable_gradient_he[16]; | |
167 float UNUSED6[16];//VPM_initial_allowable_gradient_n2[16]; | |
168 float UNUSED7[16];//VPM_max_actual_gradient[16]; | |
169 | |
170 RTC_TimeTypeDef newTime; | |
171 RTC_DateTypeDef newDate; | |
172 | |
173 float ambient_pressure_mbar_ceiling; | |
174 float descend_rate_bar_per_minute; | |
175 float ascend_rate_bar_per_minute; | |
176 | |
177 uint16_t timeoutDiveReachedZeroDepth; | |
178 uint16_t divetimeToCreateLogbook; | |
179 | |
180 uint8_t buttonResponsiveness[4]; | |
181 | |
182 SDevice DeviceData; | |
183 | |
184 float newBatteryGaugePercentageFloat; | |
185 | |
186 } SReceiveData; | |
187 | |
188 | |
189 typedef struct | |
190 { | |
191 SDataExchangeHeader header; | |
192 | |
193 uint8_t mode; | |
194 uint8_t power_on_reset; | |
195 uint8_t RTE_VERSION_high; | |
196 uint8_t RTE_VERSION_low; | |
197 | |
198 uint8_t chargeStatus; | |
199 uint8_t boolPICdata; | |
200 confirmbit8_Type confirmRequest; // confirmbit8_Type | |
201 uint8_t boolWirelessData; | |
202 | |
203 uint8_t boolPressureData; | |
204 uint8_t boolCompassData; | |
205 uint8_t boolTisssueData; | |
206 uint8_t boolCrushingData; | |
207 | |
208 uint8_t boolToxicData; | |
209 uint8_t boolTimeData; | |
210 uint8_t boolBatteryData; | |
211 uint8_t boolAmbientLightData; | |
212 | |
213 uint8_t accidentFlags; | |
214 uint8_t sensorErrors; | |
215 uint8_t spare2; | |
216 uint8_t spare3; | |
217 | |
218 SExchangeData data[2]; | |
219 SDataExchangeFooter footer; | |
220 uint8_t CRC_feature_by_SPI[4]; | |
221 } SDataExchangeSlaveToMaster; | |
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 spare1; | |
235 uint8_t spare2; | |
236 uint8_t spare3; | |
237 | |
238 uint8_t boolDeviceData; | |
239 uint8_t boolVpmRepetitiveDataValid; | |
240 uint8_t bool3; | |
241 uint8_t bool4; | |
242 | |
243 uint8_t spare1_1; | |
244 uint8_t spare1_2; | |
245 uint8_t spare1_3; | |
246 uint8_t spare1_4; | |
247 | |
248 uint8_t spare2_1; | |
249 uint8_t spare2_2; | |
250 uint8_t spare2_3; | |
251 uint8_t spare2_4; | |
252 | |
253 SDevice DeviceData[2]; | |
254 SVpmRepetitiveData VpmRepetitiveData; | |
255 | |
256 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - ((2 * sizeof(SDevice)) + sizeof(SVpmRepetitiveData))]; | |
257 SDataExchangeFooter footer; | |
258 uint8_t CRC_feature_by_SPI[4]; | |
259 } SDataExchangeSlaveToMasterDeviceData; | |
260 | |
261 | |
262 typedef struct | |
263 { | |
264 SDataExchangeHeader header; | |
265 | |
266 uint8_t mode; | |
267 uint8_t getDeviceDataNow; | |
268 uint8_t diveModeInfo; | |
269 uint8_t setEndDive; | |
270 | |
271 uint8_t bool4; | |
272 uint8_t setButtonSensitivityNow; | |
273 uint8_t setDateNow; | |
274 uint8_t setTimeNow; | |
275 | |
276 uint8_t calibrateCompassNow; | |
277 uint8_t clearDecoNow; | |
278 uint8_t setBatteryGaugeNow; | |
279 uint8_t bool9; | |
280 | |
281 uint8_t revisionHardware; | |
282 uint8_t revisionCRCx0x7A; | |
283 uint8_t spare1_3; | |
284 uint8_t spare1_4; | |
285 | |
286 uint8_t setAccidentFlag; | |
287 uint8_t spare2_1; | |
288 uint8_t spare2_2; | |
289 uint8_t spare2_3; | |
290 | |
291 SReceiveData data; | |
292 uint8_t arraySizeOfMinimumSExChangeDate[(2 * sizeof(SExchangeData)) - sizeof(SReceiveData)]; | |
293 SDataExchangeFooter footer; | |
294 uint8_t CRC_feature_by_SPI[4]; | |
295 } SDataReceiveFromMaster; | |
296 | |
297 | |
298 /* Size of Transmission buffer */ | |
299 #define EXCHANGE_BUFFERSIZE (sizeof(SDataExchangeSlaveToMaster) - 2) | |
300 #define EXCHANGE_BUFFERSIZE2 (sizeof(SDataReceiveFromMaster) - 2) | |
301 // header: 5 | |
302 // mode+bool: 5 | |
303 // data 552 ( 69 * float/4 * 2 ) | |
304 // footer: 4 | |
305 // ______________ | |
306 // SUM 566 | |
307 // CRC_feature does not count into BUFFERSIZE! | |
308 | |
309 //(COUNTOF(struct SDataExchangeSlaveToMaster) + 1) | |
310 | |
311 /* Exported macro ------------------------------------------------------------*/ | |
312 //#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__))) | |
313 | |
314 #endif /* DATA_EXCHANGE_H */ | |
315 |