annotate src/start.asm @ 605:5ce603c29750

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