Mercurial > public > hwos_code
annotate src/shared_definitions.h @ 580:1ab93aca7fa9
2.97 work...
author | heinrichsweikamp |
---|---|
date | Wed, 21 Feb 2018 19:30:28 +0100 |
parents | b7eb98dbd800 |
children | b455b31ce022 |
rev | line source |
---|---|
0 | 1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
2 ; | |
560 | 3 ; shared_definitions.h REFACTORED VERSION V2.95a1 |
0 | 4 ; |
5 ; Declare variables used both in C and ASM code | |
6 ; | |
7 ; This program is free software: you can redistribute it and/or modify | |
8 ; it under the terms of the GNU General Public License as published by | |
9 ; the Free Software Foundation, either version 3 of the License, or | |
10 ; (at your option) any later version. | |
11 ; | |
12 ; This program is distributed in the hope that it will be useful, | |
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ; GNU General Public License for more details. | |
16 ; | |
17 ; You should have received a copy of the GNU General Public License | |
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 ; | |
20 ; Copyright (c) 2010, JD Gascuel. | |
21 ;============================================================================= | |
22 ; RATIONAL | |
23 ; | |
24 ; We must enforce good data passing between the C and the ASM parts of code. | |
25 ; The previous design used two independant definitions of each variable, | |
26 ; one in C, one in ASM. If they did not match, no error was generated, and | |
27 ; anything can happend at runtime... | |
28 ; | |
29 ; The new design use LINKING to ensure the variables defined in C are at the | |
30 ; same address when used in ASM code. And it uses a unique declaration file | |
31 ; (with suitable macros) to make sure they have the same size in both language. | |
32 ; | |
33 ; HISTORY | |
34 ; 2011-01-20: [jDG] Creation. | |
35 ; | |
36 ; NOTE | |
37 ; | |
38 ; This file have to obey both ASM and C syntax. The only common directives | |
39 ; are #if/#ifdef/#endif and the #define, so they are eavily used to do the | |
40 ; trick. | |
41 ; | |
42 ; BUGS | |
43 ;============================================================================= | |
44 ; HISTORY | |
45 #endif | |
46 | |
47 #ifdef __18CXX | |
48 //------------------------------------------------------------------------ | |
49 // C-style declarations: | |
50 # ifndef TEST_MAIN | |
51 # define VAR_UCHAR(n) extern unsigned char n | |
52 # define TAB_UCHAR(n,size) extern unsigned char n[size] | |
53 # define VAR_UINT(n) extern unsigned short n | |
54 # define TAB_UINT(n,size) extern unsigned short n[size] | |
55 # else | |
56 # define VAR_UCHAR(n) unsigned char n | |
57 # define TAB_UCHAR(n,size) unsigned char n[size] | |
58 # define VAR_UINT(n) unsigned short n | |
59 # define TAB_UINT(n,size) unsigned short n[size] | |
60 # endif | |
61 #else | |
62 ;------------------------------------------------------------------------- | |
63 ; ASM-style declarations: | |
64 #define VAR_UCHAR(n) n res 1 | |
65 #define TAB_UCHAR(n,size) n res size | |
66 #define VAR_UINT(n) n res 2 | |
67 #define TAB_UINT(n,size) n res 2*size | |
68 #endif | |
69 | |
210
7dbc1d780ca5
do not clear char_O_deco_gas in copy_deco_table
heinrichsweikamp
parents:
126
diff
changeset
|
70 |
0 | 71 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
72 Define model dimensions. | |
73 NUM_COMP is the number of compartiments in the Bühlmann ZH-L16 model, ie 16. | |
74 NUM_STOPS is the maximum number of stops computed by decoplanning. | |
560 | 75 Note that the deepest stop is roughly limited to 3m * NUM_STOPS |
0 | 76 (this is assuming all stops up to the surface are used). |
77 Note also that if the table overflow, extra stops are ignored, | |
78 and not reported in TTS summing. | |
79 NUM_GAS is the number of (potentially) active gas considered during | |
80 ascent simulation. | |
81 #endif | |
82 #define NUM_COMP 0x10 | |
83 #define NUM_STOPS 0x20 | |
84 #define NUM_GAS 5 | |
85 | |
560 | 86 |
87 #ifdef __18CXX | |
88 //---- BANK 3 DATA ------------------------------------------------------- | |
89 // Gather all data C-code --> ASM-code | |
90 # pragma udata overlay bank3=0x300 | |
91 #else | |
92 ; In ASM, put the same bank, in overlay mode, at the same address | |
93 bank3 udata_ovr 0x300 | |
94 #endif | |
95 | |
96 VAR_UINT (int_O_gtissue_press); // pressure of leading compartment | |
97 | |
98 VAR_UINT (int_O_desaturation_time); // time until tissues desaturated to 5% remains, in minutes | |
99 VAR_UINT (int_O_nofly_time); // altitude / no-fly waiting time time in minutes | |
100 | |
101 VAR_UINT (int_O_ascenttime); // time-to-surface (TTS) in minutes | |
102 VAR_UINT (int_O_alternate_ascenttime); // TTS for the alternative dive plan | |
103 | |
104 VAR_UINT (int_O_CNS_fraction); // current CNS% | |
105 VAR_UINT (int_O_normal_CNS_fraction); // CNS% at end of dive in normal dive plan | |
106 VAR_UINT (int_O_alternate_CNS_fraction); // CNS% at end of dive in alternative plan | |
107 | |
108 VAR_UINT (int_O_gradient_factor); // current gradient factor in % | |
109 | |
110 VAR_UCHAR (char_O_nullzeit); // remaining NDL time in minutes | |
111 VAR_UCHAR (char_O_alternate_nullzeit); // remaining NDL time for the alternative dive plan | |
0 | 112 |
560 | 113 VAR_UCHAR (char_O_main_status); // setup of the deco engine regarding the real tissue computations |
114 VAR_UCHAR (char_O_deco_status); // setup of the deco engine regarding the decompression computations | |
115 | |
116 VAR_UCHAR (char_O_gtissue_no); // number of the leading compartment | |
117 | |
118 VAR_UCHAR (char_O_EAD); // equivalent air depth (EAD) of breathed gas | |
119 VAR_UCHAR (char_O_END); // equivalent narcosis depth (END) of breathed gas | |
120 | |
121 VAR_UCHAR (char_O_first_deco_depth); // depth of first stop (deco or gas change) | |
122 VAR_UCHAR (char_O_first_deco_time) ; // duration of first stop | |
123 | |
124 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // stops table: depth, ... | |
125 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // ... duration, and | |
126 TAB_UCHAR (char_O_deco_gas, NUM_STOPS); // ... gas breathed | |
0 | 127 |
560 | 128 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS); // variant of the stops table for logging purpose |
129 | |
130 TAB_UCHAR (char_O_tissue_N2_saturation, NUM_COMP); // nitrogen tissue pressures for display purpose | |
131 TAB_UCHAR (char_O_tissue_He_saturation, NUM_COMP); // helium tissue pressures for display purpose | |
132 | |
133 VAR_UCHAR (char_O_deco_warnings); // vector of warnings generated by the deco engine | |
0 | 134 |
560 | 135 TAB_UINT (int_O_gas_volumes, NUM_GAS); // gas volumes needed in liters |
136 TAB_UINT (int_O_tank_pres_need, NUM_GAS); // tank pressures needed in bar | |
137 VAR_UINT (int_O_ceiling); // ultimate ascent bound in mbar relative pressure | |
0 | 138 |
560 | 139 VAR_UINT (int_O_O2_ppO2); // ppO2 of pure O2 at current depth |
140 VAR_UINT (int_O_pure_ppO2); // ppO2 of the current gas or dil if breathed pure | |
141 VAR_UINT (int_O_pSCR_ppO2); // ppO2 calculated in pSCR loop | |
142 VAR_UINT (int_O_breathed_ppO2); // ppO2 actually breathed (= char_O_pure_ppO2 if in OC) | |
143 | |
0 | 144 |
145 #ifdef __18CXX | |
146 //---- BANK 4 DATA ------------------------------------------------------- | |
147 // Gather all data ASM-code --> C-code | |
148 # pragma udata overlay bank4=0x400 | |
149 #else | |
150 ; In ASM, put the same bank, in overlay mode, at the same address | |
151 bank4 udata_ovr 0x400 | |
152 #endif | |
153 | |
560 | 154 VAR_UINT (int_I_pres_respiration); // absolute pressure breathed |
155 VAR_UINT (int_I_pres_surface); // absolute pressure at surface | |
156 | |
157 VAR_UCHAR (char_I_current_gas); // number of gas currently breathed (1..5 for configured gases, 6 for the manual gas) | |
158 VAR_UCHAR (char_I_He_ratio); // helium ratio of the currently breathed gas | |
159 VAR_UCHAR (char_I_O2_ratio); // oxygen ratio of the currently breathed gas | |
160 | |
161 VAR_UCHAR (char_I_saturation_multiplier); // safety factor, 100 = no conservatism, 150 = 50% faster saturation | |
162 VAR_UCHAR (char_I_desaturation_multiplier);// safety factor, 100 = no conservatism, 66 = 50% slower desaturation | |
163 | |
164 VAR_UCHAR (char_I_GF_High_percentage); // GF model high value | |
165 VAR_UCHAR (char_I_GF_Low_percentage); // GF model low value | |
166 | |
167 VAR_UCHAR (char_I_deco_distance); // assumed extra depth below required depth for CNS and gas volumes calculations | |
168 VAR_UCHAR (char_I_depth_last_deco); // depth of the last deco stop in meters | |
169 | |
170 VAR_UCHAR (char_I_deco_model); // deco model selection: 0 = ZH-L16, 1 = ZH-L16-GF (with gradient factors) | |
171 | |
172 VAR_UCHAR (char_I_bottom_depth); // bottom depth, used for gas volume calculations | |
173 VAR_UCHAR (char_I_bottom_time); // bottom time, used for gas volume calculations | |
174 | |
175 VAR_UCHAR (char_I_dive_interval); // duration of surface break before next dive in minutes, used in simulation | |
176 VAR_UCHAR (char_I_sim_advance_time); // 'fast forward' of dive time, used in simulation (+5 min function) | |
177 | |
178 VAR_UCHAR (char_I_const_ppO2); // ppO2 reported from sensors or by setpoint | |
179 | |
180 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // change depths of the OC gases | |
181 | |
182 TAB_UCHAR (char_I_setpoint_change,NUM_GAS); // change depth for the setpoints in meter | |
183 TAB_UCHAR (char_I_setpoint_cbar, NUM_GAS); // setpoints in cbar | |
184 | |
185 TAB_UCHAR (char_I_deco_O2_ratio, NUM_GAS); // oxygen ratios of the configured gases, used for deco calculations | |
186 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // helium ratios of the configured gases, used for deco calculations | |
0 | 187 |
560 | 188 TAB_UCHAR (char_I_tank_size, NUM_GAS); // tank sizes, used for pressure needs calculation |
189 TAB_UCHAR (char_I_tank_pres_fill, NUM_GAS); // tank fill pressures, used for generating warnings | |
190 | |
191 VAR_UCHAR (char_I_cc_max_frac_o2); // limiter for maximum O2% in loop | |
192 VAR_UCHAR (char_I_PSCR_drop); // pSCR parameter drop [%] | |
193 VAR_UCHAR (char_I_PSCR_lungratio); // pSCR parameter lung ratio [1/x] | |
194 | |
195 VAR_UCHAR (char_I_altitude_wait); // selector for altitude / no-fly waiting time calculation | |
196 | |
197 VAR_UCHAR (char_I_bottom_usage); // gas consumption during bottom part and initial ascent in liters/minute | |
198 VAR_UCHAR (char_I_deco_usage); // gas consumption during deco stops and following ascents in liters/minute | |
199 | |
200 VAR_UCHAR (char_I_extra_time); // extra bottom time for fTTs and delayed ascent calculation in minutes | |
0 | 201 |
560 | 202 VAR_UCHAR (char_I_ppO2_max); // warning threshold for maximum ppO2 during working phase of the dive |
203 VAR_UCHAR (char_I_ppO2_max_deco); // warning threshold for maximum ppO2 during deco phase of the dive | |
204 VAR_UCHAR (char_I_ppO2_min); // warning threshold for maximum ppO2 when breathing OC | |
205 VAR_UCHAR (char_I_ppO2_min_loop); // warning threshold for maximum ppO2 when breathing from CCR or pSCR | |
0 | 206 |
560 | 207 VAR_UCHAR (char_I_ascent_speed); // ascent speed in meters/minute |
208 VAR_UCHAR (char_I_gas_change_time); // extra time spent during a stop for doing a gas change, in minutes | |
209 | |
0 | 210 |
560 | 211 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
212 // VAR_UCHAR (char_I_step_is_1min); // Use 1min integration for tissue and CNS. DELETED ## V2.95 - made local to p2_deco.c | |
213 // VAR_UINT (int_I_temp); // new in v101 DELETED ## no fly | |
214 // VAR_UINT (int_I_divemins); // Dive time (minutes) DELETED ## V2.95 - not used by p2_deco.c | |
215 // VAR_UCHAR (char_I_temp); // new in v101 DELETED ## no fly | |
216 // VAR_UCHAR (char_I_actual_ppO2); // DELETED ## V2.94 | |
217 // VAR_UCHAR (char_I_first_gas); // Gas used at start of dive (bottom mix) DELETED ## V2.95 - made local to p2_deco.c | |
218 // VAR_UCHAR (char_I_N2_ratio); // N2 ratio of the currently breathed gas DELETED ## V2.95 - not read from ASM, but actually computed by p2_deco.c from H2 and O2 ratio | |
219 // VAR_UCHAR (char_O_deco_last_stop); // Depth reached during deco planning. DELETED ## V2.95 - not used in ASM | |
220 // VAR_UCHAR (temp_bankx400); // reserved space for temporary variables | |
221 #endif |