Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_main.c @ 116:14a074e1a375
Split C code, and use direct linking.
author | JeanDo |
---|---|
date | Sun, 26 Dec 2010 14:30:13 +0100 |
parents | |
children | cb055a7d75f3 |
comparison
equal
deleted
inserted
replaced
115:50a06adabc67 | 116:14a074e1a375 |
---|---|
1 // ************************************************************** | |
2 // ** main code for simulation / tests without assembler code ** | |
3 // ** This is NOT a part of the OSTC ** | |
4 // ************************************************************** | |
5 | |
6 ////////////////////////////////////////////////////////////////////////////// | |
7 // OSTC - diving computer code | |
8 // Copyright (C) 2008 HeinrichsWeikamp GbR | |
9 // | |
10 // This program is free software: you can redistribute it and/or modify | |
11 // it under the terms of the GNU General Public License as published by | |
12 // the Free Software Foundation, either version 3 of the License, or | |
13 // (at your option) any later version. | |
14 // | |
15 // This program is distributed in the hope that it will be useful, | |
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 // GNU General Public License for more details. | |
19 // | |
20 // You should have received a copy of the GNU General Public License | |
21 // along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 // | |
23 ////////////////////////////////////////////////////////////////////////////// | |
24 // history: | |
25 // 12/25/10 v110: [jDG] split in three files (deco.c, main.c, definitions.h) | |
26 | |
27 #include <p18f4685.h> | |
28 #include <stdlib.h> | |
29 | |
30 #include "p2_definitions.h" | |
31 | |
32 // ************************************************** | |
33 // ** Make sure to freeze ram banks used elsewhere ** | |
34 // ************************************************** | |
35 | |
36 #pragma udata bank0=0x060 | |
37 static const unsigned char keep_free_bank0[0xA0]; // used by the assembler code | |
38 | |
39 #pragma udata bank1=0x100 | |
40 static const unsigned char keep_free_bank1[256]; // used by the assembler code | |
41 | |
42 #pragma udata bank7=0x700 | |
43 const unsigned char keep_free_bank7[256]; // used by the assembler code (DD font2display) | |
44 | |
45 // ******************************** | |
46 // ** C O N F I G U R A T I O N ** | |
47 // ** for simulation without asm ** | |
48 // ******************************** | |
49 #pragma config OSC = IRCIO67 | |
50 #pragma config FCMEN = OFF | |
51 #pragma config IESO = OFF | |
52 #pragma config PWRT = ON | |
53 #pragma config BOREN = OFF | |
54 #pragma config WDT = OFF | |
55 #pragma config WDTPS = 128 | |
56 #pragma config MCLRE = ON | |
57 #pragma config LPT1OSC = OFF | |
58 #pragma config PBADEN = OFF | |
59 #pragma config DEBUG = OFF | |
60 #pragma config XINST = OFF | |
61 #pragma config LVP = OFF | |
62 #pragma config STVREN = OFF | |
63 | |
64 // ************************* | |
65 // ** P R O T O T Y P E S ** | |
66 // ************************* | |
67 | |
68 void main(void); | |
69 | |
70 // ******************************* | |
71 // ** start ** | |
72 // ** necessary for compilation ** | |
73 // ******************************* | |
74 #pragma romdata der_code = 0x0000 | |
75 #pragma code der_start = 0x0000 | |
76 void der_start(void) | |
77 { | |
78 _asm | |
79 goto main | |
80 _endasm | |
81 } | |
82 | |
83 #pragma code main = 0x9000 | |
84 #pragma udata | |
85 void main(void) | |
86 { | |
87 static unsigned int i; | |
88 static unsigned int debug_temp; | |
89 | |
90 #if 1 | |
91 // new main to test DR-5 | |
92 | |
93 char_I_deco_model = 0; | |
94 | |
95 char_I_GF_Low_percentage = 100; | |
96 char_I_GF_High_percentage = 100; | |
97 | |
98 deco_clear_CNS_fraction(); | |
99 //char_I_const_ppO2 = 100; | |
100 //for (i=0;i<255;i++) | |
101 //{ | |
102 //calc_CNS_fraction(); | |
103 //} //for | |
104 | |
105 int_I_pres_respiration = 1000;//980; | |
106 int_I_pres_surface = 1000;//980; | |
107 char_I_N2_ratio = 79; //38; | |
108 char_I_He_ratio = 0; //50; | |
109 char_I_deco_distance = 10; // 10 = 1 meter | |
110 char_I_depth_last_deco = 3; // values below 3 (meter) are ignored | |
111 | |
112 char_I_const_ppO2 = 0; | |
113 char_I_deco_ppO2_change = 0; // [dm] 10 = 1 meter | |
114 char_I_deco_ppO2 = 0; | |
115 | |
116 char_I_deco_gas_change = 20; // [m] 1 = 1 meter | |
117 char_I_deco_N2_ratio = 50; | |
118 char_I_deco_He_ratio = 0; | |
119 | |
120 char_I_deco_gas_change2 = 6; // [m] 1 = 1 meter | |
121 char_I_deco_N2_ratio2 = 0; | |
122 char_I_deco_He_ratio2 = 0; | |
123 | |
124 char_I_deco_gas_change3 = 0; // [m] 1 = 1 meter | |
125 char_I_deco_gas_change4 = 0; // [m] 1 = 1 meter | |
126 char_I_deco_gas_change5 = 0; // [m] 1 = 1 meter | |
127 | |
128 //char_I_actual_ppO2; // 0x507 | |
129 char_I_GF_High_percentage = 100; // 0x514 new in v.102 | |
130 char_I_GF_Low_percentage = 100; // 0x515 new in v.102 | |
131 | |
132 char_I_saturation_multiplier = 110; | |
133 char_I_desaturation_multiplier = 90; | |
134 calc_hauptroutine_data_input(); | |
135 | |
136 deco_clear_tissue(); | |
137 | |
138 char_I_step_is_1min = 1; | |
139 int_I_pres_respiration = 4500 + int_I_pres_surface; | |
140 | |
141 for (i=0;i<29;i++) | |
142 { | |
143 deco_calc_hauptroutine(); | |
144 } | |
145 | |
146 char_I_step_is_1min = 0; | |
147 char_O_deco_status = 255; | |
148 while (char_O_deco_status) | |
149 deco_calc_hauptroutine(); | |
150 _asm | |
151 nop | |
152 _endasm | |
153 | |
154 char_O_deco_status = 255; | |
155 while (char_O_deco_status) | |
156 deco_calc_hauptroutine(); | |
157 _asm | |
158 nop | |
159 _endasm | |
160 | |
161 int_I_pres_respiration = 10000; | |
162 for (i=0;i<1500;i++) | |
163 { | |
164 deco_calc_hauptroutine(); | |
165 } | |
166 | |
167 _asm | |
168 nop | |
169 _endasm | |
170 | |
171 | |
172 int_I_pres_respiration = 3000; | |
173 for (i=0;i<150;i++) | |
174 { | |
175 calc_hauptroutine_data_input(); | |
176 calc_hauptroutine_update_tissues(); | |
177 } //for | |
178 | |
179 update_startvalues(); | |
180 clear_decoarray(); | |
181 clear_internal_deco_table_GF(); | |
182 calc_hauptroutine_calc_ascend_to_deco(); | |
183 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot | |
184 { | |
185 char_O_deco_status = 2; | |
186 // char_O_lock_depth_list = 255; | |
187 } | |
188 else | |
189 { | |
190 // char_O_lock_depth_list = lock_GF_depth_list; | |
191 calc_hauptroutine_calc_deco(); | |
192 } | |
193 // build_debug_output(); | |
194 | |
195 _asm | |
196 nop | |
197 _endasm | |
198 while (char_O_deco_status == 1) | |
199 { | |
200 char_O_deco_status = 0; | |
201 // char_O_lock_depth_list = 255; | |
202 calc_hauptroutine_calc_deco(); | |
203 // build_debug_output(); | |
204 _asm | |
205 nop | |
206 _endasm | |
207 }; | |
208 debug_temp = 60; // [mtr Aufstieg in 10 mtr/min (30steps'2sec/min] | |
209 int_I_pres_respiration = 9980; | |
210 for (i=0;i<debug_temp;i++) | |
211 { | |
212 int_I_pres_respiration = int_I_pres_respiration - 33; | |
213 calc_hauptroutine_data_input(); | |
214 calc_hauptroutine_update_tissues(); | |
215 int_I_pres_respiration = int_I_pres_respiration - 33; | |
216 calc_hauptroutine_data_input(); | |
217 calc_hauptroutine_update_tissues(); | |
218 int_I_pres_respiration = int_I_pres_respiration - 34; | |
219 calc_hauptroutine_data_input(); | |
220 calc_hauptroutine_update_tissues(); | |
221 } //for | |
222 _asm | |
223 nop | |
224 _endasm | |
225 | |
226 update_startvalues(); | |
227 clear_decoarray(); | |
228 clear_internal_deco_table_GF(); | |
229 calc_hauptroutine_calc_ascend_to_deco(); | |
230 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot | |
231 { | |
232 char_O_deco_status = 2; | |
233 // char_O_lock_depth_list = 255; | |
234 } | |
235 else | |
236 { | |
237 // char_O_lock_depth_list = lock_GF_depth_list; | |
238 calc_hauptroutine_calc_deco(); | |
239 } | |
240 // build_debug_output(); | |
241 | |
242 _asm | |
243 nop | |
244 _endasm | |
245 while (char_O_deco_status == 1) | |
246 { | |
247 char_O_deco_status = 0; | |
248 // char_O_lock_depth_list = 255; | |
249 calc_hauptroutine_calc_deco(); | |
250 // build_debug_output(); | |
251 _asm | |
252 nop | |
253 _endasm | |
254 }; | |
255 _asm | |
256 nop | |
257 _endasm | |
258 debug_temp = 60; // [mtr Aufstieg in 10 mtr/min (30steps'2sec/min] | |
259 int_I_pres_respiration = 9980; | |
260 debug_temp = debug_temp * 3; | |
261 for (i=0;i<debug_temp;i++) | |
262 { | |
263 calc_hauptroutine_data_input(); | |
264 calc_hauptroutine_update_tissues(); | |
265 } //for | |
266 _asm | |
267 nop | |
268 _endasm | |
269 #endif | |
270 // ----------------------- | |
271 | |
272 } // main |