annotate src/start.asm @ 504:f522210b3743

minor
author heinrichsweikamp
date Sat, 24 Jun 2017 19:26:06 +0200
parents ad8acade5567
children 7e6df19264b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File start.asm
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
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 267
diff changeset
12 #include "hwos.inc" ; Mandatory header
0
heinrichsweikamp
parents:
diff changeset
13 #include "ms5541.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "isr.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
16 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "rtc.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
23 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
24 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
25 #include "tft_outputs.inc"
113
heinrichsweikamp
parents: 93
diff changeset
26 #include "adc_lightsensor.inc"
heinrichsweikamp
parents: 93
diff changeset
27 #include "i2c.inc"
0
heinrichsweikamp
parents:
diff changeset
28
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 267
diff changeset
29 extern init_ostc
0
heinrichsweikamp
parents:
diff changeset
30 extern option_restore_all
heinrichsweikamp
parents:
diff changeset
31
heinrichsweikamp
parents:
diff changeset
32 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
33 ; Reset vector: What to do on device wake-up and hard reset.
heinrichsweikamp
parents:
diff changeset
34 ;
heinrichsweikamp
parents:
diff changeset
35 reset_v code 0x00000
heinrichsweikamp
parents:
diff changeset
36 ; goto start
heinrichsweikamp
parents:
diff changeset
37 goto 0x1FF00 ; Bootloader
heinrichsweikamp
parents:
diff changeset
38
heinrichsweikamp
parents:
diff changeset
39 ORG 0x00004 ; Needed for second-level bootloader
heinrichsweikamp
parents:
diff changeset
40 goto start
heinrichsweikamp
parents:
diff changeset
41 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
42 boot CODE
heinrichsweikamp
parents:
diff changeset
43 global start
heinrichsweikamp
parents:
diff changeset
44
heinrichsweikamp
parents:
diff changeset
45 start:
heinrichsweikamp
parents:
diff changeset
46 lfsr FSR0,0x000 ; Clear rambank 0-14
heinrichsweikamp
parents:
diff changeset
47 clear_rambank:
heinrichsweikamp
parents:
diff changeset
48 clrf POSTINC0
heinrichsweikamp
parents:
diff changeset
49 movlw 0x0F
heinrichsweikamp
parents:
diff changeset
50 cpfseq FSR0H ; Bank 14 done?
heinrichsweikamp
parents:
diff changeset
51 bra clear_rambank ; clear...
heinrichsweikamp
parents:
diff changeset
52
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 267
diff changeset
53 call init_ostc
0
heinrichsweikamp
parents:
diff changeset
54
449
heinrichsweikamp
parents: 446
diff changeset
55 ; Get button type from Bootloader-Info
474
2880aa1264f5 Fix new battery menu on Power-on reset
heinrichsweikamp
parents: 472
diff changeset
56 movlw .16
2880aa1264f5 Fix new battery menu on Power-on reset
heinrichsweikamp
parents: 472
diff changeset
57 movff WREG,analog_counter ; init averaging
449
heinrichsweikamp
parents: 446
diff changeset
58 bsf analog_switches
heinrichsweikamp
parents: 446
diff changeset
59 movlw 0x7C
heinrichsweikamp
parents: 446
diff changeset
60 movwf TBLPTRL
heinrichsweikamp
parents: 446
diff changeset
61 movlw 0xF7
heinrichsweikamp
parents: 446
diff changeset
62 movwf TBLPTRH
heinrichsweikamp
parents: 446
diff changeset
63 movlw 0x01
heinrichsweikamp
parents: 446
diff changeset
64 movwf TBLPTRU
heinrichsweikamp
parents: 446
diff changeset
65 TBLRD*+ ; Reads 0x07 for analog buttons
heinrichsweikamp
parents: 446
diff changeset
66 movlw 0x07
heinrichsweikamp
parents: 446
diff changeset
67 cpfseq TABLAT
heinrichsweikamp
parents: 446
diff changeset
68 bcf analog_switches
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
69
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
70 ; read button polarity
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
71 movlw LOW .897
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
72 movwf EEADR
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
73 movlw HIGH .897
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
74 movwf EEADRH
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
75 call read_eeprom ; EEDATA into EEPROM@EEADR
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
76 clrf EEADRH ; Reset EEADRH
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
77 movff EEDATA,button_polarity ; 0xFF (Both normal), 0x00 (Both inverted), 0x01 (Left inverted only), 0x02 (Right inverted only)
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
78
0
heinrichsweikamp
parents:
diff changeset
79 ; Air pressure compensation after reset
heinrichsweikamp
parents:
diff changeset
80 call get_calibration_data ; Get calibration data from pressure sensor
heinrichsweikamp
parents:
diff changeset
81 banksel common ; get_calibration_data uses isr_backup
heinrichsweikamp
parents:
diff changeset
82
463
2c58631d5229 minor cleanups
heinrichsweikamp
parents: 457
diff changeset
83 call TFT_DisplayOff ; display off
2c58631d5229 minor cleanups
heinrichsweikamp
parents: 457
diff changeset
84 bsf LEDr ; Status LED
2c58631d5229 minor cleanups
heinrichsweikamp
parents: 457
diff changeset
85 bcf pressure_refresh
0
heinrichsweikamp
parents:
diff changeset
86 ; First pass will not have valid temperature!
heinrichsweikamp
parents:
diff changeset
87 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
88 bra $-2
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
89 ; Second pass
0
heinrichsweikamp
parents:
diff changeset
90 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
91 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
92 bra $-2
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
93 bcf LEDr
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
94
0
heinrichsweikamp
parents:
diff changeset
95 clrf rel_pressure+0
heinrichsweikamp
parents:
diff changeset
96 clrf rel_pressure+1
heinrichsweikamp
parents:
diff changeset
97 clrf surface_interval+0
heinrichsweikamp
parents:
diff changeset
98 clrf surface_interval+1
heinrichsweikamp
parents:
diff changeset
99
heinrichsweikamp
parents:
diff changeset
100 SAFE_2BYTE_COPY amb_pressure, last_surfpressure
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
103 movff WREG,sub_a+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
104 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
105 movff WREG,sub_a+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
106 movff last_surfpressure+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
107 movff last_surfpressure+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
108 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
109 btfss neg_flag ; Is 1080mbar < amb_pressure ?
heinrichsweikamp
parents:
diff changeset
110 bra start_copy_pressure ; NO: current airpressure is lower then "allowed" airpressure, ok!
heinrichsweikamp
parents:
diff changeset
111
heinrichsweikamp
parents:
diff changeset
112 ; not ok! Overwrite with max. "allowed" airpressure
heinrichsweikamp
parents:
diff changeset
113 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
114 movff WREG,last_surfpressure+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
115 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
116 movff WREG,last_surfpressure+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 start_copy_pressure:
heinrichsweikamp
parents:
diff changeset
119 movff last_surfpressure+0,last_surfpressure_15min+0
heinrichsweikamp
parents:
diff changeset
120 movff last_surfpressure+1,last_surfpressure_15min+1
heinrichsweikamp
parents:
diff changeset
121 movff last_surfpressure+0,last_surfpressure_30min+0
heinrichsweikamp
parents:
diff changeset
122 movff last_surfpressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers
heinrichsweikamp
parents:
diff changeset
123
heinrichsweikamp
parents:
diff changeset
124 ; reset deco data for surface mode
heinrichsweikamp
parents:
diff changeset
125 movlw d'79'
heinrichsweikamp
parents:
diff changeset
126 movff WREG,char_I_N2_ratio ; 79% N2
heinrichsweikamp
parents:
diff changeset
127 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy for deco routine
heinrichsweikamp
parents:
diff changeset
128 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine
heinrichsweikamp
parents:
diff changeset
129 movff int_I_pres_respiration+1,int_I_pres_surface+1
heinrichsweikamp
parents:
diff changeset
130
heinrichsweikamp
parents:
diff changeset
131 extern deco_reset
heinrichsweikamp
parents:
diff changeset
132 call deco_reset
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
134 call rtc_init ; init clock
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
135
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
136 movlw HIGH .512 ; =2
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
137 movwf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
138 read_int_eeprom .0
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
139 clrf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
140 movlw 0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
141 cpfseq EEDATA ; =0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
142 bra no_deco_restore ; No
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
143
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
144 extern restore_decodata_from_eeprom
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
145 call restore_decodata_from_eeprom ; Reload deco data and date/time from eeprom
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
146
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
147 no_deco_restore:
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
148 call deco_calc_desaturation_time ; calculate desaturation time
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
149 banksel common
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
150 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
151 banksel common
0
heinrichsweikamp
parents:
diff changeset
152 bcf menubit ; clear menu flag
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
153
0
heinrichsweikamp
parents:
diff changeset
154 ; Check for Power-on reset here
464
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
155 extern use_old_prior_209
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
156 ; *****************************************************************************
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
157 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return"
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
158 ; *****************************************************************************
0
heinrichsweikamp
parents:
diff changeset
159
457
b4417044a042 recover old battery status prior 2.09
heinrichsweikamp
parents: 449
diff changeset
160 ; Try to migrate the old battery status from firmware 2.09 or earlier..
b4417044a042 recover old battery status prior 2.09
heinrichsweikamp
parents: 449
diff changeset
161 btfsc RCON,POR ; Was this a power-on reset?
472
4fdf6886004b CHANGE: Show warnings either in Customview (If active) _or_ next to warning sign
heinrichsweikamp
parents: 464
diff changeset
162 call use_old_prior_209 ; No
464
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
163
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
164 bcf use_old_batt_flag
416
4389fe9673b2 NEW: Support for new logbook memory chip (minor hardware change)
heinrichsweikamp
parents: 410
diff changeset
165 btfsc RCON,POR ; Was this a power-on reset?
464
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
166 bsf use_old_batt_flag ; No
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
167
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
168 call lt2942_get_status ; Check for gauge IC
449
heinrichsweikamp
parents: 446
diff changeset
169 btfss battery_gauge_available ; cR or 2 hardware?
416
4389fe9673b2 NEW: Support for new logbook memory chip (minor hardware change)
heinrichsweikamp
parents: 410
diff changeset
170 bra power_on_return2 ; no
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
171
375
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 359
diff changeset
172 movlw .30
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 359
diff changeset
173 movff WREG,opt_cR_button_right
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 359
diff changeset
174 movff WREG,opt_cR_button_left ; Reset on power-on reset
a9e35c1327aa 1.88 release, BUGFIX: Start with Sensor use from sleep (cR only), CHANGE: Apply button settings when button menu is closed, NEW: Reset button settings on a magnet reset (cR and OSTC 2)
heinrichsweikamp
parents: 359
diff changeset
175 call piezo_config ; Yes, configure buttons
416
4389fe9673b2 NEW: Support for new logbook memory chip (minor hardware change)
heinrichsweikamp
parents: 410
diff changeset
176 call piezo_config ; Yes, configure buttons (2 times)
0
heinrichsweikamp
parents:
diff changeset
177
416
4389fe9673b2 NEW: Support for new logbook memory chip (minor hardware change)
heinrichsweikamp
parents: 410
diff changeset
178 power_on_return2:
0
heinrichsweikamp
parents:
diff changeset
179 ; check firmware and reset Custom Functions after an update
heinrichsweikamp
parents:
diff changeset
180 movlw d'1'
281
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
181 movwf EEADR ; =1
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
182 movwf EEADRH ; =1
0
heinrichsweikamp
parents:
diff changeset
183 call read_eeprom ; read current version x
heinrichsweikamp
parents:
diff changeset
184 movff EEDATA,temp1
heinrichsweikamp
parents:
diff changeset
185 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
186 call read_eeprom ; read current version y
heinrichsweikamp
parents:
diff changeset
187 movff EEDATA,temp2
heinrichsweikamp
parents:
diff changeset
188 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
189
443
heinrichsweikamp
parents: 441
diff changeset
190 movlw softwareversion_x
heinrichsweikamp
parents: 441
diff changeset
191 cpfseq temp1 ; compare version x
0
heinrichsweikamp
parents:
diff changeset
192 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
193
heinrichsweikamp
parents:
diff changeset
194 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
195 cpfseq temp2 ; compare version y
heinrichsweikamp
parents:
diff changeset
196 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
197 bra restart ; x and y are equal -> do not reset cf
heinrichsweikamp
parents:
diff changeset
198
heinrichsweikamp
parents:
diff changeset
199 check_firmware_new:
heinrichsweikamp
parents:
diff changeset
200 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
201 clrf CCPR1L ; Backlight off
heinrichsweikamp
parents:
diff changeset
202 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
203 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
204 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
205 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
206 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
207 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
208 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
209 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
210 extern color_image
heinrichsweikamp
parents:
diff changeset
211 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
212 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
213 WIN_SMALL .10,.100
427
ceb1b7329dce add code for new compass chip
heinrichsweikamp
parents: 416
diff changeset
214 STRCPY_PRINT "Update successful!" ; Hard coded since language switch does not work here
0
heinrichsweikamp
parents:
diff changeset
215 WIN_SMALL .10,.140
427
ceb1b7329dce add code for new compass chip
heinrichsweikamp
parents: 416
diff changeset
216 STRCPY "New Firmware: "
0
heinrichsweikamp
parents:
diff changeset
217 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
218 movwf lo
heinrichsweikamp
parents:
diff changeset
219 bsf leftbind
heinrichsweikamp
parents:
diff changeset
220 output_8
heinrichsweikamp
parents:
diff changeset
221 PUTC "."
heinrichsweikamp
parents:
diff changeset
222 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
223 movwf lo
45
76dfe320e6ec 1.01 beta start
heinrichsweikamp
parents: 24
diff changeset
224 output_99x
0
heinrichsweikamp
parents:
diff changeset
225 bcf leftbind
heinrichsweikamp
parents:
diff changeset
226 STRCAT_PRINT "" ; Print second row
heinrichsweikamp
parents:
diff changeset
227 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
228
heinrichsweikamp
parents:
diff changeset
229 ; place "after-update reset" here...
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
230
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
231 extern oPressureAdjust, option_reset, option_save
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
232 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
233 call option_reset ; Reset FSR0 option to factory default.
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
234 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
235 call option_save ; Save in EEPROM
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
236
281
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
237 call fix_180_dives ; fix dives made with the 1.80
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
238
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
239 rcall backup_flash_page ; backup the first 128bytes from flash to EEPROM
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
240
0
heinrichsweikamp
parents:
diff changeset
241 movlw d'1' ; store current version in EEPROM
281
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
242 movwf EEADR ; =1
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
243 movwf EEADRH ; =1
0
heinrichsweikamp
parents:
diff changeset
244 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
245 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
246 call write_eeprom ; write version x
heinrichsweikamp
parents:
diff changeset
247 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
248 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
249 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
250 call write_eeprom ; write version y
heinrichsweikamp
parents:
diff changeset
251 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
252
heinrichsweikamp
parents:
diff changeset
253 movlw .7
heinrichsweikamp
parents:
diff changeset
254 movwf lo
heinrichsweikamp
parents:
diff changeset
255 check_firmware_new2:
heinrichsweikamp
parents:
diff changeset
256 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
257 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
258 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
259 bra $-2
heinrichsweikamp
parents:
diff changeset
260 decfsz lo,F ; Wait 10 seconds...
heinrichsweikamp
parents:
diff changeset
261 bra check_firmware_new2
heinrichsweikamp
parents:
diff changeset
262
heinrichsweikamp
parents:
diff changeset
263 global restart
heinrichsweikamp
parents:
diff changeset
264 restart:
heinrichsweikamp
parents:
diff changeset
265 clrf STKPTR ; Never return from here
276
e4cb495aed3d Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents: 275
diff changeset
266 clrf CCP1CON ; stop PWM
e4cb495aed3d Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents: 275
diff changeset
267 bcf PORTC,2 ; Pull PWM out to GND
e4cb495aed3d Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents: 275
diff changeset
268
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 16
diff changeset
269 extern option_save_all, option_check_all
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 16
diff changeset
270
0
heinrichsweikamp
parents:
diff changeset
271 btfsc menubit ; Return from Menu/COMM mode or timeout?
heinrichsweikamp
parents:
diff changeset
272 call option_save_all ; Yes, save all settings into EEPROM
heinrichsweikamp
parents:
diff changeset
273
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
274 call option_restore_all ; Restore everything from EEPROM into RAM
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
275 call option_check_all ; Check all options (and reset if not within their min/max boundaries)
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
276 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
277
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
278 clrf flag1 ; clear all flags
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
279 clrf flag2
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
280 clrf flag3
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
281 clrf flag4
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
282 clrf flag5
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
283 clrf flag6
0
heinrichsweikamp
parents:
diff changeset
284 clrf flag7
heinrichsweikamp
parents:
diff changeset
285 clrf flag8
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
286 clrf flag9
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
287 clrf flag10
267
f64afa14ef07 BUGFIX: Analog sensors were ignored in 1.76
heinrichsweikamp
parents: 255
diff changeset
288 ; Do not clear flag11 (Sensor calibration and charger status)
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
289 clrf flag12
449
heinrichsweikamp
parents: 446
diff changeset
290 ; ; Do not clear flag13 (Important hardware flags)
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
291 clrf flag14
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
292 clrf hardware_flag ; hardware descriptor flag
449
heinrichsweikamp
parents: 446
diff changeset
293 bsf tft_is_dimming ; TFT is dimming up (soon), ignore ambient sensor!
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
294
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
295 ; configure hardware_flag byte
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
296
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
297 bsf ambient_sensor ; Set flag
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
298 bsf optical_input ; Set flag
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
299
113
heinrichsweikamp
parents: 93
diff changeset
300 call lt2942_get_status ; Check for gauge IC
449
heinrichsweikamp
parents: 446
diff changeset
301 btfss battery_gauge_available ; cR/2 hardware?
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
302 bra restart2 ; No
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
303
113
heinrichsweikamp
parents: 93
diff changeset
304 call lt2942_init ; Yes, init battery gauge IC
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
305 bcf optical_input ; Clear flag
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
306
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
307 banksel 0xF16
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
308 bcf ANCON0,7 ; AN7 Digital input
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
309 banksel common
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
310 bcf lightsen_power ; Power-down ambient light sensor
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
311 bcf ambient_sensor ; Clear flag
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
312 nop
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
313 btfss PORTF,2 ; Light sensor available?
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
314 bsf ambient_sensor ; Yes.
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
315 banksel 0xF16
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
316 bsf ANCON0,7 ; AN7 Analog again
441
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
317 banksel common
360acdcda0d7 +BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents: 429
diff changeset
318 bsf lightsen_power ; Power-up ambient light sensor again
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
319
243
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
320 restart2:
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
321 btfsc vusb_in
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
322 bra restart3 ; USB (and powered on)
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
323 bcf PORTE,0 ; Start comms
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
324 WAITMS d'1'
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
325 btfss vusb_in
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
326 bra restart3 ; USB (and powered off)
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
327 bsf ble_available ; ble available
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
328 restart3:
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
329 bsf PORTE,0 ; Stop comms
248
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
330 btfsc ble_available ; ble available?
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
331 bra restart4 ; Yes, can't be a cR
449
heinrichsweikamp
parents: 446
diff changeset
332 btfss battery_gauge_available ; Rechargeable
248
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
333 bra restart4 ; No, can't be a cR
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
334 bsf analog_o2_input ; Set flag for analog
249
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
335 restart4:
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
336 ; The hardware_flag is now:
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
337 ; 3: 0x0A
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
338 ; cR: 0x05
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
339 ; 2 with BLE: 0x11
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
340 ; 3 with BLE: 0x1A
429
4b93354b7738 hardware_flag handling
heinrichsweikamp
parents: 427
diff changeset
341 ; 2 with ambient: 0x13
113
heinrichsweikamp
parents: 93
diff changeset
342
0
heinrichsweikamp
parents:
diff changeset
343 ; Select high altitude (Fly) mode?
heinrichsweikamp
parents:
diff changeset
344 movff last_surfpressure_30min+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
345 movff last_surfpressure_30min+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
346 movlw HIGH high_altitude_threshold
heinrichsweikamp
parents:
diff changeset
347 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
348 movlw LOW high_altitude_threshold ; Hard-wired 880mbar
heinrichsweikamp
parents:
diff changeset
349 movwf sub_a+0
heinrichsweikamp
parents:
diff changeset
350 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
351 btfss neg_flag ; Result negative (Ambient>880mbar)?
heinrichsweikamp
parents:
diff changeset
352 bsf high_altitude_mode ; No, Set Flag!
heinrichsweikamp
parents:
diff changeset
353
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
354 btfss analog_o2_input
165
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
355 bsf TRISB,3
449
heinrichsweikamp
parents: 446
diff changeset
356 btfss battery_gauge_available
165
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
357 bsf TRISG,0
0
heinrichsweikamp
parents:
diff changeset
358 call ext_flash_disable_protection ; Disable write protection for external flash
heinrichsweikamp
parents:
diff changeset
359
155
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
360 bsf flip_screen ; Flip 180°
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
361 TSTOSS opt_flip_screen ; =1: Flip the screen
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
362 bcf flip_screen ; Normal orientation
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 147
diff changeset
363
464
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
364 btfsc use_old_batt_flag ; =1: load old battery information after power-on reset
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
365 goto use_old_batteries ; Returns to "surfloop"!
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
366
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
367 btfsc RCON,POR ; Was this a power-on reset?
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
368 goto surfloop ; Jump to Surfaceloop!
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
369 bsf RCON,POR ; Set bit for next detection
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
370 ; Things to do after a power-on reset
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
371 extern new_battery_menu,use_old_batteries
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
372 goto new_battery_menu ; Returns to "surfloop"!
0
heinrichsweikamp
parents:
diff changeset
373
heinrichsweikamp
parents:
diff changeset
374 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
375 ; Setup all flags and parameters for divemode and simulator computations.
heinrichsweikamp
parents:
diff changeset
376 ;
heinrichsweikamp
parents:
diff changeset
377 global restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
378 restart_set_modes_and_flags: ; "Call"ed from divemode, as well!
heinrichsweikamp
parents:
diff changeset
379 call option_restore_all ; Restore everything from EEPROM
24
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
380
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
381 ; Setup sampling rate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
382 movlw .2
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
383 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
384 TSTOSS opt_sampling_rate ; =1: 10s, =0: 2s
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
385 bra restart_set_modes_and_flags1
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
386 movlw .10
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
387 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
388 restart_set_modes_and_flags1:
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
389 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR
0
heinrichsweikamp
parents:
diff changeset
390
heinrichsweikamp
parents:
diff changeset
391 bcf FLAG_apnoe_mode
heinrichsweikamp
parents:
diff changeset
392 bcf FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
393 bcf FLAG_gauge_mode ; =1: In Gauge mode
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
394 bcf FLAG_pscr_mode
224
5a4801918be9 temporally disable "Copy disable flags from digital input" routine
heinrichsweikamp
parents: 220
diff changeset
395 call disable_ir_s8 ; IR off
0
heinrichsweikamp
parents:
diff changeset
396
heinrichsweikamp
parents:
diff changeset
397 tstfsz lo
heinrichsweikamp
parents:
diff changeset
398 bra restart_set_modes_and_flags2
heinrichsweikamp
parents:
diff changeset
399 ; OC Mode
heinrichsweikamp
parents:
diff changeset
400 return
heinrichsweikamp
parents:
diff changeset
401
heinrichsweikamp
parents:
diff changeset
402 restart_set_modes_and_flags2:
heinrichsweikamp
parents:
diff changeset
403 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
404 bra restart_set_modes_and_flags3
heinrichsweikamp
parents:
diff changeset
405 ; CC Mode
359
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
406 btfsc analog_o2_input ; cR?
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
407 bra restart_set_modes_and_flags2b ; Yes, skip mode check
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
408 btfsc optical_input ; 3
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
409 bra restart_set_modes_and_flags2b ; Yes, skip mode check
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
410 ; Make sure Sensor is not selected
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
411 ; opt_ccr_mode must be <> 1 (=0: Fixed SP, =1: Sensor, =2: Auto SP)
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
412 banksel opt_ccr_mode
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
413 movlw .1
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
414 cpfseq opt_ccr_mode ; = Sensor?
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
415 bra restart_set_modes_and_flags2b ; No
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
416 clrf opt_ccr_mode ; Yes, reset to Fixed SP
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
417 restart_set_modes_and_flags2b:
2be48ccfa9de make AUTO SP available on OSTC2 hardware
heinrichsweikamp
parents: 338
diff changeset
418 banksel common
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 319
diff changeset
419 bsf FLAG_ccr_mode ; =1: CCR mode (Fixed SP, Auto SP or Sensor) active
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 165
diff changeset
420 call enable_ir_s8 ; Enable IR/S8-Port
0
heinrichsweikamp
parents:
diff changeset
421 return
heinrichsweikamp
parents:
diff changeset
422
heinrichsweikamp
parents:
diff changeset
423 restart_set_modes_and_flags3:
heinrichsweikamp
parents:
diff changeset
424 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
425 bra restart_set_modes_and_flags4
heinrichsweikamp
parents:
diff changeset
426 ; Gauge Mode
heinrichsweikamp
parents:
diff changeset
427 bsf FLAG_gauge_mode ; =1: In Gauge mode
heinrichsweikamp
parents:
diff changeset
428 return
heinrichsweikamp
parents:
diff changeset
429
heinrichsweikamp
parents:
diff changeset
430 restart_set_modes_and_flags4:
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
431 decfsz lo,F
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
432 bra restart_set_modes_and_flags5
0
heinrichsweikamp
parents:
diff changeset
433 ; Apnea Mode
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
434 bsf FLAG_apnoe_mode
0
heinrichsweikamp
parents:
diff changeset
435 return ; start in Surfacemode
heinrichsweikamp
parents:
diff changeset
436
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
437 restart_set_modes_and_flags5:
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
438 ; PSCR Mode
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
439 bsf FLAG_pscr_mode
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
440 return ; start in Surfacemode
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
441
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
442
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
443 backup_flash_page: ; backup the first 128bytes from flash to EEPROM
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
444 ; Start address in internal flash
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
445 movlw 0x00
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
446 movwf TBLPTRL
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
447 movwf TBLPTRH
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
448 movwf TBLPTRU
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
449
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
450 movlw .128
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
451 movwf lo ; Byte counter
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
452 clrf EEADR
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
453 movlw .3
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
454 movwf EEADRH ; Setup backup address
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
455
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
456 TBLRD*- ; Dummy read to be in 128 byte block
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
457 backup_flash_loop:
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
458 tblrd+* ; Table Read with Pre-Increment
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
459 movff TABLAT,EEDATA ; put 1 byte
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
460 call write_eeprom ; save it in EEPROM
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
461 incf EEADR,F
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
462 decfsz lo,F ; 128byte done?
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
463 bra backup_flash_loop ; No
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
464 clrf EEADRH ; Reset EEADRH
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
465 return ; Done.
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
466
0
heinrichsweikamp
parents:
diff changeset
467 END