Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/start.asm @ 812:86efd57c158c
minor italian update
author | heinrichsweikamp |
---|---|
date | Wed, 25 Mar 2015 18:24:58 +0100 |
parents | c50296c3059e |
children | 2a0e5d884fc3 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
796
diff
changeset
|
2 ; Copyright (C) 2015 HeinrichsWeikamp GbR |
0 | 3 |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Start and init | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 10/13/04 | |
21 ; last updated: 06/24/08 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 start: | |
26 movlb b'00000001' ; ram bank 1 selected | |
521 | 27 movff STKPTR,temp10 ; Save stack pointer, for crash reports. |
235 | 28 clrf temp10+1 |
0 | 29 call init |
30 btfsc divemode ; Reset from Divemode? | |
681 | 31 call DISP_resetdebugger ; Yes! Something went wrong, show reset informations |
306 | 32 start3: |
0 | 33 clrf STKPTR ; Clear Stackpointer |
359 | 34 lfsr FSR0,year+1 ; Clear rambank 1-9, do not delete RTC registers |
0 | 35 clear_rambank: |
36 clrf POSTINC0 | |
37 movlw 0x0A | |
38 cpfseq FSR0H ; Bank 9 done? | |
39 bra clear_rambank ; clear... | |
40 | |
41 ; Defaults for RTC | |
42 call disable_rs232 ; disable UART module | |
43 call RTCinit ; reset RTC | |
44 | |
45 ; Air pressure compensation after reset | |
46 call get_calibration_data ; Get calibration data from pressure sensor | |
714 | 47 banksel flag5 |
713 | 48 bcf no_sensor_int ; Enable sensor interrupt |
0 | 49 bcf pressure_refresh |
50 wait_start_pressure: | |
51 btfss pressure_refresh ; Air pressure compensation | |
52 bra wait_start_pressure | |
53 | |
54 clrf rel_pressure+0 | |
55 clrf rel_pressure+1 | |
56 clrf surface_interval+0 | |
57 clrf surface_interval+1 | |
58 | |
59 bsf sleepmode ; Routine only works in sleepmode... | |
60 call pressuretest_sleep_fast ; Gets pressure without averaging (faster!) | |
61 bcf sleepmode ; Normal mode again | |
233 | 62 |
521 | 63 ; Extra power-up reset (JeanDo emulator) |
64 Ifdef TESTING | |
65 call reset_gases | |
66 call reset_all_cf | |
67 call reset_external_eeprom | |
68 | |
69 movlw LOW(.1000) | |
70 movwf amb_pressure+0 | |
71 movlw HIGH(.1000) | |
72 movwf amb_pressure+1 | |
73 Endif | |
74 | |
75 ; Get real pressure (if not in emulator mode) | |
76 Ifndef TESTING | |
507 | 77 SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure ; copy for compatibility |
78 Endif | |
79 | |
80 movff amb_pressure+0,last_surfpressure+0 | |
81 movff amb_pressure+1,last_surfpressure+1 | |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
327
diff
changeset
|
82 movff last_surfpressure+0,last_surfpressure_15min+0 |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
327
diff
changeset
|
83 movff last_surfpressure+1,last_surfpressure_15min+1 |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
327
diff
changeset
|
84 movff last_surfpressure+0,last_surfpressure_30min+0 |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
327
diff
changeset
|
85 movff last_surfpressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers |
0 | 86 |
87 ; reset deco data | |
236 | 88 ostc_debug '0' ; Sends debug-information to screen if debugmode active |
89 | |
0 | 90 movlw d'79' ; 79% N2 |
197 | 91 movff WREG,char_I_N2_ratio ; No He at the Surface |
236 | 92 clrf WREG ; Use as buffer |
93 movff WREG,char_I_He_ratio ; No He at the Surface | |
94 movff WREG,char_I_step_is_1min ; 2 second deco mode | |
95 GETCUSTOM8 d'11' ; Saturation multiplier % | |
96 movff WREG,char_I_saturation_multiplier | |
97 GETCUSTOM8 d'12' ; Desaturation multiplier % | |
98 movff WREG,char_I_desaturation_multiplier | |
507 | 99 movff amb_pressure+0,int_I_pres_respiration+0 ; copy for deco routine |
100 movff amb_pressure+1,int_I_pres_respiration+1 | |
101 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine | |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
327
diff
changeset
|
102 movff int_I_pres_respiration+1,int_I_pres_surface+1 |
0 | 103 |
513 | 104 call deco_clear_tissue |
105 movlb b'00000001' ; select ram bank 1 | |
106 | |
508
b595569e4bcc
BUGFIX char_I_(N2_ratio/He_ratio) array not inited at boot time
JeanDo
parents:
507
diff
changeset
|
107 call divemode_check_decogases ; Setup N2/He ratio array |
520
acf4776eec08
BUGFIX bank1 error, deco_calc_wo_deco done twice in start routine.
JeanDo
parents:
513
diff
changeset
|
108 |
acf4776eec08
BUGFIX bank1 error, deco_calc_wo_deco done twice in start routine.
JeanDo
parents:
513
diff
changeset
|
109 call calc_deko_surfmode ; calculate desaturation for one minute |
acf4776eec08
BUGFIX bank1 error, deco_calc_wo_deco done twice in start routine.
JeanDo
parents:
513
diff
changeset
|
110 |
116 | 111 call deco_calc_desaturation_time ; calculate desaturation time |
112 call deco_clear_CNS_fraction ; clear CNS | |
520
acf4776eec08
BUGFIX bank1 error, deco_calc_wo_deco done twice in start routine.
JeanDo
parents:
513
diff
changeset
|
113 movlb b'00000001' ; select ram bank 1 |
acf4776eec08
BUGFIX bank1 error, deco_calc_wo_deco done twice in start routine.
JeanDo
parents:
513
diff
changeset
|
114 |
412 | 115 clrf nofly_time+0 ; Reset NoFly |
116 clrf nofly_time+1 ; Reset NoFly | |
117 bcf nofly_active ; Clear flag | |
0 | 118 |
119 ; check firmware and reset Custom Functions after an update | |
384
904863f96582
Work-Around for "Reset all" overwriting 0x00 to 0x04 in EEPROM Bank1
heinrichsweikamp
parents:
380
diff
changeset
|
120 movlw d'1' |
0 | 121 movwf EEADR |
384
904863f96582
Work-Around for "Reset all" overwriting 0x00 to 0x04 in EEPROM Bank1
heinrichsweikamp
parents:
380
diff
changeset
|
122 movlw d'1' |
0 | 123 movwf EEADRH |
124 call read_eeprom ; read current version x | |
125 movff EEDATA,temp1 | |
126 incf EEADR,F ; set to 0x102 | |
127 call read_eeprom ; read current version y | |
128 movff EEDATA,temp2 | |
129 clrf EEADRH ; Reset EEADRH | |
130 | |
131 movlw softwareversion_x | |
132 cpfseq temp1 ; compare version x | |
133 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM | |
134 | |
135 movlw softwareversion_y | |
136 cpfseq temp2 ; compare version y | |
137 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM | |
138 bra restart ; x and y are equal -> do not reset cf | |
139 | |
140 check_firmware_new: | |
384
904863f96582
Work-Around for "Reset all" overwriting 0x00 to 0x04 in EEPROM Bank1
heinrichsweikamp
parents:
380
diff
changeset
|
141 movlw d'1' ; store current version in EEPROM |
0 | 142 movwf EEADR |
384
904863f96582
Work-Around for "Reset all" overwriting 0x00 to 0x04 in EEPROM Bank1
heinrichsweikamp
parents:
380
diff
changeset
|
143 movlw d'1' |
0 | 144 movwf EEADRH |
145 movlw softwareversion_x | |
146 movwf EEDATA | |
147 call write_eeprom ; write version x | |
148 incf EEADR,F ; set to 0x102 | |
149 movlw softwareversion_y | |
150 movwf EEDATA | |
151 call write_eeprom ; write version y | |
152 clrf EEADRH ; Reset EEADRH | |
392 | 153 |
500 | 154 ; After update resets |
155 ; Reset brightness to ECO | |
578 | 156 movlw LOW 0x103 |
500 | 157 movwf EEADR |
578 | 158 movlw HIGH 0x103 |
681 | 159 movwf EEADRH ; DISPLAY brightness (=0: Eco, =1: High) |
500 | 160 movlw .0 |
161 movwf EEDATA | |
162 call write_eeprom ; write byte | |
649 | 163 clrf EEADRH ; Reset EEADRH |
164 | |
796 | 165 call reset_all_cf_bank2 ; Reset CF64-93 with this update.... |
166 | |
0 | 167 restart: |
720 | 168 ; check for time/date vault |
169 movlw .1 | |
170 movwf EEADRH | |
171 read_int_eeprom .5 | |
172 movlw 0xAA | |
173 cpfseq EEDATA ; 0xAA in EEPROM Bank1, Byte 5? | |
174 bra restart0 ; No | |
175 | |
176 movlw 0x00 | |
177 movwf EEDATA | |
178 write_int_eeprom d'5' ; clear flag | |
179 read_int_eeprom .6 | |
180 movff EEDATA,year | |
181 read_int_eeprom .7 | |
182 movff EEDATA,month | |
183 read_int_eeprom .8 | |
184 movff EEDATA,day | |
185 read_int_eeprom .9 | |
186 movff EEDATA,hours | |
187 read_int_eeprom .10 | |
188 movff EEDATA,mins | |
189 read_int_eeprom .11 | |
190 movff EEDATA,secs | |
191 call RTCinit ; Check limits | |
192 restart0: | |
193 clrf EEADRH | |
390 | 194 movlw b'00000011' |
195 movwf T3CON ; Timer3 with 32768Hz clock running | |
196 clrf TMR3L | |
537 | 197 nop |
390 | 198 clrf TMR3H |
21 | 199 bcf LED_red |
200 bcf LED_blue ; all LEDs off | |
43 | 201 GETCUSTOM8 d'48' ; time correction value |
202 movff WREG, time_correction_value ; store in Bank0 register | |
15 | 203 |
204 clrf flag1 ; clear all flags | |
205 clrf flag2 | |
206 clrf flag3 | |
207 clrf flag4 | |
208 clrf flag5 | |
209 clrf flag6 | |
210 clrf flag7 | |
211 clrf flag8 | |
212 clrf flag9 | |
213 clrf flag10 | |
214 clrf flag11 | |
215 clrf flag12 | |
216 clrf flag13 | |
217 clrf flag14 | |
218 clrf flag15 | |
730 | 219 clrf flag16 |
153 | 220 |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
221 ; Should we set win_flip_screen ? |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
222 bsf flag1,0 ; Precondition to yes |
153 | 223 clrf EEADRH ; Reset EEADRH |
224 read_int_eeprom d'1' | |
225 movlw .7 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
226 cpfsgt EEDATA ; serial > 2048 (Mk2n hardware) ? |
153 | 227 bcf flag1,0 |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
228 incf EEDATA,W ; serial == 65535 (emulation) ? |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
229 btfsc STATUS,Z |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
230 bcf flag1,0 |
153 | 231 movff flag1,win_flags ; store in Bank0 register |
232 clrf flag1 ; Clear flag1 (again) | |
239 | 233 |
234 ; Select high altitude (Fly) mode? | |
235 movff last_surfpressure_30min+0,sub_b+0 | |
236 movff last_surfpressure_30min+1,sub_b+1 | |
237 movlw HIGH d'880' | |
238 movwf sub_a+1 | |
239 movlw LOW d'880' ; Hard-wired 880mBar | |
240 movwf sub_a+0 | |
241 call sub16 ; sub_c = sub_a - sub_b | |
242 btfss neg_flag ; Result negative (Ambient>880mBar)? | |
243 bsf high_altitude_mode ; No, Set Flag! | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
244 |
142 | 245 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth |
0 | 246 WIN_TOP .0 |
247 WIN_LEFT .0 | |
248 WIN_FONT FT_SMALL | |
249 WIN_INVERT .0 ; Init new Wordprocessor | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
62
diff
changeset
|
250 setf WREG |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
62
diff
changeset
|
251 movff WREG,win_color1 ; Beware: win_color1 is bank0, and we are bank1 currently |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
62
diff
changeset
|
252 movff WREG,win_color2 |
0 | 253 call I2CReset ; Just in Case any I2C device blocks the Bus |
254 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure | |
255 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure | |
256 | |
257 ; Check if new CF were added in the last firmware version | |
258 clrf EEADRH | |
259 read_int_eeprom d'92' ; Read number of CF used in this firmware | |
260 movlw max_custom_number ; Defined in definitions.asm | |
261 cpfseq EEDATA ; Compare with last version | |
605 | 262 bra restart1 ; New CF, show warning and store new number |
263 bra restart2 ; No new CF, continue with boot | |
264 | |
265 restart1: | |
622 | 266 ; Reset all CF and Gases |
776 | 267 ; call reset_gases |
268 ; call reset_all_cf | |
605 | 269 ; Show info screen |
681 | 270 call DISPLAY_boot ; DISP boot (Incl. Clear Screen!) |
605 | 271 rcall display_new_cf_installed; Show info screen |
0 | 272 ; Save new number of current CF count |
273 movlw max_custom_number ; Defined in definitions.asm | |
274 movwf EEDATA | |
275 write_int_eeprom d'92' ; Store number of CF used in this firmware | |
276 | |
605 | 277 restart2: |
0 | 278 ; Set Debug mode? |
279 read_int_eeprom d'39' | |
280 bsf debug_mode | |
281 movlw d'1' | |
282 cpfseq EEDATA | |
283 bcf debug_mode ; clear flag if <> 1 | |
284 | |
362
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
285 ; Check if logbook has been converted already (Internal EEPROM 0x100=0xAA) |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
286 movlw LOW 0x100 |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
287 movwf EEADR |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
288 movlw HIGH 0x100 |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
289 movwf EEADRH |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
290 call read_eeprom ; read byte |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
291 movlw 0xAA |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
292 cpfseq EEDATA ; is 0xAA already? |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
293 call logbook_convert_64k ; No, convert now (And write 0xAA to internal EEPROM 0x100) |
64da813d4726
Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
Heinrichsweikamp
parents:
359
diff
changeset
|
294 |
681 | 295 ; Set DISPLAY brightness flag |
578 | 296 movlw LOW 0x103 |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
297 movwf EEADR |
578 | 298 movlw HIGH 0x103 |
681 | 299 movwf EEADRH ; DISPLAY brightness (=0: Eco, =1: High) |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
300 call read_eeprom ; read byte |
681 | 301 bcf DISPLAY_brightness_high ; Eco mode |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
302 movlw .0 |
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
303 cpfseq EEDATA ; High? |
681 | 304 bsf DISPLAY_brightness_high ; Yes! |
499
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
305 |
2ac77db9c150
Added OLED brightness setting, texts 280, 312 and 313 need update
heinrichsweikamp
parents:
493
diff
changeset
|
306 clrf EEADRH ; Reset EEADRH |
0 | 307 goto surfloop ; Jump to Surfaceloop! |
308 | |
309 | |
310 display_new_cf_installed: | |
681 | 311 call DISP_new_cf_warning ; Display new CF warning screen |
0 | 312 movlw d'20' ; timeout for warning screen |
313 bra startup_screen3a ; Will RETURN after timeout or button press | |
197 | 314 |
315 ;============================================================================= | |
316 ; Setup all flags and parameters for divemode and simulator computations. | |
317 ; | |
318 restart_set_modes_and_flags: ; "Call"ed from divemode, as well! | |
0 | 319 bcf gauge_mode |
320 bcf FLAG_const_ppO2_mode | |
321 bcf FLAG_apnoe_mode | |
45 | 322 |
323 ; Pre-load modes for OC, GF 90/90 and no Aponoe or Gauge. | |
197 | 324 bcf no_deco_customviews ; Clear no-deco-mode-flag |
45 | 325 movlw d'0' |
469 | 326 movff WREG,char_I_deco_model ; ZH-L16 |
45 | 327 ; Load GF values into RAM |
328 movlw d'90' | |
197 | 329 movff WREG,char_I_GF_Low_percentage |
330 movff WREG,char_I_GF_High_percentage ; Set to 90/90... | |
0 | 331 clrf EEADRH |
197 | 332 read_int_eeprom d'34' ; Read deco data |
333 movlw d'1' ; Gauge mode | |
0 | 334 cpfseq EEDATA |
197 | 335 bra restart_3_test_ppO2_mode ; check for ppO2 mode |
336 bsf gauge_mode ; Set flag for gauge mode | |
337 bsf no_deco_customviews ; Set no-deco-mode-flag | |
338 return ; start in Surfacemode | |
0 | 339 restart_3_test_ppO2_mode: |
197 | 340 movlw d'2' ; const ppO2 mode |
0 | 341 cpfseq EEDATA |
197 | 342 bra restart_3_test_apnoe_mode; check for apnoe mode |
343 bsf FLAG_const_ppO2_mode ; Set flag for ppO2 mode | |
344 return ; start in Surfacemode | |
0 | 345 restart_3_test_apnoe_mode: |
197 | 346 movlw d'3' ; Apnoe mode |
0 | 347 cpfseq EEDATA |
197 | 348 bra restart_4_test_gf_mode ; check for GF OC mode |
349 bsf FLAG_apnoe_mode ; Set flag for Apnoe Mode | |
350 bsf no_deco_customviews ; Set no-deco-mode-flag | |
351 return ; start in Surfacemode | |
0 | 352 restart_4_test_gf_mode: |
197 | 353 movlw d'4' ; GF OC mode |
0 | 354 cpfseq EEDATA |
197 | 355 bra restart_5_test_gfO2_mode ; check for GF CC mode |
0 | 356 movlw d'1' |
197 | 357 movff WREG,char_I_deco_model ; Set Flagbyte for GF method |
45 | 358 ; Load GF values into RAM |
667 | 359 rcall restart_load_gf |
197 | 360 return ; start in Surfacemode |
0 | 361 restart_5_test_gfO2_mode: |
197 | 362 movlw d'5' ; GF CC mode |
0 | 363 cpfseq EEDATA |
592
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
364 bra restart_5_test_pSCR_mode ; check for pSCR-GF |
197 | 365 bsf FLAG_const_ppO2_mode ; Set flag for ppO2 mode |
0 | 366 movlw d'1' |
197 | 367 movff WREG,char_I_deco_model ; Set Flagbyte for GF method |
137 | 368 ; Load GF values into RAM |
667 | 369 rcall restart_load_gf |
197 | 370 return ; start in Surfacemode |
592
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
371 restart_5_test_pSCR_mode: |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
372 movlw d'6' ; pSCR-GF |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
373 cpfseq EEDATA |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
374 return ; start in Surfacemode |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
375 bcf FLAG_const_ppO2_mode ; Clear flag for ppO2 mode |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
376 movlw d'1' |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
377 movff WREG,char_I_deco_model ; Set Flagbyte for GF method |
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
378 ; Load GF values into RAM |
667 | 379 rcall restart_load_gf |
380 return ; start in Surfacemode | |
381 | |
382 restart_load_gf: | |
668 | 383 btfsc use_aGF |
667 | 384 bra restart_load_gf2 ; Use aGf |
385 ; Use normal GF | |
386 ; Load GF values into RAM | |
592
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
387 GETCUSTOM8 d'32' ; GF low |
667 | 388 movff EEDATA,char_I_GF_Low_percentage |
592
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
389 GETCUSTOM8 d'33' ; GF high |
667 | 390 movff EEDATA,char_I_GF_High_percentage |
391 return ; Done. | |
392 restart_load_gf2: ; Use aGf | |
393 ; Load GF values into RAM | |
394 GETCUSTOM8 d'67' ; aGF low | |
395 movff EEDATA,char_I_GF_Low_percentage | |
396 GETCUSTOM8 d'68' ; aGF high | |
397 movff EEDATA,char_I_GF_High_percentage | |
398 return ; Done. | |
399 | |
592
cda5b45b953f
NEW: Deco mode "pSCR-GF": Computes deco and CNS based on pSCR parameters (CF62/63)
heinrichsweikamp
parents:
578
diff
changeset
|
400 |
197 | 401 ;============================================================================= |
0 | 402 |
403 startup_screen1: | |
681 | 404 call DISP_ClearScreen |
405 call DISP_startupscreen1 ; show startup sreen | |
0 | 406 startup_screen1_2: |
407 movlw d'10' ; timeout for startup screen | |
408 movwf temp1 | |
409 WAITMS d'200' | |
576 | 410 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! |
0 | 411 screen1_loop: |
337 | 412 btfsc uart_dump_screen ; Asked to dump screen contains ? |
413 call dump_screen ; Yes! | |
414 | |
0 | 415 btfsc onesecupdate ; do every second tasks? |
416 call set_dive_modes ; tests if depth>threshold | |
417 btfsc onesecupdate ; do every second tasks? | |
418 decf temp1,F | |
419 bcf onesecupdate ; every second tasks done | |
420 | |
421 tstfsz temp1 ; timout occured? | |
422 bra screen1_loop2 ; no | |
423 return | |
424 | |
425 screen1_loop2: | |
426 btfsc divemode ; Divemode active? | |
427 return | |
428 btfsc switch_left ; Ack? | |
429 return | |
430 btfsc switch_right ; Ack? | |
431 return | |
432 bra screen1_loop ; loop screen | |
433 | |
434 startup_screen2: | |
681 | 435 call DISP_ClearScreen ; Page 1 |
436 call DISP_startupscreen2 ; show startup sreen | |
0 | 437 bra startup_screen1_2 |
438 | |
439 startup_screen3a:; WARNING: Also used for decodescriptions and CF Warning screen! | |
440 movwf temp1 | |
441 WAITMS d'200' | |
576 | 442 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! |
0 | 443 screen3_loop: |
337 | 444 btfsc uart_dump_screen ; Asked to dump screen contains ? |
445 call dump_screen ; Yes! | |
446 | |
0 | 447 btfsc onesecupdate ; do every second tasks? |
448 call set_dive_modes ; tests if depth>threshold | |
449 | |
450 btfsc onesecupdate ; do every second tasks? | |
451 decf temp1,F | |
452 bcf onesecupdate ; every second tasks done | |
453 | |
454 tstfsz temp1 ; timout occured? | |
455 bra screen3_loop2 ; no | |
456 return | |
457 screen3_loop2: | |
458 btfsc switch_left ; Ack? | |
459 return | |
460 btfsc switch_right ; Ack? | |
461 return | |
462 bra screen3_loop ; loop screen | |
463 | |
337 | 464 ;============================================================================= |
465 | |
306 | 466 first_start: |
467 movlw max_custom_number ; Defined in definitions.asm | |
468 movwf EEDATA | |
469 write_int_eeprom d'92' ; Store number of CF used in this firmware | |
470 bra start3 ; continue with normal start | |
471 | |
0 | 472 init: |
466 | 473 movlw OSCCON_VALUE |
0 | 474 movwf OSCCON |
475 | |
476 movlw b'00010001' ; I/O Ports | |
477 movwf TRISA | |
478 clrf PORTA | |
479 movlw b'00000011' | |
480 movwf TRISB | |
481 clrf PORTB | |
482 movlw b'11011101' ; UART | |
483 movwf TRISC | |
484 clrf PORTC | |
485 movlw b'00000000' | |
486 movwf TRISE | |
487 clrf PORTE | |
488 movlw b'00000000' | |
489 movwf TRISD | |
490 clrf PORTD | |
491 | |
492 movlw b'01000000' ; Bit6: PPL enable | |
493 movwf OSCTUNE | |
494 | |
466 | 495 movlw T0CON_VALUE ; Timer0 |
0 | 496 movwf T0CON |
497 | |
498 movlw b'00000111' ; Timer1 | |
499 movwf T1CON | |
500 | |
501 movlw b'11010000' ; Interrups | |
502 movwf INTCON | |
503 movlw b'00000101' | |
504 movwf INTCON2 | |
505 movlw b'00001000' | |
506 movwf INTCON3 | |
507 movlw b'00100001' | |
508 movwf PIE1 | |
509 movlw b'00000000' | |
510 movwf PIE2 | |
511 clrf RCON | |
512 | |
513 movlw b'00000000' ; A/D Converter | |
514 movwf ADCON0 | |
515 movlw b'00001110' | |
516 movwf ADCON1 | |
517 movlw b'10001010' ; Right justified | |
518 movwf ADCON2 | |
519 | |
520 clrf SSPCON1 ; Set I²C Mode | |
537 | 521 movlw SSPSTAT_VALUE |
0 | 522 movwf SSPSTAT |
523 movlw b'00101000' | |
524 movwf SSPCON1 | |
525 movlw b'00000000' | |
526 movwf SSPCON2 | |
466 | 527 movlw SSPADD_VALUE ; I²C Speed |
0 | 528 movwf SSPADD |
529 | |
530 clrf CCP1CON ; PWM Module off | |
531 clrf ECCP1CON ; PWM Module off | |
532 | |
533 movlw b'00000111' ; Comperator Module off | |
534 movwf CMCON | |
535 | |
536 movlw b'00100000' | |
537 movwf CANCON ; ECAN Module OFF | |
538 | |
539 movlw b'00100100' ; UART | |
540 movwf TXSTA | |
541 movlw b'10010000' | |
542 movwf RCSTA | |
543 movlw b'00001000' | |
544 movwf BAUDCON | |
545 clrf SPBRGH | |
466 | 546 movlw SPBRG_VALUE |
0 | 547 movwf SPBRG |
548 clrf RCREG | |
549 clrf PIR1 | |
550 return |