comparison src/shared_definitions.h @ 604:ca4556fb60b9

bump to 2.99beta, work on 3.00 stable
author heinrichsweikamp
date Thu, 22 Nov 2018 19:47:26 +0100
parents b455b31ce022
children c40025d8e750
comparison
equal deleted inserted replaced
603:00b24fb4324d 604:ca4556fb60b9
1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 ; 2 ;
3 ; shared_definitions.h REFACTORED VERSION V2.97 3 ; shared_definitions.h REFACTORED VERSION V2.99e
4 ; 4 ;
5 ; Declare variables used both in C and ASM code 5 ; Declare variables used both in C and ASM code
6 ; 6 ;
7 ; This program is free software: you can redistribute it and/or modify 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 8 ; it under the terms of the GNU General Public License as published by
15 ; GNU General Public License for more details. 15 ; GNU General Public License for more details.
16 ; 16 ;
17 ; You should have received a copy of the GNU General Public License 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/>. 18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ; 19 ;
20 ; Copyright (c) 2010, JD Gascuel. 20 ; Copyright (c) 2010, JD Gascuel
21 ;============================================================================= 21 ;=============================================================================
22 ; RATIONAL 22 ; RATIONAL
23 ; 23 ;
24 ; We must enforce good data passing between the C and the ASM parts of code. 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, 25 ; The previous design used two independant definitions of each variable,
29 ; The new design use LINKING to ensure the variables defined in C are at the 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 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. 31 ; (with suitable macros) to make sure they have the same size in both language.
32 ; 32 ;
33 ; HISTORY 33 ; HISTORY
34 ; 2011-01-20: [jDG] Creation. 34 ; 2011-01-20: [jDG] Creation
35 ; 35 ;
36 ; NOTE 36 ; NOTE
37 ; 37 ;
38 ; This file have to obey both ASM and C syntax. The only common directives 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 39 ; are #if/#ifdef/#endif and the #define, so they are eavily used to do the
44 ; HISTORY 44 ; HISTORY
45 #endif 45 #endif
46 46
47 #ifdef __18CXX 47 #ifdef __18CXX
48 //------------------------------------------------------------------------ 48 //------------------------------------------------------------------------
49 // C-style declarations: 49 // C-Style Declarations:
50 # ifndef TEST_MAIN 50 # ifndef TEST_MAIN
51 # define VAR_UCHAR(n) extern unsigned char n 51 # define VAR_UCHAR(n) extern unsigned char n
52 # define TAB_UCHAR(n,size) extern unsigned char n[size] 52 # define TAB_UCHAR(n,size) extern unsigned char n[size]
53 # define VAR_UINT(n) extern unsigned short n 53 # define VAR_UINT(n) extern unsigned short n
54 # define TAB_UINT(n,size) extern unsigned short n[size] 54 # define TAB_UINT(n,size) extern unsigned short n[size]
55 # else 55 # else
56 # define VAR_UCHAR(n) unsigned char n 56 # define VAR_UCHAR(n) unsigned char n
57 # define TAB_UCHAR(n,size) unsigned char n[size] 57 # define TAB_UCHAR(n,size) unsigned char n[size]
58 # define VAR_UINT(n) unsigned short n 58 # define VAR_UINT(n) unsigned short n
59 # define TAB_UINT(n,size) unsigned short n[size] 59 # define TAB_UINT(n,size) unsigned short n[size]
60 # endif 60 # endif
61 #else 61 #else
62 ;------------------------------------------------------------------------- 62 ;-------------------------------------------------------------------------
63 ; ASM-style declarations: 63 ; ASM-Style Declarations:
64 #define VAR_UCHAR(n) n res 1 64 #define VAR_UCHAR(n) n res 1
65 #define TAB_UCHAR(n,size) n res size 65 #define TAB_UCHAR(n,size) n res size
66 #define VAR_UINT(n) n res 2 66 #define VAR_UINT(n) n res 2
67 #define TAB_UINT(n,size) n res 2*size 67 #define TAB_UINT(n,size) n res 2*size
68 #endif 68 #endif
69 69
70 70
71 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 71 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
72 Define model dimensions. 72 Define Model Dimensions
73 NUM_COMP is the number of compartiments in the Bühlmann ZH-L16 model, ie 16. 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. 74 NUM_STOPS is the maximum number of stops computed by decoplanning.
75 Note that the deepest stop is roughly limited to 3m * NUM_STOPS 75 Note that the deepest stop is roughly limited to 3m * NUM_STOPS
76 (this is assuming all stops up to the surface are used). 76 (this is assuming all stops up to the surface are used).
77 Note also that if the table overflow, extra stops are ignored, 77 Note also that if the table overflow, extra stops are ignored,
78 and not reported in TTS summing. 78 and not reported in TTS summing.
79 NUM_GAS is the number of (potentially) active gas considered during 79 NUM_GAS is the number of (potentially) active gas considered during
80 ascent simulation. 80 ascent simulation.
81 #endif 81 NUM_SP is the number of setpoints
82 #define NUM_COMP 0x10 82 #endif
83 #define NUM_STOPS 0x20 83 #define NUM_COMP 0x10
84 #define NUM_GAS 5 84 #define NUM_STOPS 0x20
85 #define NUM_GAS 5
86 #define NUM_SP 5
85 87
86 88
87 #ifdef __18CXX 89 #ifdef __18CXX
88 //---- BANK 3 DATA ------------------------------------------------------- 90 //---- BANK 3 DATA -------------------------------------------------------
89 // Gather all data C-code --> ASM-code 91 // Gather all Data C-Code --> ASM-Code
90 // Memory usage: 41 Bytes left 92 // Memory usage: 202 Byte used, 54 Byte free
91 # pragma udata overlay bank3=0x300 93 # pragma udata overlay bank3=0x300
92 #else 94 #else
93 ; In ASM, put the same bank, in overlay mode, at the same address 95 ; in ASM, put the same bank, in overlay mode, at the same address
94 bank3 udata_ovr 0x300 96 bank3 udata_ovr 0x300
95 #endif 97 #endif
96 98
97 VAR_UINT (int_O_desaturation_time); // time until tissues desaturated to 5% remains, in minutes 99 VAR_UINT (int_O_desaturation_time); // time until tissues desaturated to 5% remains, in minutes
98 VAR_UINT (int_O_nofly_time); // altitude / no-fly waiting time time in minutes 100 VAR_UINT (int_O_nofly_time); // altitude / no-fly waiting time time in minutes
99 101
102 104
103 VAR_UINT (int_O_CNS_fraction); // current CNS% 105 VAR_UINT (int_O_CNS_fraction); // current CNS%
104 VAR_UINT (int_O_normal_CNS_fraction); // CNS% at end of dive in normal dive plan 106 VAR_UINT (int_O_normal_CNS_fraction); // CNS% at end of dive in normal dive plan
105 VAR_UINT (int_O_alternate_CNS_fraction); // CNS% at end of dive in alternative plan 107 VAR_UINT (int_O_alternate_CNS_fraction); // CNS% at end of dive in alternative plan
106 108
107 VAR_UINT (int_O_gradient_factor); // current gradient factor in % 109 VAR_UINT (int_O_gradient_factor); // current gradient factor in %, 100% = on M-line of straight Buhlmann
110
111 VAR_UCHAR (char_O_lead_number); // number of the leading tissue
108 112
109 VAR_UCHAR (char_O_nullzeit); // remaining NDL time in minutes 113 VAR_UCHAR (char_O_nullzeit); // remaining NDL time in minutes
110 VAR_UCHAR (char_O_alternate_nullzeit); // remaining NDL time for the alternative dive plan 114 VAR_UCHAR (char_O_alternate_nullzeit); // remaining NDL time for the alternative dive plan
111 115
112 VAR_UCHAR (char_O_main_status); // setup of the deco engine regarding the real tissue computations 116 VAR_UCHAR (char_O_main_status); // setup of the deco engine regarding the real tissue computations
113 VAR_UCHAR (char_O_deco_status); // setup of the deco engine regarding the decompression computations 117 VAR_UCHAR (char_O_deco_status); // setup of the deco engine regarding the decompression computations
118 VAR_UCHAR (char_O_deco_warnings); // vector of warnings generated by the deco engine
119 VAR_UCHAR (char_O_deco_info); // vector of infos generated by the deco engine
114 120
115 VAR_UCHAR (char_O_EAD); // equivalent air depth (EAD) of breathed gas 121 VAR_UCHAR (char_O_EAD); // equivalent air depth (EAD) of breathed gas
116 VAR_UCHAR (char_O_END); // equivalent narcosis depth (END) of breathed gas 122 VAR_UCHAR (char_O_END); // equivalent narcosis depth (END) of breathed gas
117 123
118 VAR_UCHAR (char_O_first_deco_depth); // depth of first stop (deco or gas change) 124 VAR_UCHAR (char_O_first_deco_depth); // depth of first stop (deco or gas change)
119 VAR_UCHAR (char_O_first_deco_time) ; // duration of first stop 125 VAR_UCHAR (char_O_first_deco_time) ; // duration of first stop
120 126
121 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // stops table: depth, ... 127 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // stops table: depth, ... | ATTENTION: do not re-arrange these
122 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // ... duration, and 128 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // ... duration, and | three arrays relative
123 TAB_UCHAR (char_O_deco_gas, NUM_STOPS); // ... gas breathed 129 TAB_UCHAR (char_O_deco_gas, NUM_STOPS); // ... gas breathed | to each other!
124 130
125 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS); // variant of the stops table for logging purpose 131 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS); // variant of the stops table for logging purpose
126 132
127 TAB_UCHAR (char_O_tissue_N2_saturation, NUM_COMP); // nitrogen tissue pressures for display purpose 133 TAB_UCHAR (char_O_tissue_N2_saturation, NUM_COMP); // nitrogen tissue pressures for display purpose
128 TAB_UCHAR (char_O_tissue_He_saturation, NUM_COMP); // helium tissue pressures for display purpose 134 TAB_UCHAR (char_O_tissue_He_saturation, NUM_COMP); // helium tissue pressures for display purpose
129 135
130 VAR_UCHAR (char_O_deco_warnings); // vector of warnings generated by the deco engine 136 TAB_UINT (int_O_ascent_volumes, NUM_GAS); // gas volumes needed for ascent in liters
131 137 TAB_UINT (int_O_ascent_pres_need, NUM_GAS); // tank pressures needed for ascent in bar
132 TAB_UINT (int_O_gas_volumes, NUM_GAS); // gas volumes needed in liters 138
133 TAB_UINT (int_O_tank_pres_need, NUM_GAS); // tank pressures needed in bar 139 VAR_UINT (int_O_ceiling); // ascent boundary in mbar relative pressure, calculated at GF-high
134 VAR_UINT (int_O_ceiling); // ultimate ascent bound in mbar relative pressure
135 140
136 VAR_UINT (int_O_O2_ppO2); // ppO2 of pure O2 at current depth 141 VAR_UINT (int_O_O2_ppO2); // ppO2 of pure O2 at current depth
137 VAR_UINT (int_O_pure_ppO2); // ppO2 of the current gas or dil if breathed pure 142 VAR_UINT (int_O_pure_ppO2); // ppO2 of the current gas or dil if breathed pure
138 VAR_UINT (int_O_pSCR_ppO2); // ppO2 calculated in pSCR loop 143 VAR_UINT (int_O_pSCR_ppO2); // ppO2 calculated in pSCR loop
139 VAR_UINT (int_O_breathed_ppO2); // ppO2 actually breathed (= char_O_pure_ppO2 if in OC) 144 VAR_UINT (int_O_breathed_ppO2); // ppO2 actually breathed (= char_O_pure_ppO2 if in OC)
140 145
146 TAB_UINT (int_O_pressure_need, 2); // pressure reading, need by deco calculations, in 0.1 bar
147 VAR_UINT (int_O_sac_rate); // SAC rate in 0.1 liter/minute
148
141 149
142 #ifdef __18CXX 150 #ifdef __18CXX
143 //---- BANK 4 DATA ------------------------------------------------------- 151 //---- BANK 4 DATA -------------------------------------------------------
144 // Gather all data ASM-code --> C-code 152 // Gather all Data ASM-Code --> C-Code
145 // Memory usage: 183 bytes left 153 // Memory usage: 86 Byte used, 170 byte free
146 # pragma udata overlay bank4=0x400 154 # pragma udata overlay bank4=0x400
147 #else 155 #else
148 ; In ASM, put the same bank, in overlay mode, at the same address 156 ; in ASM, put the same bank, in overlay mode, at the same address
149 bank4 udata_ovr 0x400 157 bank4 udata_ovr 0x400
150 #endif 158 #endif
151 159
152 VAR_UINT (int_I_pres_respiration); // absolute pressure breathed 160 VAR_UINT (int_I_pres_respiration); // absolute pressure breathed
153 VAR_UINT (int_I_pres_surface); // absolute pressure at surface 161 VAR_UINT (int_I_pres_surface); // absolute pressure at surface
154 162
155 VAR_UCHAR (char_I_current_gas); // number of gas currently breathed (1..5 for configured gases, 6 for the manual gas) 163 VAR_UCHAR (char_I_current_gas); // number of gas currently breathed (1..5 for configured gases, 6 for the manual gas)
156 VAR_UCHAR (char_I_He_ratio); // helium ratio of the currently breathed gas 164 VAR_UCHAR (char_I_current_gas_type); // type of current gas: (0=Disabled), 1=First, 2=Travel/Normal, 3=Deco/-
157 VAR_UCHAR (char_I_O2_ratio); // oxygen ratio of the currently breathed gas 165 VAR_UCHAR (char_I_He_ratio); // helium ratio of the currently breathed gas
166 VAR_UCHAR (char_I_O2_ratio); // oxygen ratio of the currently breathed gas
158 167
159 VAR_UCHAR (char_I_saturation_multiplier); // safety factor, 100 = no conservatism, 150 = 50% faster saturation 168 VAR_UCHAR (char_I_saturation_multiplier); // safety factor, 100 = no conservatism, 150 = 50% faster saturation
160 VAR_UCHAR (char_I_desaturation_multiplier); // safety factor, 100 = no conservatism, 66 = 50% slower desaturation 169 VAR_UCHAR (char_I_desaturation_multiplier); // safety factor, 100 = no conservatism, 66 = 50% slower desaturation
161 170
162 VAR_UCHAR (char_I_GF_High_percentage); // GF model high value 171 VAR_UCHAR (char_I_GF_High_percentage); // GF model high value
170 VAR_UCHAR (char_I_bottom_depth); // bottom depth, used for gas volume calculations 179 VAR_UCHAR (char_I_bottom_depth); // bottom depth, used for gas volume calculations
171 VAR_UCHAR (char_I_bottom_time); // bottom time, used for gas volume calculations 180 VAR_UCHAR (char_I_bottom_time); // bottom time, used for gas volume calculations
172 181
173 VAR_UCHAR (char_I_dive_interval); // duration of surface break before next dive in minutes, used in simulation 182 VAR_UCHAR (char_I_dive_interval); // duration of surface break before next dive in minutes, used in simulation
174 VAR_UCHAR (char_I_sim_advance_time); // 'fast forward' of dive time, used in simulation (+5 min function) 183 VAR_UCHAR (char_I_sim_advance_time); // 'fast forward' of dive time, used in simulation (+5 min function)
184 VAR_UCHAR (char_I_extra_time); // extra bottom time for fTTs and delayed ascent calculation in minutes
175 185
176 VAR_UCHAR (char_I_const_ppO2); // ppO2 reported from sensors or by setpoint 186 VAR_UCHAR (char_I_const_ppO2); // ppO2 reported from sensors or by setpoint
177 187
178 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // change depths of the OC gases 188 TAB_UCHAR (char_I_setpoint_cbar, NUM_SP); // setpoints in cbar | ATTENTION: do not change the position of these
179 TAB_UCHAR (char_I_dil_change, NUM_GAS); // change depths of the diluent gases. Attention: must be placed after char_I_deco_gas_change! Remark: not used by C code, only by ASM code 189 TAB_UCHAR (char_I_setpoint_change,NUM_SP); // change depth for the setpoints in meter | two arrays relative to each other!
180 190
181 TAB_UCHAR (char_I_setpoint_change,NUM_GAS); // change depth for the setpoints in meter 191 TAB_UCHAR (char_I_deco_O2_ratio, NUM_GAS); // oxygen ratios of the configured gases, used for deco calc. | ATTENTION: do not change the
182 TAB_UCHAR (char_I_setpoint_cbar, NUM_GAS); // setpoints in cbar 192 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // helium ratios of the configured gases, used for deco calc. | position of these
183 193 TAB_UCHAR (char_I_deco_gas_type, NUM_GAS); // type of the configured gases, used for deco calc. | arrays relative to
184 TAB_UCHAR (char_I_deco_O2_ratio, NUM_GAS); // oxygen ratios of the configured gases, used for deco calculations 194 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // change depths of the configured gases, used for deco calc. | each other!
185 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // helium ratios of the configured gases, used for deco calculations 195
186 196 TAB_UCHAR (char_I_tank_size, NUM_GAS * 2); // tank sizes, used for pressure needs and SAC calculations
187 TAB_UCHAR (char_I_tank_size, NUM_GAS); // tank sizes, used for pressure needs calculation 197 TAB_UCHAR (char_I_tank_pres_fill, NUM_GAS * 2); // tank fill pressures (in multiples of 10 bar), used to generate warnings
188 TAB_UCHAR (char_I_tank_pres_fill, NUM_GAS); // tank fill pressures, used for generating warnings
189 198
190 VAR_UCHAR (char_I_cc_max_frac_o2); // limiter for maximum O2% in loop 199 VAR_UCHAR (char_I_cc_max_frac_o2); // limiter for maximum O2% in loop
191 VAR_UCHAR (char_I_PSCR_drop); // pSCR parameter drop [%] 200 VAR_UCHAR (char_I_PSCR_drop); // pSCR parameter drop [%]
192 VAR_UCHAR (char_I_PSCR_lungratio); // pSCR parameter lung ratio [1/x] 201 VAR_UCHAR (char_I_PSCR_lungratio); // pSCR parameter lung ratio [1/x]
193 202
194 VAR_UCHAR (char_I_altitude_wait); // selector for altitude / no-fly waiting time calculation 203 VAR_UCHAR (char_I_altitude_wait); // selector for altitude / no-fly waiting time calculation
195 204
196 VAR_UCHAR (char_I_bottom_usage); // gas consumption during bottom part and initial ascent in liters/minute 205 VAR_UCHAR (char_I_bottom_usage); // gas consumption during bottom part and initial ascent in liters/minute
197 VAR_UCHAR (char_I_deco_usage); // gas consumption during deco stops and following ascents in liters/minute 206 VAR_UCHAR (char_I_deco_usage); // gas consumption during deco stops and following ascents in liters/minute
198 207
199 VAR_UCHAR (char_I_extra_time); // extra bottom time for fTTs and delayed ascent calculation in minutes 208 VAR_UCHAR (char_I_gas6_depth); // change depth (MOD) of the manually configured gas in meters
200 209
201 VAR_UCHAR (char_I_ppO2_max); // warning threshold for maximum ppO2 during working phase of the dive 210 VAR_UCHAR (char_I_ppO2_max); // warning threshold for maximum ppO2 during working phase of the dive
202 VAR_UCHAR (char_I_ppO2_max_deco); // warning threshold for maximum ppO2 during deco phase of the dive 211 VAR_UCHAR (char_I_ppO2_max_deco); // warning threshold for maximum ppO2 during deco phase of the dive
203 VAR_UCHAR (char_I_ppO2_min); // warning threshold for maximum ppO2 when breathing OC 212 VAR_UCHAR (char_I_ppO2_min); // warning threshold for maximum ppO2 when breathing OC
204 VAR_UCHAR (char_I_ppO2_min_loop); // warning threshold for maximum ppO2 when breathing from CCR or pSCR 213 VAR_UCHAR (char_I_ppO2_min_loop); // warning threshold for maximum ppO2 when breathing from CCR or pSCR
205 214
206 VAR_UCHAR (char_I_ascent_speed); // ascent speed in meters/minute 215 VAR_UCHAR (char_I_ascent_speed); // ascent speed in meters/minute
207 VAR_UCHAR (char_I_gas_change_time); // extra time spent during a stop for doing a gas change, in minutes 216 VAR_UCHAR (char_I_gas_change_time); // extra time spent during a stop for doing a gas change, in minutes
217
218 VAR_UCHAR (char_I_SAC_mode); // SAC calculation mode
219 VAR_UCHAR (char_I_max_pres_diff); // maximum pressure difference for independent double mode
220
221 TAB_UINT (int_IO_pressure_value,2); // pressure reading, measured pressure, in 0.1 bar | ATTENTION: do not change the position
222 TAB_UINT (int_I_pressure_drop, 2); // pressure reading, average pressure drop, in 1/160 bar/sec | of these arrays relative to each other!
223
224 TAB_UCHAR (char_I_pressure_gas, 2); // pressure reading, associated gas (1-5) / diluent (6-10), 0 if off
225 TAB_UCHAR (char_I_pressure_age, 2); // pressure reading, age of data
226 TAB_UCHAR (char_I_pressure_stat,2); // pressure reading, transmitter status data
227
228 VAR_UCHAR (char_I_backtrack_time); // index (in minutes) of backtrack entries in char_I_backtrack_depth
229
230
231 #ifdef __18CXX
232 //---- BANK 11 DATA -------------------------------------------------------
233 // Backtracking Data ASM-Code --> C-Code
234 // Memory usage: 256 Byte used, 0 byte free
235 # pragma udata overlay bank11=0xB00
236 #else
237 ; in ASM, put the same bank, in overlay mode, at the same address
238 bank11 udata_ovr 0xB00
239 #endif
240
241 TAB_UCHAR (char_I_backtrack_depth, 0x100); // recorded depths for backtracking in cave mode