annotate src/shared_definitions.h @ 521:06e9370c6d75

CHANGE: Apply safety margin parameters to both models (GF and non-GF) Put B?hlmann constants in code for readability Fix unused gas warning (Do not warn)
author heinrichsweikamp
date Fri, 04 Aug 2017 16:01:28 +0200
parents f0828110d864
children b7eb98dbd800
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; shared_definitions.h
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Declare variables used both in C and ASM code
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; This program is free software: you can redistribute it and/or modify
heinrichsweikamp
parents:
diff changeset
8 ; it under the terms of the GNU General Public License as published by
heinrichsweikamp
parents:
diff changeset
9 ; the Free Software Foundation, either version 3 of the License, or
heinrichsweikamp
parents:
diff changeset
10 ; (at your option) any later version.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12 ; This program is distributed in the hope that it will be useful,
heinrichsweikamp
parents:
diff changeset
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
heinrichsweikamp
parents:
diff changeset
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
heinrichsweikamp
parents:
diff changeset
15 ; GNU General Public License for more details.
heinrichsweikamp
parents:
diff changeset
16 ;
heinrichsweikamp
parents:
diff changeset
17 ; You should have received a copy of the GNU General Public License
heinrichsweikamp
parents:
diff changeset
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
heinrichsweikamp
parents:
diff changeset
19 ;
heinrichsweikamp
parents:
diff changeset
20 ; Copyright (c) 2010, JD Gascuel.
heinrichsweikamp
parents:
diff changeset
21 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
22 ; RATIONAL
heinrichsweikamp
parents:
diff changeset
23 ;
heinrichsweikamp
parents:
diff changeset
24 ; We must enforce good data passing between the C and the ASM parts of code.
heinrichsweikamp
parents:
diff changeset
25 ; The previous design used two independant definitions of each variable,
heinrichsweikamp
parents:
diff changeset
26 ; one in C, one in ASM. If they did not match, no error was generated, and
heinrichsweikamp
parents:
diff changeset
27 ; anything can happend at runtime...
heinrichsweikamp
parents:
diff changeset
28 ;
heinrichsweikamp
parents:
diff changeset
29 ; The new design use LINKING to ensure the variables defined in C are at the
heinrichsweikamp
parents:
diff changeset
30 ; same address when used in ASM code. And it uses a unique declaration file
heinrichsweikamp
parents:
diff changeset
31 ; (with suitable macros) to make sure they have the same size in both language.
heinrichsweikamp
parents:
diff changeset
32 ;
heinrichsweikamp
parents:
diff changeset
33 ; HISTORY
heinrichsweikamp
parents:
diff changeset
34 ; 2011-01-20: [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
35 ;
heinrichsweikamp
parents:
diff changeset
36 ; NOTE
heinrichsweikamp
parents:
diff changeset
37 ;
heinrichsweikamp
parents:
diff changeset
38 ; This file have to obey both ASM and C syntax. The only common directives
heinrichsweikamp
parents:
diff changeset
39 ; are #if/#ifdef/#endif and the #define, so they are eavily used to do the
heinrichsweikamp
parents:
diff changeset
40 ; trick.
heinrichsweikamp
parents:
diff changeset
41 ;
heinrichsweikamp
parents:
diff changeset
42 ; BUGS
heinrichsweikamp
parents:
diff changeset
43 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
44 ; HISTORY
heinrichsweikamp
parents:
diff changeset
45 #endif
heinrichsweikamp
parents:
diff changeset
46
heinrichsweikamp
parents:
diff changeset
47 #ifdef __18CXX
heinrichsweikamp
parents:
diff changeset
48 //------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
49 // C-style declarations:
heinrichsweikamp
parents:
diff changeset
50 # ifndef TEST_MAIN
heinrichsweikamp
parents:
diff changeset
51 # define VAR_UCHAR(n) extern unsigned char n
heinrichsweikamp
parents:
diff changeset
52 # define TAB_UCHAR(n,size) extern unsigned char n[size]
heinrichsweikamp
parents:
diff changeset
53 # define VAR_UINT(n) extern unsigned short n
heinrichsweikamp
parents:
diff changeset
54 # define TAB_UINT(n,size) extern unsigned short n[size]
heinrichsweikamp
parents:
diff changeset
55 # else
heinrichsweikamp
parents:
diff changeset
56 # define VAR_UCHAR(n) unsigned char n
heinrichsweikamp
parents:
diff changeset
57 # define TAB_UCHAR(n,size) unsigned char n[size]
heinrichsweikamp
parents:
diff changeset
58 # define VAR_UINT(n) unsigned short n
heinrichsweikamp
parents:
diff changeset
59 # define TAB_UINT(n,size) unsigned short n[size]
heinrichsweikamp
parents:
diff changeset
60 # endif
heinrichsweikamp
parents:
diff changeset
61 #else
heinrichsweikamp
parents:
diff changeset
62 ;-------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
63 ; ASM-style declarations:
heinrichsweikamp
parents:
diff changeset
64 #define VAR_UCHAR(n) n res 1
heinrichsweikamp
parents:
diff changeset
65 #define TAB_UCHAR(n,size) n res size
heinrichsweikamp
parents:
diff changeset
66 #define VAR_UINT(n) n res 2
heinrichsweikamp
parents:
diff changeset
67 #define TAB_UINT(n,size) n res 2*size
heinrichsweikamp
parents:
diff changeset
68 #endif
heinrichsweikamp
parents:
diff changeset
69
heinrichsweikamp
parents:
diff changeset
70 #ifdef __18CXX
heinrichsweikamp
parents:
diff changeset
71 //---- BANK 3 DATA -------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
72 // Gather all data C-code --> ASM-code
heinrichsweikamp
parents:
diff changeset
73 # pragma udata overlay bank3=0x300
heinrichsweikamp
parents:
diff changeset
74 #else
heinrichsweikamp
parents:
diff changeset
75 bank3 udata_ovr 0x300
heinrichsweikamp
parents:
diff changeset
76 #endif
heinrichsweikamp
parents:
diff changeset
77
210
7dbc1d780ca5 do not clear char_O_deco_gas in copy_deco_table
heinrichsweikamp
parents: 126
diff changeset
78
0
heinrichsweikamp
parents:
diff changeset
79 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
heinrichsweikamp
parents:
diff changeset
80 Define model dimensions.
heinrichsweikamp
parents:
diff changeset
81 NUM_COMP is the number of compartiments in the Bühlmann ZH-L16 model, ie 16.
heinrichsweikamp
parents:
diff changeset
82 NUM_STOPS is the maximum number of stops computed by decoplanning.
heinrichsweikamp
parents:
diff changeset
83 Note that the deapest stop is roughly limited to 3m * NUM_STOPS
heinrichsweikamp
parents:
diff changeset
84 (this is assuming all stops up to the surface are used).
heinrichsweikamp
parents:
diff changeset
85 Note also that if the table overflow, extra stops are ignored,
heinrichsweikamp
parents:
diff changeset
86 and not reported in TTS summing.
heinrichsweikamp
parents:
diff changeset
87 NUM_GAS is the number of (potentially) active gas considered during
heinrichsweikamp
parents:
diff changeset
88 ascent simulation.
heinrichsweikamp
parents:
diff changeset
89 #endif
heinrichsweikamp
parents:
diff changeset
90 #define NUM_COMP 0x10
heinrichsweikamp
parents:
diff changeset
91 #define NUM_STOPS 0x20
heinrichsweikamp
parents:
diff changeset
92 #define NUM_GAS 5
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 VAR_UINT (int_O_gtissue_press);
heinrichsweikamp
parents:
diff changeset
95 VAR_UINT (int_O_desaturation_time); //
heinrichsweikamp
parents:
diff changeset
96 VAR_UINT (int_O_ascenttime); // TTS (in minutes)
heinrichsweikamp
parents:
diff changeset
97 VAR_UINT (int_O_extra_ascenttime); // TTS for @+5min variant (in minutes)
heinrichsweikamp
parents:
diff changeset
98 VAR_UINT (int_O_CNS_fraction); // new in v.101
heinrichsweikamp
parents:
diff changeset
99
heinrichsweikamp
parents:
diff changeset
100 VAR_UCHAR (char_O_nullzeit); //
heinrichsweikamp
parents:
diff changeset
101 VAR_UCHAR (char_O_deco_status); // Deko state-machine state.
heinrichsweikamp
parents:
diff changeset
102 VAR_UCHAR (char_O_deco_last_stop); // Depth reached during deko planning.
heinrichsweikamp
parents:
diff changeset
103 VAR_UCHAR (char_O_gradient_factor); //
heinrichsweikamp
parents:
diff changeset
104 VAR_UCHAR (char_O_gtissue_no); //
heinrichsweikamp
parents:
diff changeset
105 VAR_UCHAR (char_O_diluent); // new in v.101
heinrichsweikamp
parents:
diff changeset
106 VAR_UCHAR (char_O_flush_ppO2); // 2011-05-01: ppO2 from diluant (CCR mode).
heinrichsweikamp
parents:
diff changeset
107 VAR_UCHAR (char_O_EAD); // 2011-05-01: Added EAD/END in deco model.
heinrichsweikamp
parents:
diff changeset
108 VAR_UCHAR (char_O_END); // 2011-05-01: Added EAD/END in deco model.
heinrichsweikamp
parents:
diff changeset
109
heinrichsweikamp
parents:
diff changeset
110 VAR_UCHAR (char_O_first_deco_depth); // Depth of first stop.
heinrichsweikamp
parents:
diff changeset
111 VAR_UCHAR (char_O_first_deco_time) ; // Duration of first stop.
heinrichsweikamp
parents:
diff changeset
112 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // Fusionned decompression table:
heinrichsweikamp
parents:
diff changeset
113 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // Both ZH-L16 and L16-GF models.
111
c61b7a4e317c Bugfix: CNS in planner
heinrichsweikamp
parents: 105
diff changeset
114 TAB_UCHAR (char_O_deco_gas, NUM_STOPS); // Both ZH-L16 and L16-GF models.
0
heinrichsweikamp
parents:
diff changeset
115 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS); // For logging the full decoplan
heinrichsweikamp
parents:
diff changeset
116
heinrichsweikamp
parents:
diff changeset
117 TAB_UCHAR (char_O_tissue_N2_saturation, NUM_COMP); // Nitrogen compartiment desaturation time, in min.
heinrichsweikamp
parents:
diff changeset
118 TAB_UCHAR (char_O_tissue_He_saturation, NUM_COMP); // Helium compartiment desaturation time, in min.
heinrichsweikamp
parents:
diff changeset
119
heinrichsweikamp
parents:
diff changeset
120 TAB_UINT (int_O_gas_volumes, 5); // Volumes evaluation for each gas tank, in 0.1 liters.
123
d076e9c02438 add ceiling display
heinrichsweikamp
parents: 111
diff changeset
121 VAR_UINT (int_O_ceiling); // in mbar
0
heinrichsweikamp
parents:
diff changeset
122
heinrichsweikamp
parents:
diff changeset
123 #ifdef __18CXX
heinrichsweikamp
parents:
diff changeset
124 //---- BANK 4 DATA -------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
125 // Gather all data ASM-code --> C-code
heinrichsweikamp
parents:
diff changeset
126 # pragma udata overlay bank4=0x400
heinrichsweikamp
parents:
diff changeset
127 #else
heinrichsweikamp
parents:
diff changeset
128 ; In ASM, put the same bank, in overlay mode, at the same address
heinrichsweikamp
parents:
diff changeset
129 bank4 udata_ovr 0x400
heinrichsweikamp
parents:
diff changeset
130 #endif
heinrichsweikamp
parents:
diff changeset
131
heinrichsweikamp
parents:
diff changeset
132 VAR_UCHAR (char_I_step_is_1min); // Use 1min integration for tissue and CNS.
heinrichsweikamp
parents:
diff changeset
133
heinrichsweikamp
parents:
diff changeset
134 VAR_UINT (int_I_pres_respiration); //
heinrichsweikamp
parents:
diff changeset
135 VAR_UINT (int_I_pres_surface); //
heinrichsweikamp
parents:
diff changeset
136 VAR_UINT (int_I_temp); // new in v101
heinrichsweikamp
parents:
diff changeset
137 VAR_UINT (int_I_divemins); // Dive time (minutes)
heinrichsweikamp
parents:
diff changeset
138 VAR_UCHAR (char_I_temp); // new in v101
heinrichsweikamp
parents:
diff changeset
139 VAR_UCHAR (char_I_actual_ppO2); //
heinrichsweikamp
parents:
diff changeset
140 VAR_UCHAR (char_I_first_gas); // Gas used at start of dive (bottom mix)
377
f0828110d864 set char_I_current_gas for gas6 use
heinrichsweikamp
parents: 210
diff changeset
141 VAR_UCHAR (char_I_current_gas); // Current gas breathed (1..6).
0
heinrichsweikamp
parents:
diff changeset
142 VAR_UCHAR (char_I_N2_ratio); //
heinrichsweikamp
parents:
diff changeset
143 VAR_UCHAR (char_I_He_ratio); //
heinrichsweikamp
parents:
diff changeset
144 VAR_UCHAR (char_I_O2_ratio); //
heinrichsweikamp
parents:
diff changeset
145 VAR_UCHAR (char_I_saturation_multiplier); // for conservatism/safety values 1.0 no conservatism to 1.5 50% faster saturation
heinrichsweikamp
parents:
diff changeset
146 VAR_UCHAR (char_I_desaturation_multiplier);// for conservatism/safety values 0.66 50% slower desaturation to 1.0 no conservatism// consveratism used in calc_tissue , calc_tissue_step_1_min and sim_tissue_1min
heinrichsweikamp
parents:
diff changeset
147 VAR_UCHAR (char_I_GF_High_percentage); // new in v.102
heinrichsweikamp
parents:
diff changeset
148 VAR_UCHAR (char_I_GF_Low_percentage); // new in v.102
heinrichsweikamp
parents:
diff changeset
149 VAR_UCHAR (char_I_deco_distance); //
heinrichsweikamp
parents:
diff changeset
150 VAR_UCHAR (char_I_depth_last_deco); // new in v.101 unit: [m]
heinrichsweikamp
parents:
diff changeset
151 VAR_UCHAR (char_I_deco_model); // new in v.102. 0 == ZH-L16, 1 = ZH-L16-GF (Gradiant factor)
heinrichsweikamp
parents:
diff changeset
152 VAR_UCHAR (char_I_bottom_depth); // Bottom depth for planning (used in gas volume evaluation).
heinrichsweikamp
parents:
diff changeset
153 VAR_UCHAR (char_I_bottom_time); // Bottom time for planning (used in gas volume evaluation).
heinrichsweikamp
parents:
diff changeset
154 VAR_UCHAR (char_I_dive_interval); // Delay before next dive simulation.
heinrichsweikamp
parents:
diff changeset
155 VAR_UCHAR (char_I_const_ppO2); // new in v.101
heinrichsweikamp
parents:
diff changeset
156
heinrichsweikamp
parents:
diff changeset
157 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // new in v.101
heinrichsweikamp
parents:
diff changeset
158 TAB_UCHAR (char_I_dil_change,NUM_GAS); // Must be placed after char_I_deco_gas_change!
heinrichsweikamp
parents:
diff changeset
159
heinrichsweikamp
parents:
diff changeset
160 TAB_UCHAR (char_I_setpoint_change,NUM_GAS); // Change depths in m
heinrichsweikamp
parents:
diff changeset
161 TAB_UCHAR (char_I_deco_N2_ratio, NUM_GAS); // new in v.101
heinrichsweikamp
parents:
diff changeset
162 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // new in v.101
heinrichsweikamp
parents:
diff changeset
163
heinrichsweikamp
parents:
diff changeset
164 TAB_UCHAR (char_I_setpoint_cbar,NUM_GAS); // Setpoints in cbar
heinrichsweikamp
parents:
diff changeset
165
heinrichsweikamp
parents:
diff changeset
166 VAR_UCHAR (char_I_bottom_usage); // [l/min]
heinrichsweikamp
parents:
diff changeset
167 VAR_UCHAR (char_I_deco_usage); // [l/min]
heinrichsweikamp
parents:
diff changeset
168
heinrichsweikamp
parents:
diff changeset
169 VAR_UCHAR (char_I_extra_time); // [min]
heinrichsweikamp
parents:
diff changeset
170 VAR_UCHAR (temp_bankx400); // temp