annotate src/start.asm @ 610:2ce43f09586e

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