Mercurial > public > hwos_code
annotate src/shared_definitions.h @ 628:cd58f7fc86db
3.05 stable work
| author | heinrichsweikamp |
|---|---|
| date | Thu, 19 Sep 2019 12:01:29 +0200 |
| parents | c40025d8e750 |
| children | 185ba2f91f59 |
| rev | line source |
|---|---|
| 0 | 1 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 2 ; | |
| 628 | 3 ; shared_definitions.h combined next generation V3.04.3 |
| 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 ; | |
| 604 | 20 ; Copyright (c) 2010, JD Gascuel |
| 0 | 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 | |
| 604 | 34 ; 2011-01-20: [jDG] Creation |
| 0 | 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 | |
| 582 | 48 //------------------------------------------------------------------------ |
| 604 | 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 | |
| 0 | 61 #else |
| 582 | 62 ;------------------------------------------------------------------------- |
| 604 | 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 | |
| 0 | 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 |
| 604 | 72 Define Model Dimensions |
| 0 | 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. | |
| 604 | 81 NUM_SP is the number of setpoints |
| 0 | 82 #endif |
| 623 | 83 #define NUM_COMP 0x10 |
| 84 #define NUM_STOPS 0x20 | |
| 85 #define NUM_STOPS_LOG 0x0F | |
| 86 #define NUM_GAS 5 | |
| 0 | 87 |
| 560 | 88 |
| 89 #ifdef __18CXX | |
| 582 | 90 //---- BANK 3 DATA ------------------------------------------------------- |
| 604 | 91 // Gather all Data C-Code --> ASM-Code |
| 628 | 92 // Memory usage: 247 Byte used, 9 Byte free |
| 560 | 93 # pragma udata overlay bank3=0x300 |
| 94 #else | |
| 604 | 95 ; in ASM, put the same bank, in overlay mode, at the same address |
| 623 | 96 bank3 equ 0x300 |
| 97 bank3 udata_ovr bank3 | |
| 560 | 98 #endif |
| 99 | |
| 623 | 100 VAR_UINT (int_O_desaturation_time); // time until tissues desaturated to 5% remains, in minutes |
| 101 VAR_UINT (int_O_nofly_time); // altitude / no-fly waiting time time in minutes | |
| 560 | 102 |
| 623 | 103 VAR_UINT (int_O_TTS_norm); // ascent time (TTS) in normal plan in minutes |
| 104 VAR_UINT (int_O_TTS_alt); // ascent time (TTS) in alternative plan in minutes | |
| 604 | 105 |
| 623 | 106 VAR_UINT (int_O_CNS_current); // current CNS % |
| 107 VAR_UINT (int_O_CNS_norm); // CNS% at end of dive in normal dive plan | |
| 108 VAR_UINT (int_O_CNS_alt); // CNS% at end of dive in alternative plan | |
| 0 | 109 |
| 623 | 110 VAR_UINT (int_O_lead_supersat); // supersaturation of the leading tissue in %, 100% = on M-line of straight Buhlmann |
| 560 | 111 |
| 623 | 112 VAR_UCHAR (char_O_lead_tissue); // number of the leading tissue |
| 113 | |
| 114 VAR_UCHAR (char_O_NDL_norm); // remaining NDL time for the normal dive plan in minutes | |
| 115 VAR_UCHAR (char_O_NDL_alt); // remaining NDL time for the alternative dive plan in minutes | |
| 560 | 116 |
| 623 | 117 VAR_UCHAR (char_O_main_status); // setup of the deco engine regarding the real tissue computations |
| 118 VAR_UCHAR (char_O_deco_status); // setup of the deco engine regarding the decompression computations | |
| 119 VAR_UCHAR (char_O_deco_warnings); // vector of warnings generated by the deco engine | |
| 120 VAR_UCHAR (char_O_deco_info); // vector of infos generated by the deco engine | |
| 560 | 121 |
| 623 | 122 VAR_UCHAR (char_O_EAD); // equivalent air depth (EAD) of breathed gas |
| 123 VAR_UCHAR (char_O_END); // equivalent narcosis depth (END) of breathed gas | |
| 560 | 124 |
| 623 | 125 TAB_UCHAR (char_O_tissue_pres_N2, NUM_COMP); // N2 tissue pressures for display purpose |
| 126 TAB_UCHAR (char_O_tissue_pres_He, NUM_COMP); // He tissue pressures for display purpose | |
| 127 TAB_UCHAR (char_O_tissue_pressure, NUM_COMP); // total tissue pressures for display purpose | |
| 128 TAB_UCHAR (char_O_tissue_saturation, NUM_COMP); // tissue saturations for display purpose | |
| 0 | 129 |
| 623 | 130 TAB_UINT (int_O_gas_need_vol, NUM_GAS); // gas volumes needed for ascent in liters |
| 131 TAB_UINT (int_O_gas_need_pres, NUM_GAS); // gas volumes needed for ascent in bar as per tank size | |
| 0 | 132 |
| 623 | 133 VAR_UINT (int_O_ceiling); // ascent boundary in mbar relative pressure, calculated at GF-high |
| 134 | |
| 135 VAR_UINT (int_O_breathed_ppO2); // ppO2 actually breathed (= int_O_pure_ppO2 if in OC) | |
| 560 | 136 |
| 623 | 137 VAR_UINT (int_O_O2_ppO2); // ppO2 of pure O2 at current depth |
| 138 VAR_UINT (int_O_pure_ppO2); // ppO2 of the current gas or diluent if breathed pure | |
| 139 VAR_UINT (int_O_pSCR_ppO2); // ppO2 calculated in pSCR loop | |
| 604 | 140 |
| 0 | 141 |
| 623 | 142 TAB_UINT (int_O_pressure_need, 2); // pressure reading, need by deco calculations, in 0.1 bar |
| 143 VAR_UINT (int_O_SAC_measured); // measured SAC rate in 0.1 liter/minute | |
| 144 | |
| 145 VAR_UCHAR (char_O_depth_sim); // depth reached in deco calculation, used in deco calculator to show progress | |
| 0 | 146 |
| 582 | 147 VAR_UINT (int_I_pres_respiration); // absolute pressure breathed |
| 148 VAR_UINT (int_I_pres_surface); // absolute pressure at surface | |
| 560 | 149 |
| 623 | 150 VAR_UCHAR (char_I_current_gas_num); // number of gas currently breathed (1..5 for configured gases, 6 for the manual gas) |
| 604 | 151 VAR_UCHAR (char_I_current_gas_type); // type of current gas: (0=Disabled), 1=First, 2=Travel/Normal, 3=Deco/- |
| 152 VAR_UCHAR (char_I_He_ratio); // helium ratio of the currently breathed gas | |
| 153 VAR_UCHAR (char_I_O2_ratio); // oxygen ratio of the currently breathed gas | |
| 560 | 154 |
| 582 | 155 VAR_UCHAR (char_I_saturation_multiplier); // safety factor, 100 = no conservatism, 150 = 50% faster saturation |
| 156 VAR_UCHAR (char_I_desaturation_multiplier); // safety factor, 100 = no conservatism, 66 = 50% slower desaturation | |
| 560 | 157 |
| 582 | 158 VAR_UCHAR (char_I_GF_High_percentage); // GF model high value |
| 159 VAR_UCHAR (char_I_GF_Low_percentage); // GF model low value | |
| 560 | 160 |
| 582 | 161 VAR_UCHAR (char_I_depth_last_deco); // depth of the last deco stop in meters |
| 560 | 162 |
| 582 | 163 VAR_UCHAR (char_I_deco_model); // deco model selection: 0 = ZH-L16, 1 = ZH-L16-GF (with gradient factors) |
| 560 | 164 |
| 582 | 165 VAR_UCHAR (char_I_bottom_depth); // bottom depth, used for gas volume calculations |
| 166 VAR_UCHAR (char_I_bottom_time); // bottom time, used for gas volume calculations | |
| 560 | 167 |
| 582 | 168 VAR_UCHAR (char_I_dive_interval); // duration of surface break before next dive in minutes, used in simulation |
| 169 VAR_UCHAR (char_I_sim_advance_time); // 'fast forward' of dive time, used in simulation (+5 min function) | |
| 604 | 170 VAR_UCHAR (char_I_extra_time); // extra bottom time for fTTs and delayed ascent calculation in minutes |
| 560 | 171 |
| 623 | 172 VAR_UCHAR (char_I_const_ppO2); // ppO2 reported from sensors or selected setpoint |
| 560 | 173 |
| 604 | 174 TAB_UCHAR (char_I_deco_O2_ratio, NUM_GAS); // oxygen ratios of the configured gases, used for deco calc. | ATTENTION: do not change the |
| 175 TAB_UCHAR (char_I_deco_He_ratio, NUM_GAS); // helium ratios of the configured gases, used for deco calc. | position of these | |
| 176 TAB_UCHAR (char_I_deco_gas_type, NUM_GAS); // type of the configured gases, used for deco calc. | arrays relative to | |
| 177 TAB_UCHAR (char_I_deco_gas_change,NUM_GAS); // change depths of the configured gases, used for deco calc. | each other! | |
| 560 | 178 |
| 623 | 179 TAB_UCHAR (char_I_gas_avail_size, NUM_GAS * 2); // tank sizes, used for pressure needs and SAC calculations |
| 180 TAB_UCHAR (char_I_gas_avail_pres, NUM_GAS * 2); // tank pressures available (in multiples of 10 bar), used to generate warnings | |
| 0 | 181 |
| 623 | 182 VAR_UCHAR (char_I_CC_max_frac_O2); // limiter for maximum O2% in loop |
| 582 | 183 VAR_UCHAR (char_I_PSCR_drop); // pSCR parameter drop [%] |
| 184 VAR_UCHAR (char_I_PSCR_lungratio); // pSCR parameter lung ratio [1/x] | |
| 0 | 185 |
| 582 | 186 VAR_UCHAR (char_I_altitude_wait); // selector for altitude / no-fly waiting time calculation |
| 560 | 187 |
| 623 | 188 VAR_UCHAR (char_I_SAC_work); // gas consumption during bottom part and initial ascent in liters/minute |
| 189 VAR_UCHAR (char_I_SAC_deco); // gas consumption during deco stops and following ascents in liters/minute | |
| 0 | 190 |
| 604 | 191 VAR_UCHAR (char_I_gas6_depth); // change depth (MOD) of the manually configured gas in meters |
| 582 | 192 |
| 623 | 193 VAR_UCHAR (char_I_ppO2_max_work); // warning threshold for maximum ppO2 during working phase of the dive |
| 194 VAR_UCHAR (char_I_ppO2_max_deco); // warning threshold for maximum ppO2 during deco phase of the dive | |
| 582 | 195 VAR_UCHAR (char_I_ppO2_min); // warning threshold for maximum ppO2 when breathing OC |
| 196 VAR_UCHAR (char_I_ppO2_min_loop); // warning threshold for maximum ppO2 when breathing from CCR or pSCR | |
| 197 | |
| 623 | 198 VAR_UCHAR (char_I_ascent_speed); // ascent speed in meters/minute |
| 199 VAR_UCHAR (char_I_descent_speed); // descent speed in meters/minute | |
| 582 | 200 VAR_UCHAR (char_I_gas_change_time); // extra time spent during a stop for doing a gas change, in minutes |
| 604 | 201 |
| 202 VAR_UCHAR (char_I_SAC_mode); // SAC calculation mode | |
| 203 VAR_UCHAR (char_I_max_pres_diff); // maximum pressure difference for independent double mode | |
| 204 | |
| 205 TAB_UINT (int_IO_pressure_value,2); // pressure reading, measured pressure, in 0.1 bar | ATTENTION: do not change the position | |
| 206 TAB_UINT (int_I_pressure_drop, 2); // pressure reading, average pressure drop, in 1/160 bar/sec | of these arrays relative to each other! | |
| 207 | |
| 208 TAB_UCHAR (char_I_pressure_gas, 2); // pressure reading, associated gas (1-5) / diluent (6-10), 0 if off | |
| 209 TAB_UCHAR (char_I_pressure_age, 2); // pressure reading, age of data | |
| 210 TAB_UCHAR (char_I_pressure_stat,2); // pressure reading, transmitter status data | |
| 211 | |
| 628 | 212 TAB_UCHAR (char_O_deco_time_for_log, NUM_STOPS_LOG); // times of the shallowest NUM_STOPS_LOG deco stops |
| 604 | 213 |
| 623 | 214 VAR_UINT (int_O_profiling_overrun); // current scheduling overrun in ms |
| 215 VAR_UINT (int_O_profiling_overrun_max); // maximum scheduling overrun in ms | |
| 216 VAR_UCHAR (char_O_profiling_overrun_phase); // calculation phase causing the maximum overrun | |
| 217 VAR_UCHAR (char_O_profiling_runs_norm); // runs per cycle for normal plan | |
| 218 VAR_UCHAR (char_O_profiling_runs_alt); // runs per cycle for alternative plan | |
| 219 | |
| 628 | 220 VAR_UINT (int_O_tank_pressure); // tank pressure for logging in [bar] |
| 221 VAR_UINT (int_O_gas_density); // gas density of currently breathed mix in multiples of 0.01 grams per liter | |
| 222 | |
| 223 VAR_UCHAR (char_I_backtrack_time); // index (in minutes) of backtrack entries in char_I_backtrack_depth | |
| 224 VAR_UCHAR (char_I_gas_contingency); // =1: switch to alternative gas if best gas is depleted | |
| 225 | |
| 226 VAR_UCHAR (char_I_gas_density_att); // threshold for gas density attention [0.1 grams/l] | |
| 227 VAR_UCHAR (char_I_gas_density_warn); // threshold for gas density warning [0.1 grams/l] | |
| 228 | |
| 229 VAR_UCHAR (char_I_dil_ppO2_check); // =1: check ppO2 of the pure diluent against current setpoint | |
| 623 | 230 |
| 231 | |
| 232 #ifdef __18CXX | |
| 233 //---- BANK 4 DATA ------------------------------------------------------- | |
| 234 // Gather all Data ASM-Code --> C-Code | |
| 235 // Memory usage: 96 Byte used, 160 byte free | |
| 236 # pragma udata overlay bank4=0x400 | |
| 237 #else | |
| 238 ; in ASM, put the same bank, in overlay mode, at the same address | |
| 239 bank4 equ 0x400 | |
| 240 bank4 udata_ovr bank4 | |
| 241 #endif | |
| 242 | |
| 243 TAB_UCHAR (char_O_deco_depth, NUM_STOPS); // stops table: depth, ... | ATTENTION: do not re-arrange these | |
| 244 TAB_UCHAR (char_O_deco_time, NUM_STOPS); // ... duration, and | three arrays relative | |
| 245 TAB_UCHAR (char_O_deco_gas, NUM_STOPS); // ... gas breathed | to each other! | |
| 246 | |
| 604 | 247 |
| 248 #ifdef __18CXX | |
| 249 //---- BANK 11 DATA ------------------------------------------------------- | |
| 250 // Backtracking Data ASM-Code --> C-Code | |
| 251 // Memory usage: 256 Byte used, 0 byte free | |
| 252 # pragma udata overlay bank11=0xB00 | |
| 253 #else | |
| 254 ; in ASM, put the same bank, in overlay mode, at the same address | |
| 255 bank11 udata_ovr 0xB00 | |
| 256 #endif | |
| 257 | |
| 258 TAB_UCHAR (char_I_backtrack_depth, 0x100); // recorded depths for backtracking in cave mode |
