comparison src/shared_definitions.h @ 0:11d4fc797f74

init
author heinrichsweikamp
date Wed, 24 Apr 2013 19:22:45 +0200
parents
children 0aaa4877ba25
comparison
equal deleted inserted replaced
-1:000000000000 0:11d4fc797f74
1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 ;
3 ; shared_definitions.h
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
70 #ifdef __18CXX
71 //---- BANK 3 DATA -------------------------------------------------------
72 // Gather all data C-code --> ASM-code
73 # pragma udata overlay bank3=0x300
74 #else
75 bank3 udata_ovr 0x300
76 #endif
77
78 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
79 Define model dimensions.
80 NUM_COMP is the number of compartiments in the Bühlmann ZH-L16 model, ie 16.
81 NUM_STOPS is the maximum number of stops computed by decoplanning.
82 Note that the deapest stop is roughly limited to 3m * NUM_STOPS
83 (this is assuming all stops up to the surface are used).
84 Note also that if the table overflow, extra stops are ignored,
85 and not reported in TTS summing.
86 NUM_GAS is the number of (potentially) active gas considered during
87 ascent simulation.
88 #endif
89 #define NUM_COMP 0x10
90 #define NUM_STOPS 0x20
91 #define NUM_GAS 5
92
93 VAR_UINT (int_O_gtissue_limit);
94 VAR_UINT (int_O_gtissue_press);
95 VAR_UINT (int_O_desaturation_time); //
96 VAR_UINT (int_O_ascenttime); // TTS (in minutes)
97 VAR_UINT (int_O_extra_ascenttime); // TTS for @+5min variant (in minutes)
98 VAR_UINT (int_O_CNS_fraction); // new in v.101
99
100 VAR_UCHAR (char_O_nullzeit); //
101 VAR_UCHAR (char_O_deco_status); // Deko state-machine state.
102 VAR_UCHAR (char_O_deco_last_stop); // Depth reached during deko planning.
103 VAR_UCHAR (char_O_gradient_factor); //
104 VAR_UCHAR (char_O_gtissue_no); //
105 VAR_UCHAR (char_O_diluent); // new in v.101
106 VAR_UCHAR (char_O_flush_ppO2); // 2011-05-01: ppO2 from diluant (CCR mode).
107 VAR_UCHAR (char_O_EAD); // 2011-05-01: Added EAD/END in deco model.
108 VAR_UCHAR (char_O_END); // 2011-05-01: Added EAD/END in deco model.
109 VAR_UCHAR (char_O_relative_gradient_GF); // new in v.102
110
111 VAR_UCHAR (char_O_first_deco_depth); // Depth of first stop.
112 VAR_UCHAR (char_O_first_deco_time) ; // Duration of first stop.
113 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // Fusionned decompression table:
114 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // Both ZH-L16 and L16-GF models.
115 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS); // For logging the full decoplan
116
117 TAB_UCHAR (char_O_tissue_N2_saturation, NUM_COMP); // Nitrogen compartiment desaturation time, in min.
118 TAB_UCHAR (char_O_tissue_He_saturation, NUM_COMP); // Helium compartiment desaturation time, in min.
119
120 TAB_UINT (int_O_gas_volumes, 5); // Volumes evaluation for each gas tank, in 0.1 liters.
121
122 #ifdef __18CXX
123 //---- BANK 4 DATA -------------------------------------------------------
124 // Gather all data ASM-code --> C-code
125 # pragma udata overlay bank4=0x400
126 #else
127 ; In ASM, put the same bank, in overlay mode, at the same address
128 bank4 udata_ovr 0x400
129 #endif
130
131 VAR_UCHAR (char_I_step_is_1min); // Use 1min integration for tissue and CNS.
132
133 VAR_UINT (int_I_pres_respiration); //
134 VAR_UINT (int_I_pres_surface); //
135 VAR_UINT (int_I_temp); // new in v101
136 VAR_UINT (int_I_divemins); // Dive time (minutes)
137 VAR_UCHAR (char_I_temp); // new in v101
138 VAR_UCHAR (char_I_actual_ppO2); //
139 VAR_UCHAR (char_I_first_gas); // Gas used at start of dive (bottom mix)
140 VAR_UCHAR (char_I_current_gas); // Current gas breathed (1..3).
141 VAR_UCHAR (char_I_N2_ratio); //
142 VAR_UCHAR (char_I_He_ratio); //
143 VAR_UCHAR (char_I_O2_ratio); //
144 VAR_UCHAR (char_I_saturation_multiplier); // for conservatism/safety values 1.0 no conservatism to 1.5 50% faster saturation
145 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
146 VAR_UCHAR (char_I_GF_High_percentage); // new in v.102
147 VAR_UCHAR (char_I_GF_Low_percentage); // new in v.102
148 VAR_UCHAR (char_I_deco_distance); //
149 VAR_UCHAR (char_I_depth_last_deco); // new in v.101 unit: [m]
150 VAR_UCHAR (char_I_deco_model); // new in v.102. 0 == ZH-L16, 1 = ZH-L16-GF (Gradiant factor)
151 VAR_UCHAR (char_I_bottom_depth); // Bottom depth for planning (used in gas volume evaluation).
152 VAR_UCHAR (char_I_bottom_time); // Bottom time for planning (used in gas volume evaluation).
153 VAR_UCHAR (char_I_dive_interval); // Delay before next dive simulation.
154 VAR_UCHAR (char_I_const_ppO2); // new in v.101
155
156 TAB_UCHAR (char_I_deco_enable, NUM_GAS); // new in v.101
157
158 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // new in v.101
159 TAB_UCHAR (char_I_dil_change,NUM_GAS); // Must be placed after char_I_deco_gas_change!
160
161 TAB_UCHAR (char_I_setpoint_change,NUM_GAS); // Change depths in m
162 TAB_UCHAR (char_I_deco_N2_ratio, NUM_GAS); // new in v.101
163 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // new in v.101
164
165 TAB_UCHAR (char_I_setpoint_cbar,NUM_GAS); // Setpoints in cbar
166
167 VAR_UCHAR (char_I_bottom_usage); // [l/min]
168 VAR_UCHAR (char_I_deco_usage); // [l/min]
169
170 VAR_UCHAR (char_I_extra_time); // [min]
171 VAR_UCHAR (temp_bankx400); // temp