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