annotate src/start.asm @ 356:fcf3ae0fee6a

Changed content for new 0x6F command (Get compact headers)
author heinrichsweikamp
date Sun, 02 Aug 2015 09:52:28 +0200
parents 2811932b4e99
children 2be48ccfa9de
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 bsf no_sensor_int ; disable sensor interrupt
heinrichsweikamp
parents:
diff changeset
55
heinrichsweikamp
parents:
diff changeset
56 ; Air pressure compensation after reset
heinrichsweikamp
parents:
diff changeset
57 call get_calibration_data ; Get calibration data from pressure sensor
heinrichsweikamp
parents:
diff changeset
58 banksel common ; get_calibration_data uses isr_backup
heinrichsweikamp
parents:
diff changeset
59 bcf no_sensor_int ; normal sensor interrupt mode
heinrichsweikamp
parents:
diff changeset
60
10
55dfc8f6093f sensor status on power-on reset
heinrichsweikamp
parents: 0
diff changeset
61 call TFT_DisplayOff ; display off
55dfc8f6093f sensor status on power-on reset
heinrichsweikamp
parents: 0
diff changeset
62 bsf LEDr ; Status LED
0
heinrichsweikamp
parents:
diff changeset
63 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
64 ; First pass will not have valid temperature!
heinrichsweikamp
parents:
diff changeset
65 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
66 bra $-2
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 45
diff changeset
67 bcf LEDr
0
heinrichsweikamp
parents:
diff changeset
68 ; Second pass
heinrichsweikamp
parents:
diff changeset
69 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
70 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
71 bra $-2
heinrichsweikamp
parents:
diff changeset
72
heinrichsweikamp
parents:
diff changeset
73 clrf rel_pressure+0
heinrichsweikamp
parents:
diff changeset
74 clrf rel_pressure+1
heinrichsweikamp
parents:
diff changeset
75 clrf surface_interval+0
heinrichsweikamp
parents:
diff changeset
76 clrf surface_interval+1
heinrichsweikamp
parents:
diff changeset
77
heinrichsweikamp
parents:
diff changeset
78 SAFE_2BYTE_COPY amb_pressure, last_surfpressure
heinrichsweikamp
parents:
diff changeset
79
heinrichsweikamp
parents:
diff changeset
80 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
81 movff WREG,sub_a+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
82 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
83 movff WREG,sub_a+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
84 movff last_surfpressure+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
85 movff last_surfpressure+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
86 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
87 btfss neg_flag ; Is 1080mbar < amb_pressure ?
heinrichsweikamp
parents:
diff changeset
88 bra start_copy_pressure ; NO: current airpressure is lower then "allowed" airpressure, ok!
heinrichsweikamp
parents:
diff changeset
89
heinrichsweikamp
parents:
diff changeset
90 ; not ok! Overwrite with max. "allowed" airpressure
heinrichsweikamp
parents:
diff changeset
91 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
92 movff WREG,last_surfpressure+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
93 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
94 movff WREG,last_surfpressure+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
95
heinrichsweikamp
parents:
diff changeset
96 start_copy_pressure:
heinrichsweikamp
parents:
diff changeset
97 movff last_surfpressure+0,last_surfpressure_15min+0
heinrichsweikamp
parents:
diff changeset
98 movff last_surfpressure+1,last_surfpressure_15min+1
heinrichsweikamp
parents:
diff changeset
99 movff last_surfpressure+0,last_surfpressure_30min+0
heinrichsweikamp
parents:
diff changeset
100 movff last_surfpressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 ; reset deco data for surface mode
heinrichsweikamp
parents:
diff changeset
103 movlw d'79'
heinrichsweikamp
parents:
diff changeset
104 movff WREG,char_I_N2_ratio ; 79% N2
heinrichsweikamp
parents:
diff changeset
105 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy for deco routine
heinrichsweikamp
parents:
diff changeset
106 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine
heinrichsweikamp
parents:
diff changeset
107 movff int_I_pres_respiration+1,int_I_pres_surface+1
heinrichsweikamp
parents:
diff changeset
108
heinrichsweikamp
parents:
diff changeset
109 extern deco_reset
heinrichsweikamp
parents:
diff changeset
110 call deco_reset
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
111
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
112 call rtc_init ; init clock
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
113
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
114 movlw HIGH .512 ; =2
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
115 movwf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
116 read_int_eeprom .0
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
117 clrf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
118 movlw 0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
119 cpfseq EEDATA ; =0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
120 bra no_deco_restore ; No
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
121
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
122 extern restore_decodata_from_eeprom
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
123 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
124
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
125 no_deco_restore:
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
126 call deco_calc_desaturation_time ; calculate desaturation time
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
127 banksel common
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
128 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
129 banksel common
0
heinrichsweikamp
parents:
diff changeset
130 bcf menubit ; clear menu flag
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
131
0
heinrichsweikamp
parents:
diff changeset
132 ; Check for Power-on reset here
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
133 extern new_battery_menu,use_old_batteries
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
134 ; *****************************************************************************
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
135 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return"
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
136 ; *****************************************************************************
0
heinrichsweikamp
parents:
diff changeset
137
heinrichsweikamp
parents:
diff changeset
138 btfsc RCON,POR ; Was this a power-on reset?
heinrichsweikamp
parents:
diff changeset
139 goto use_old_batteries ; No, load last stored battery values
heinrichsweikamp
parents:
diff changeset
140
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
141 call lt2942_get_status ; Check for gauge IC
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 224
diff changeset
142 btfsc rechargeable ; cR hardware?
215
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
143 goto use_old_batteries ; Yes, load last stored battery values
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
144
8636efc5c6c5 ignore battery menu for cr
heinrichsweikamp
parents: 207
diff changeset
145 ; No, cR and we have a power-on reset
0
heinrichsweikamp
parents:
diff changeset
146 goto new_battery_menu ; show "New battery dialog"
heinrichsweikamp
parents:
diff changeset
147
heinrichsweikamp
parents:
diff changeset
148 global power_on_return
heinrichsweikamp
parents:
diff changeset
149 power_on_return:
heinrichsweikamp
parents:
diff changeset
150 bsf RCON,POR ; Set bit for next detection
heinrichsweikamp
parents:
diff changeset
151
heinrichsweikamp
parents:
diff changeset
152 ; check firmware and reset Custom Functions after an update
heinrichsweikamp
parents:
diff changeset
153 movlw d'1'
281
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
154 movwf EEADR ; =1
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
155 movwf EEADRH ; =1
0
heinrichsweikamp
parents:
diff changeset
156 call read_eeprom ; read current version x
heinrichsweikamp
parents:
diff changeset
157 movff EEDATA,temp1
heinrichsweikamp
parents:
diff changeset
158 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
159 call read_eeprom ; read current version y
heinrichsweikamp
parents:
diff changeset
160 movff EEDATA,temp2
heinrichsweikamp
parents:
diff changeset
161 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
162
heinrichsweikamp
parents:
diff changeset
163 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
164 cpfseq temp1 ; compare version x
heinrichsweikamp
parents:
diff changeset
165 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
166
heinrichsweikamp
parents:
diff changeset
167 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
168 cpfseq temp2 ; compare version y
heinrichsweikamp
parents:
diff changeset
169 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
170 bra restart ; x and y are equal -> do not reset cf
heinrichsweikamp
parents:
diff changeset
171
heinrichsweikamp
parents:
diff changeset
172 check_firmware_new:
heinrichsweikamp
parents:
diff changeset
173 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
174 clrf CCPR1L ; Backlight off
heinrichsweikamp
parents:
diff changeset
175 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
176 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
177 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
178 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
179 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
180 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
181 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
182 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
183 extern color_image
heinrichsweikamp
parents:
diff changeset
184 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
185 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
186 WIN_SMALL .10,.100
52
0fae975af741 english correction
heinrichsweikamp
parents: 50
diff changeset
187 STRCPY_TEXT_PRINT tNewFirmware1 ; "Update successfull!"
0
heinrichsweikamp
parents:
diff changeset
188 WIN_SMALL .10,.140
heinrichsweikamp
parents:
diff changeset
189 STRCPY_TEXT tNewFirmware2 ; "New Firmware: "
heinrichsweikamp
parents:
diff changeset
190 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
191 movwf lo
heinrichsweikamp
parents:
diff changeset
192 bsf leftbind
heinrichsweikamp
parents:
diff changeset
193 output_8
heinrichsweikamp
parents:
diff changeset
194 PUTC "."
heinrichsweikamp
parents:
diff changeset
195 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
196 movwf lo
45
76dfe320e6ec 1.01 beta start
heinrichsweikamp
parents: 24
diff changeset
197 output_99x
0
heinrichsweikamp
parents:
diff changeset
198 bcf leftbind
heinrichsweikamp
parents:
diff changeset
199 STRCAT_PRINT "" ; Print second row
heinrichsweikamp
parents:
diff changeset
200 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
201
heinrichsweikamp
parents:
diff changeset
202 ; place "after-update reset" here...
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
203
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
204 extern oPressureAdjust, option_reset, option_save
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
205 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
206 call option_reset ; Reset FSR0 option to factory default.
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
207 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
208 call option_save ; Save in EEPROM
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
209
281
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
210 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
211
0
heinrichsweikamp
parents:
diff changeset
212 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
213 movwf EEADR ; =1
eb758a5b44eb BUGFIX: Fix download issue for dives made with 1.80 firmware
heinrichsweikamp
parents: 276
diff changeset
214 movwf EEADRH ; =1
0
heinrichsweikamp
parents:
diff changeset
215 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
216 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
217 call write_eeprom ; write version x
heinrichsweikamp
parents:
diff changeset
218 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
219 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
220 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
221 call write_eeprom ; write version y
heinrichsweikamp
parents:
diff changeset
222 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
223
heinrichsweikamp
parents:
diff changeset
224 movlw .7
heinrichsweikamp
parents:
diff changeset
225 movwf lo
heinrichsweikamp
parents:
diff changeset
226 check_firmware_new2:
heinrichsweikamp
parents:
diff changeset
227 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
228 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
229 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
230 bra $-2
heinrichsweikamp
parents:
diff changeset
231 decfsz lo,F ; Wait 10 seconds...
heinrichsweikamp
parents:
diff changeset
232 bra check_firmware_new2
heinrichsweikamp
parents:
diff changeset
233
heinrichsweikamp
parents:
diff changeset
234 global restart
heinrichsweikamp
parents:
diff changeset
235 restart:
heinrichsweikamp
parents:
diff changeset
236 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
237 clrf CCP1CON ; stop PWM
e4cb495aed3d Increase byte timeout in PC download mode, faster response to "Exit" in main menu
heinrichsweikamp
parents: 275
diff changeset
238 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
239
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 16
diff changeset
240 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
241
0
heinrichsweikamp
parents:
diff changeset
242 btfsc menubit ; Return from Menu/COMM mode or timeout?
heinrichsweikamp
parents:
diff changeset
243 call option_save_all ; Yes, save all settings into EEPROM
heinrichsweikamp
parents:
diff changeset
244
220
effd7259f5a5 make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents: 215
diff changeset
245 call option_restore_all ; Restore everything from EEPROM
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
246 call option_check_all ; Check all options (and reset if not within their min/max boundaries)
220
effd7259f5a5 make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents: 215
diff changeset
247 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
248
0
heinrichsweikamp
parents:
diff changeset
249 clrf flag1 ; clear all flags
heinrichsweikamp
parents:
diff changeset
250 clrf flag2
heinrichsweikamp
parents:
diff changeset
251 clrf flag3
heinrichsweikamp
parents:
diff changeset
252 clrf flag4
heinrichsweikamp
parents:
diff changeset
253 clrf flag5
heinrichsweikamp
parents:
diff changeset
254 clrf flag6
heinrichsweikamp
parents:
diff changeset
255 clrf flag7
heinrichsweikamp
parents:
diff changeset
256 clrf flag8
16
7b06f20881be calm compass reading for minor heading changes
heinrichsweikamp
parents: 10
diff changeset
257 clrf flag9
113
heinrichsweikamp
parents: 93
diff changeset
258 clrf flag10
267
f64afa14ef07 BUGFIX: Analog sensors were ignored in 1.76
heinrichsweikamp
parents: 255
diff changeset
259 ; Do not clear flag11 (Sensor calibration and charger status)
255
ad62dff7739a add bearing option to compass
heinrichsweikamp
parents: 249
diff changeset
260 clrf flag12
319
cf929551d31c move flag13 into bank common
heinrichsweikamp
parents: 281
diff changeset
261 clrf flag13
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 224
diff changeset
262 clrf hardware_flag ; hardware descriptor flag
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 224
diff changeset
263 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
264
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
265 ; configure hardware_flag byte
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
266
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
267 bsf ambient_sensor ; Clear flag
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
268 bsf optical_input ; Clear flag
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
269
113
heinrichsweikamp
parents: 93
diff changeset
270 call lt2942_get_status ; Check for gauge IC
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
271 btfss rechargeable ; cR hardware?
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
272 bra restart2 ; No
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
273
113
heinrichsweikamp
parents: 93
diff changeset
274 call lt2942_init ; Yes, init battery gauge IC
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
275 bcf ambient_sensor ; Clear flag
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
276 bcf optical_input ; Clear flag
248
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
277
243
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
278 restart2:
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
279 btfsc vusb_in
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
280 bra restart3 ; USB (and powered on)
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
281 bcf PORTE,0 ; Start comms
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
282 WAITMS d'1'
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
283 btfss vusb_in
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
284 bra restart3 ; USB (and powered off)
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
285 bsf ble_available ; ble available
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
286 restart3:
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
287 bsf PORTE,0 ; Stop comms
248
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
288 btfsc ble_available ; ble available?
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
289 bra restart4 ; Yes, can't be a cR
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
290 btfss rechargeable ; Rechargeable
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
291 bra restart4 ; No, can't be a cR
afe73e1a0181 support hardware_flag for all possible hardware combinations
heinrichsweikamp
parents: 243
diff changeset
292 bsf analog_o2_input ; Set flag for analog
249
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
293 restart4:
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
294 ; The hardware_flag is now:
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
295 ; 3: 0x0A
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
296 ; cR: 0x05
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
297 ; 2 with BLE: 0x11
94bf757690cf ignore sensor for non-sensor hardware
heinrichsweikamp
parents: 248
diff changeset
298 ; 3 with BLE: 0x1A
113
heinrichsweikamp
parents: 93
diff changeset
299
0
heinrichsweikamp
parents:
diff changeset
300 ; Select high altitude (Fly) mode?
heinrichsweikamp
parents:
diff changeset
301 movff last_surfpressure_30min+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
302 movff last_surfpressure_30min+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
303 movlw HIGH high_altitude_threshold
heinrichsweikamp
parents:
diff changeset
304 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
305 movlw LOW high_altitude_threshold ; Hard-wired 880mbar
heinrichsweikamp
parents:
diff changeset
306 movwf sub_a+0
heinrichsweikamp
parents:
diff changeset
307 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
308 btfss neg_flag ; Result negative (Ambient>880mbar)?
heinrichsweikamp
parents:
diff changeset
309 bsf high_altitude_mode ; No, Set Flag!
heinrichsweikamp
parents:
diff changeset
310
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
311 btfss analog_o2_input
165
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
312 bsf TRISB,3
235
23311219dacc under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents: 224
diff changeset
313 btfss rechargeable
165
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
314 bsf TRISG,0
0
heinrichsweikamp
parents:
diff changeset
315 call ext_flash_disable_protection ; Disable write protection for external flash
heinrichsweikamp
parents:
diff changeset
316
155
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
317 bsf flip_screen ; Flip 180°
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
318 TSTOSS opt_flip_screen ; =1: Flip the screen
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
319 bcf flip_screen ; Normal orientation
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 147
diff changeset
320
0
heinrichsweikamp
parents:
diff changeset
321 goto surfloop ; Jump to Surfaceloop!
heinrichsweikamp
parents:
diff changeset
322
heinrichsweikamp
parents:
diff changeset
323 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
324 ; Setup all flags and parameters for divemode and simulator computations.
heinrichsweikamp
parents:
diff changeset
325 ;
heinrichsweikamp
parents:
diff changeset
326 global restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
327 restart_set_modes_and_flags: ; "Call"ed from divemode, as well!
heinrichsweikamp
parents:
diff changeset
328 call option_restore_all ; Restore everything from EEPROM
24
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
329
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
330 ; Setup sampling rate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
331 movlw .2
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
332 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
333 TSTOSS opt_sampling_rate ; =1: 10s, =0: 2s
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
334 bra restart_set_modes_and_flags1
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
335 movlw .10
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
336 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
337 restart_set_modes_and_flags1:
0
heinrichsweikamp
parents:
diff changeset
338 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea
heinrichsweikamp
parents:
diff changeset
339
heinrichsweikamp
parents:
diff changeset
340 bcf FLAG_apnoe_mode
heinrichsweikamp
parents:
diff changeset
341 bcf FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
342 bcf FLAG_gauge_mode ; =1: In Gauge mode
224
5a4801918be9 temporally disable "Copy disable flags from digital input" routine
heinrichsweikamp
parents: 220
diff changeset
343 call disable_ir_s8 ; IR off
0
heinrichsweikamp
parents:
diff changeset
344
heinrichsweikamp
parents:
diff changeset
345 tstfsz lo
heinrichsweikamp
parents:
diff changeset
346 bra restart_set_modes_and_flags2
heinrichsweikamp
parents:
diff changeset
347 ; OC Mode
heinrichsweikamp
parents:
diff changeset
348 return
heinrichsweikamp
parents:
diff changeset
349
heinrichsweikamp
parents:
diff changeset
350 restart_set_modes_and_flags2:
heinrichsweikamp
parents:
diff changeset
351 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
352 bra restart_set_modes_and_flags3
heinrichsweikamp
parents:
diff changeset
353 ; CC Mode
338
2811932b4e99 NEW: Mode Auto SP: Automatically switches the SP during descent (CC Mode)
heinrichsweikamp
parents: 319
diff changeset
354 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
355 call enable_ir_s8 ; Enable IR/S8-Port
0
heinrichsweikamp
parents:
diff changeset
356 return
heinrichsweikamp
parents:
diff changeset
357
heinrichsweikamp
parents:
diff changeset
358 restart_set_modes_and_flags3:
heinrichsweikamp
parents:
diff changeset
359 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
360 bra restart_set_modes_and_flags4
heinrichsweikamp
parents:
diff changeset
361 ; Gauge Mode
heinrichsweikamp
parents:
diff changeset
362 bsf FLAG_gauge_mode ; =1: In Gauge mode
heinrichsweikamp
parents:
diff changeset
363 return
heinrichsweikamp
parents:
diff changeset
364
heinrichsweikamp
parents:
diff changeset
365 restart_set_modes_and_flags4:
heinrichsweikamp
parents:
diff changeset
366 ; Apnea Mode
heinrichsweikamp
parents:
diff changeset
367 bsf FLAG_apnoe_mode
heinrichsweikamp
parents:
diff changeset
368 return ; start in Surfacemode
heinrichsweikamp
parents:
diff changeset
369
heinrichsweikamp
parents:
diff changeset
370 END