Mercurial > public > hwos_code
annotate src/start.asm @ 605:5ce603c29750
gas color coding fixed
author | heinrichsweikamp |
---|---|
date | Sun, 25 Nov 2018 13:21:52 +0100 |
parents | ca4556fb60b9 |
children | d866684249bd |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
604 | 3 ; File start.asm REFACTORED VERSION V2.99e |
0 | 4 ; |
5 ; Startup subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-06 : [mH] moving from OSTC code | |
11 | |
604 | 12 #include "hwos.inc" ; mandatory header |
582 | 13 #include "ms5541.inc" |
14 #include "isr.inc" | |
604 | 15 #include "shared_definitions.h" ; mailbox from/to p2_deco.c |
582 | 16 #include "eeprom_rs232.inc" |
17 #include "math.inc" | |
18 #include "tft.inc" | |
19 #include "surfmode.inc" | |
20 #include "wait.inc" | |
21 #include "rtc.inc" | |
22 #include "external_flash.inc" | |
23 #include "convert.inc" | |
24 #include "strings.inc" | |
25 #include "tft_outputs.inc" | |
26 #include "adc_lightsensor.inc" | |
27 #include "i2c.inc" | |
0 | 28 |
582 | 29 extern init_ostc |
30 extern option_restore_all | |
31 extern restore_decodata_from_eeprom | |
32 extern oPressureAdjust | |
33 extern option_reset | |
34 extern option_save | |
35 extern option_save_all | |
36 extern option_check_all | |
37 extern do_new_battery_select | |
38 extern use_old_batteries | |
39 extern use_old_prior_209 | |
604 | 40 extern get_first_gas_to_WREG |
41 extern get_first_dil_to_WREG | |
42 extern option_cleanup_oCCRMode_pSCR | |
43 extern option_cleanup_oCCRMode_CCR | |
44 | |
45 IFDEF _rx_functions | |
46 extern option_cleanup_oTrMode_CCR | |
47 extern option_cleanup_oTrMode_no_CCR | |
48 ENDIF | |
49 | |
0 | 50 |
51 ;============================================================================= | |
604 | 52 ; Reset Vector: entry point on device wake-up and hard reset |
0 | 53 ; |
582 | 54 reset_v code 0x00000 |
0 | 55 |
582 | 56 ; goto start |
604 | 57 goto 0x1FF00 ; bootloader |
582 | 58 |
604 | 59 ORG 0x00004 ; needed for second-level bootloader |
0 | 60 goto start |
582 | 61 |
0 | 62 ;============================================================================= |
582 | 63 |
604 | 64 boot CODE |
65 | |
66 ;============================================================================= | |
0 | 67 |
582 | 68 global start |
0 | 69 start: |
604 | 70 lfsr FSR0,0x000 ; clear ram-banks 0-14 |
0 | 71 clear_rambank: |
72 clrf POSTINC0 | |
73 movlw 0x0F | |
604 | 74 cpfseq FSR0H ; bank 14 done? |
75 bra clear_rambank ; NO - loop | |
0 | 76 |
604 | 77 call init_ostc ; initialize hardware (ports, timers, etc.) |
0 | 78 |
604 | 79 ; get button type from Bootloader-Info |
582 | 80 movlw .16 |
604 | 81 movff WREG,analog_counter ; initialize averaging |
582 | 82 bsf analog_switches |
83 movlw 0x7C | |
84 movwf TBLPTRL | |
85 movlw 0xF7 | |
86 movwf TBLPTRH | |
87 movlw 0x01 | |
88 movwf TBLPTRU | |
604 | 89 TBLRD*+ ; reads 0x07 for analog buttons |
449 | 90 movlw 0x07 |
91 cpfseq TABLAT | |
582 | 92 bcf analog_switches |
475 | 93 |
94 ; read button polarity | |
582 | 95 movlw LOW .897 |
475 | 96 movwf EEADR |
582 | 97 movlw HIGH .897 |
475 | 98 movwf EEADRH |
604 | 99 call read_eeprom ; EEDATA into EEPROM @ EEADR |
100 clrf EEADRH ; reset EEADRH | |
101 movff EEDATA,button_polarity ; 0xFF (both normal), 0x00 (both inverted), 0x01 (left inverted only), 0x02 (right inverted only) | |
475 | 102 |
604 | 103 ; air pressure compensation after reset |
582 | 104 call get_calibration_data ; get calibration data from pressure sensor |
105 banksel common ; get_calibration_data uses isr_backup | |
0 | 106 |
582 | 107 call TFT_DisplayOff ; turn off display |
108 bsf LEDr ; turn on red LED | |
109 bcf pressure_refresh | |
604 | 110 ; first pass will not have valid temperature |
111 btfss pressure_refresh ; air pressure compensation | |
0 | 112 bra $-2 |
604 | 113 ; second pass |
0 | 114 bcf pressure_refresh |
604 | 115 btfss pressure_refresh ; air pressure compensation |
0 | 116 bra $-2 |
582 | 117 bcf LEDr |
118 | |
0 | 119 clrf rel_pressure+0 |
120 clrf rel_pressure+1 | |
121 clrf surface_interval+0 | |
122 clrf surface_interval+1 | |
123 | |
582 | 124 SAFE_2BYTE_COPY amb_pressure, last_surfpressure |
0 | 125 |
582 | 126 movlw LOW max_surfpressure |
127 movff WREG,sub_a+0 ; max. "allowed" air pressure in mbar | |
128 movlw HIGH max_surfpressure | |
129 movff WREG,sub_a+1 ; max. "allowed" air pressure in mbar | |
0 | 130 movff last_surfpressure+0,sub_b+0 |
131 movff last_surfpressure+1,sub_b+1 | |
582 | 132 call subU16 ; sub_c = sub_a - sub_b |
604 | 133 btfss neg_flag ; is 1080 mbar < amb_pressure ? |
134 bra start_copy_pressure ; NO - current air pressure is lower then "allowed" air pressure, ok | |
0 | 135 |
604 | 136 ; not ok - overwrite with max. "allowed" air pressure |
582 | 137 movlw LOW max_surfpressure |
138 movff WREG,last_surfpressure+0 ; max. "allowed" air pressure in mbar | |
139 movlw HIGH max_surfpressure | |
140 movff WREG,last_surfpressure+1 ; max. "allowed" air pressure in mbar | |
0 | 141 |
142 start_copy_pressure: | |
143 movff last_surfpressure+0,last_surfpressure_15min+0 | |
144 movff last_surfpressure+1,last_surfpressure_15min+1 | |
145 movff last_surfpressure+0,last_surfpressure_30min+0 | |
582 | 146 movff last_surfpressure+1,last_surfpressure_30min+1 ; resets all air pressure registers |
560 | 147 |
148 ; initialize GF high (needed by deco engine for color-coding the GF value) | |
149 movff opt_GF_high,char_I_GF_High_percentage | |
150 | |
582 | 151 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; breathing at surface |
152 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; surface pressure | |
153 movff int_I_pres_respiration+1,int_I_pres_surface+1 | |
0 | 154 |
604 | 155 call deco_clear_tissue ; set all tissues to Pamb * N2_ratio (code located in p2_deco.c) |
582 | 156 banksel common ; back to bank 1, needed after every return from C code |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
157 |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
158 call rtc_init ; init clock |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
159 |
582 | 160 movlw HIGH .512 ; =2 |
161 movwf EEADRH | |
162 read_int_eeprom .0 | |
163 clrf EEADRH | |
164 movlw 0xAA | |
165 cpfseq EEDATA ; =0xAA | |
604 | 166 bra no_deco_restore ; NO |
167 call restore_decodata_from_eeprom ; reload deco data and date/time from eeprom | |
582 | 168 no_deco_restore: |
169 call deco_calc_dive_interval_1min ; calculate deco in surface mode | |
170 call deco_calc_desaturation_time ; calculate desaturation and no-fly time | |
171 banksel common | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
172 |
0 | 173 bcf menubit ; clear menu flag |
215 | 174 |
604 | 175 ; check for power-on reset here |
582 | 176 |
177 ; ***************************************************************************** | |
215 | 178 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return" |
582 | 179 ; ***************************************************************************** |
0 | 180 |
582 | 181 ; Try to migrate the old battery status from firmware 2.09 or earlier.. |
604 | 182 btfsc RCON,POR ; was this a power-on reset? |
183 call use_old_prior_209 ; NO | |
464
0491a84fd0b8
CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents:
463
diff
changeset
|
184 |
582 | 185 bcf use_old_batt_flag |
604 | 186 btfsc RCON,POR ; was this a power-on reset? |
187 bsf use_old_batt_flag ; NO | |
582 | 188 |
604 | 189 call lt2942_get_status ; check for gauge IC |
582 | 190 btfss battery_gauge_available ; cR or 2 hardware? |
604 | 191 bra check_firmware_new ; NO - skip next |
192 movlw .30 ; YES - reset button sensitivity | |
193 movff WREG,opt_cR_button_right | |
194 movff WREG,opt_cR_button_left ; reset on power-on reset | |
195 call piezo_config ; configure buttons | |
196 call piezo_config ; configure buttons (2 times) | |
197 | |
198 check_firmware_new: | |
199 call TFT_boot ; initialize TFT (includes clear screen) | |
200 clrf CCPR1L ; backlight off | |
201 | |
202 WIN_TOP .40 | |
203 WIN_LEFT .10 | |
204 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block ; show heinrichsweikamp logo | |
215 | 205 |
604 | 206 call TFT_standard_color |
207 | |
208 WIN_SMALL .20,.100 | |
209 STRCPY_PRINT "Update successful!" ; hard coded since language switch does not work here | |
0 | 210 |
604 | 211 WIN_SMALL .20,.140 |
212 STRCPY "New Firmware: " | |
213 call TFT_cat_firmware ; show firmware version x.y and color-code if outdated | |
214 STRCAT_PRINT "" ; finalize output | |
215 bcf win_invert ; reset inverted output if firmware is outdated | |
216 call TFT_standard_color ; reset color if firmware is outdated | |
217 | |
218 WIN_SMALL .60,.180 | |
219 call TFT_cat_beta_release ; if it is a beta version, show "BETA" + issue, else "Release" | |
220 STRCAT_PRINT "" ; finalize output | |
221 call TFT_standard_color ; reset color | |
222 | |
223 call TFT_Display_FadeIn ; display resulting surface screen | |
224 | |
225 ; check if a new firmware was loaded, if yes reset Custom Function oPressureAdjust | |
0 | 226 movlw d'1' |
582 | 227 movwf EEADR ; =1 |
228 movwf EEADRH ; =1 | |
229 call read_eeprom ; read current version x | |
230 movff EEDATA,lo | |
231 incf EEADR,F ; set to 0x102 | |
232 call read_eeprom ; read current version y | |
233 movff EEDATA,hi | |
604 | 234 clrf EEADRH ; reset EEADRH |
0 | 235 |
443 | 236 movlw softwareversion_x |
604 | 237 cpfseq lo ; compare version x |
238 bra check_firmware_new4 ; is not equal -> reset CF and store new version in EEPROM | |
0 | 239 |
240 movlw softwareversion_y | |
604 | 241 cpfseq hi ; compare version y |
242 bra check_firmware_new4 ; is not equal -> reset CF and store new version in EEPROM | |
243 bra check_firmware_new5 ; x and y are equal -> do not reset CF | |
582 | 244 |
604 | 245 check_firmware_new4: |
582 | 246 ; place "after-update reset" here... |
247 lfsr FSR0,oPressureAdjust | |
604 | 248 call option_reset ; reset oPressureAdjust to factory default |
582 | 249 lfsr FSR0,oPressureAdjust |
604 | 250 call option_save ; save new value of oPressureAdjust in EEPROM |
582 | 251 |
604 | 252 check_firmware_new5: |
582 | 253 rcall backup_flash_page ; backup the first 128 bytes from flash to EEPROM |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
52
diff
changeset
|
254 |
582 | 255 movlw d'1' ; store current version in EEPROM |
256 movwf EEADR ; =1 | |
257 movwf EEADRH ; =1 | |
0 | 258 movlw softwareversion_x |
582 | 259 movwf EEDATA |
604 | 260 call write_eeprom ; write version, major number |
582 | 261 incf EEADR,F ; set to 0x102 |
0 | 262 movlw softwareversion_y |
582 | 263 movwf EEDATA |
604 | 264 call write_eeprom ; write version, minor number |
265 clrf EEADRH ; reset EEADRH | |
0 | 266 |
604 | 267 ; wait 10 seconds |
268 movlw .10 ; load loop counter | |
269 check_firmware_new6: | |
270 call wait_1s ; wait (about) 1 second | |
271 decfsz WREG,W ; YES - decrement loop counter, did it became zero? | |
272 bra check_firmware_new6 ; NO - loop | |
273 ;bra restart ; YES - proceed with restart | |
274 | |
0 | 275 |
582 | 276 global restart |
0 | 277 restart: |
604 | 278 clrf STKPTR ; never return from here |
582 | 279 clrf CCP1CON ; stop PWM |
604 | 280 bcf PORTC,2 ; pull PWM out to GND |
276
e4cb495aed3d
Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents:
275
diff
changeset
|
281 |
604 | 282 btfsc menubit ; return from Menu/COMM mode or timeout? |
283 call option_save_all ; YES - save all settings into EEPROM | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
16
diff
changeset
|
284 |
604 | 285 call option_restore_all ; restore everything from EEPROM into RAM |
286 call option_check_all ; check all options (and reset if not within their min/max boundaries) | |
287 call option_save_all ; save all settings into EEPROM after they have been checked | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
21
diff
changeset
|
288 |
582 | 289 clrf flag1 ; clear all flags |
290 clrf flag2 | |
291 clrf flag3 | |
292 clrf flag4 | |
293 clrf flag5 | |
294 clrf flag6 | |
295 clrf flag7 | |
296 clrf flag8 | |
297 clrf flag9 | |
298 clrf flag10 | |
604 | 299 ; do not clear flag11 (sensor calibration and charger status) |
582 | 300 clrf flag12 |
604 | 301 ; do not clear flag13 (important hardware flags) |
582 | 302 clrf flag14 |
604 | 303 clrf flag15 |
304 clrf flag16 | |
305 clrf flag17 | |
306 | |
307 clrf cvt_flags | |
308 | |
309 clrf tft_update_flags+0 | |
310 clrf tft_update_flags+1 | |
311 clrf tft_update_flags+2 | |
312 | |
313 clrf hardware_flag1 ; hardware descriptor 1 | |
314 ; hardware_flag2 ; hardware descriptor 2 - do not clear here! | |
23
e402813343b6
new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents:
21
diff
changeset
|
315 |
582 | 316 bsf tft_is_dimming ; TFT is dimming up (soon), ignore ambient sensor! |
236 | 317 |
604 | 318 ; configure hardware descriptor 1 |
319 bcf tft_power ; inverted, here needed for I2C_probe_OSTC_rx, to wake-up RX circuity | |
320 bsf ambient_sensor ; set flag | |
321 bsf optical_input ; set flag | |
582 | 322 |
604 | 323 call lt2942_get_status ; check for gauge IC |
582 | 324 btfss battery_gauge_available ; cR/2 hardware? |
604 | 325 bra restart2 ; NO |
326 call lt2942_init ; YES - initialize battery gauge IC | |
327 bcf optical_input ; clear flag | |
236 | 328 |
582 | 329 banksel 0xF16 |
604 | 330 bcf ANCON0,7 ; AN7 digital input |
331 banksel common | |
332 bcf lightsen_power ; power-down ambient light sensor | |
333 bcf ambient_sensor ; clear flag | |
582 | 334 nop |
604 | 335 btfss PORTF,2 ; light sensor available? |
336 bsf ambient_sensor ; YES | |
582 | 337 banksel 0xF16 |
604 | 338 bsf ANCON0,7 ; AN7 analog again |
582 | 339 banksel common |
604 | 340 bsf lightsen_power ; power-up ambient light sensor again |
582 | 341 |
243 | 342 restart2: |
582 | 343 btfsc vusb_in |
344 bra restart3 ; USB (and powered on) | |
604 | 345 bcf PORTE,0 ; start comms |
582 | 346 WAITMS d'1' |
347 btfss vusb_in | |
348 bra restart3 ; USB (and powered off) | |
604 | 349 bsf ble_available ; BLE available |
582 | 350 |
351 restart3: | |
604 | 352 bsf PORTE,0 ; stop comms |
353 btfsc ble_available ; BLE available? | |
354 bra restart4 ; YES - can't be a cR | |
355 btfss battery_gauge_available ; rechargeable? | |
356 bra restart4 ; NO - can't be a cR | |
357 bsf analog_o2_input ; set flag for analog | |
582 | 358 |
604 | 359 restart4: |
360 IFDEF _rx_functions | |
361 WAITMS d'200' | |
362 call I2C_probe_OSTC_rx ; set ostc_rx_present flag if this is an OSTC TR model | |
363 | |
364 ; The hardware descriptor is now: | |
582 | 365 ; 0x11: 2 with BLE |
604 | 366 ; 0x13: +/2 with BLE & ambient |
582 | 367 ; 0x05: cR |
368 ; 0x0A: 3 | |
369 ; 0x1A: 3 with BLE | |
604 | 370 ; 0x33: 2 TR |
582 | 371 |
604 | 372 btfss ostc_rx_present ; OSTC TR detected? |
373 bra restart5 ; NO | |
374 movff opt_TR_mode,WREG ; YES - get user-selected TR mode | |
375 tstfsz WREG ; TR functions switched on? | |
376 bsf FLAG_tr_enabled ; YES - switch on displays and calculation functions | |
377 ENDIF | |
378 | |
379 ; configure hardware descriptor 2 | |
380 ; flag screen_type will be configured on each call of TFT_boot | |
381 ; flags compass_type & compass_type2 will be configured on each call of I2C_init_compass | |
382 ; flag analog_switches will be configured directly after hard start (in start:) | |
383 | |
384 restart5: | |
385 ; Select high altitude (fly) mode? | |
0 | 386 movff last_surfpressure_30min+0,sub_b+0 |
387 movff last_surfpressure_30min+1,sub_b+1 | |
582 | 388 movlw HIGH high_altitude_threshold |
0 | 389 movwf sub_a+1 |
604 | 390 movlw LOW high_altitude_threshold ; hard-wired 880 hPa |
0 | 391 movwf sub_a+0 |
582 | 392 call subU16 ; sub_c = sub_a - sub_b |
604 | 393 btfss neg_flag ; result negative (ambient > 880 hPa)? |
394 bsf high_altitude_mode ; NO - set flag | |
0 | 395 |
582 | 396 btfss analog_o2_input |
397 bsf TRISB,3 | |
398 btfss battery_gauge_available | |
399 bsf TRISG,0 | |
400 call ext_flash_disable_protection ; disable write protection for external flash | |
464
0491a84fd0b8
CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents:
463
diff
changeset
|
401 |
604 | 402 bsf flip_screen ; select screen flip 180° |
403 TSTOSS opt_flip_screen ; shall actually flip? (=1: flip the screen) | |
404 bcf flip_screen ; NO - revert to normal orientation | |
582 | 405 |
406 btfsc use_old_batt_flag ; =1: load old battery information after power-on reset | |
604 | 407 goto use_old_batteries ; returns to surface loop |
582 | 408 |
409 btfsc RCON,POR ; was this a power-on reset? | |
604 | 410 goto surfloop ; YES - jump to surface loop |
582 | 411 bsf RCON,POR ; set bit for next detection |
412 ; Things to do after a power-on reset | |
604 | 413 goto do_new_battery_select ; returns to surface loop |
0 | 414 |
415 ;============================================================================= | |
416 ; Setup all flags and parameters for divemode and simulator computations. | |
417 ; | |
418 global restart_set_modes_and_flags | |
604 | 419 restart_set_modes_and_flags: ; "Call"ed from dive mode as well |
420 call option_restore_all ; restore everything from EEPROM | |
24 | 421 |
582 | 422 ; Setup sampling rate |
423 movlw .2 | |
424 movwf samplingrate | |
425 TSTOSS opt_sampling_rate ; =1: 10s, =0: 2s | |
426 bra restart_set_modes_and_flags1 | |
427 movlw .10 | |
428 movwf samplingrate | |
429 | |
24 | 430 restart_set_modes_and_flags1: |
604 | 431 bcf FLAG_gauge_mode |
582 | 432 bcf FLAG_apnoe_mode |
604 | 433 bcf FLAG_oc_mode |
434 bcf FLAG_ccr_mode | |
582 | 435 bcf FLAG_pscr_mode |
604 | 436 bcf FLAG_bailout_mode |
582 | 437 call disable_ir_s8 ; IR off |
0 | 438 |
604 | 439 IFDEF _cave_mode |
440 bsf FLAG_cave_mode ; enable cave mode by default | |
441 movff opt_calc_asc_gasvolume,WREG ; get gas needs calculation mode (0=off, 1=on, 2=cave mode) | |
442 xorlw .2 ; coding for cave mode | |
443 tstfsz WREG ; cave mode enabled? | |
444 bcf FLAG_cave_mode ; NO - disable cave mode again | |
445 bcf FLAG_cave_mode_shutdown ; clear flag for cave mode shutdown | |
446 bcf FLAG_dive_turned ; clear flag for dive turned | |
447 bcf gas_needs_mode_last ; set last gas calculation results as direct ascent needs | |
448 ENDIF | |
449 | |
450 ; Initialize active_gas and active_dil for surface mode pressure display | |
451 call get_first_gas_to_WREG | |
452 movwf active_gas | |
453 call get_first_dil_to_WREG | |
454 movwf active_dil | |
455 | |
582 | 456 ; Setup char_I_saturation_multiplier and char_I_desaturation_multiplier |
457 movff opt_sat_multiplier_gf,char_I_saturation_multiplier | |
458 movff opt_desat_multiplier_gf,char_I_desaturation_multiplier | |
459 movff char_I_deco_model,lo ; 0 = ZH-L16, 1 = ZH-L16-GF | |
460 tstfsz lo | |
461 bra restart_set_modes_and_flags1b | |
462 movff opt_sat_multiplier_non_gf,char_I_saturation_multiplier | |
463 movff opt_desat_multiplier_non_gf,char_I_desaturation_multiplier | |
464 | |
465 restart_set_modes_and_flags1b: | |
466 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | |
467 tstfsz lo | |
468 bra restart_set_modes_and_flags2 | |
469 | |
470 ; OC Mode | |
604 | 471 bsf FLAG_oc_mode ; =1: OC mode active |
472 IFDEF _rx_functions | |
473 call option_cleanup_oTrMode_no_CCR ; revert TR mode from 'CCR Dil+O2' to 'on' | |
474 ENDIF | |
582 | 475 return |
0 | 476 |
477 restart_set_modes_and_flags2: | |
582 | 478 decfsz lo,F |
479 bra restart_set_modes_and_flags3 | |
480 | |
604 | 481 ; CCR Mode |
582 | 482 bsf FLAG_ccr_mode ; =1: CCR mode (Fixed SP, Auto SP or Sensor) active |
604 | 483 call option_cleanup_oCCRMode_CCR ; revert CCR mode 'Sensor' to 'fixed SP' if no sensor interface available |
484 IFDEF _rx_functions | |
485 call option_cleanup_oTrMode_CCR ; revert TR mode from 'ind.double' to 'on' | |
486 ENDIF | |
487 call enable_ir_s8 ; enable IR/S8 port | |
582 | 488 return |
0 | 489 |
490 restart_set_modes_and_flags3: | |
582 | 491 decfsz lo,F |
492 bra restart_set_modes_and_flags4 | |
493 | |
494 ; Gauge Mode | |
604 | 495 bsf FLAG_gauge_mode ; =1: in gauge mode |
496 IFDEF _rx_functions | |
497 call option_cleanup_oTrMode_no_CCR ; revert TR mode from 'CCR Dil+O2' to 'on' | |
498 ENDIF | |
582 | 499 return |
0 | 500 |
501 restart_set_modes_and_flags4: | |
582 | 502 decfsz lo,F |
503 bra restart_set_modes_and_flags5 | |
604 | 504 |
582 | 505 ; Apnea Mode |
604 | 506 bsf FLAG_apnoe_mode ; =1: in Apnea mode |
507 IFDEF _rx_functions | |
508 call option_cleanup_oTrMode_no_CCR ; revert TR mode from 'CCR Dil+O2' to 'on' | |
509 ENDIF | |
510 return ; start in surface mode | |
0 | 511 |
480
ad8acade5567
NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents:
475
diff
changeset
|
512 restart_set_modes_and_flags5: |
604 | 513 ; pSCR Mode |
514 bsf FLAG_pscr_mode ; set pSCR mode flag | |
515 call option_cleanup_oCCRMode_pSCR ; in pSCR mode, revert AutoSP (2) to calculated SP (0), additionally revert Sensor to fixed SP if no sensor interface available | |
516 IFDEF _rx_functions | |
517 call option_cleanup_oTrMode_no_CCR ; revert TR mode from 'CCR Dil+O2' to 'on' | |
518 ENDIF | |
519 call enable_ir_s8 ; enable IR/S8 port | |
520 return ; start in surface mode | |
560 | 521 |
582 | 522 |
604 | 523 ; backup the first 128 bytes from flash to EEPROM |
582 | 524 backup_flash_page: |
525 ; Start address in internal flash | |
526 movlw 0x00 | |
527 movwf TBLPTRL | |
528 movwf TBLPTRH | |
529 movwf TBLPTRU | |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
530 |
582 | 531 movlw .128 |
604 | 532 movwf lo ; byte counter |
582 | 533 clrf EEADR |
534 movlw .3 | |
604 | 535 movwf EEADRH ; setup backup address |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
536 |
604 | 537 TBLRD*- ; dummy read to be in 128 byte block |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
538 backup_flash_loop: |
604 | 539 tblrd+* ; table read with pre-increment |
582 | 540 movff TABLAT,EEDATA ; put 1 byte |
541 call write_eeprom ; save it in EEPROM | |
542 incf EEADR,F | |
604 | 543 decfsz lo,F ; 128 byte done? |
544 bra backup_flash_loop ; NO - loop | |
545 clrf EEADRH ; reset EEADRH | |
546 return ; done | |
410
d3087a8ed7e1
BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents:
375
diff
changeset
|
547 |
0 | 548 END |