annotate src/start.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents b87f23fae743
children cd58f7fc86db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
3 ; File start.asm combined next generation V3.03.2
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"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
14 #include "shared_definitions.h" ; mailbox from/to p2_deco.c
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
15 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
16 #include "math.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
17 #include "tft.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
18 #include "surfmode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
19 #include "wait.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
20 #include "rtc.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
21 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
22 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
23 #include "tft_outputs.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
24 #include "adc_lightsensor.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
25 #include "i2c.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
26 #include "divemode.inc"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
27 #include "rx_ops.inc"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
28
0
heinrichsweikamp
parents:
diff changeset
29
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
30 extern init_ostc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
31 extern option_restore_all
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
32 extern backup_flash_page
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
33 extern restore_decodata_from_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
34 extern oPressureAdjust
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
35 extern option_reset
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
36 extern option_save
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
37 extern option_save_all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
38 extern option_check_all
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
39 extern do_new_battery_select
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
40 extern get_battery_data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
41 extern use_old_prior_209
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
42 extern get_first_gas_to_WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
43
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
44 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
45 extern option_cleanup_oCCRMode_pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
46 extern option_cleanup_oCCRMode_CCR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
47 extern get_first_dil_to_WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
48 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
49
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
50 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
51 extern option_cleanup_oTrMode_CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
52 extern option_cleanup_oTrMode_no_CCR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
53 extern rx_firmware_new_major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
54 extern rx_firmware_new_minor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
55 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
56
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
57 ;-----------------------------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
58
0
heinrichsweikamp
parents:
diff changeset
59
heinrichsweikamp
parents:
diff changeset
60 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
61 ; Reset Vector: entry point on device wake-up and hard reset
0
heinrichsweikamp
parents:
diff changeset
62 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
63 reset_v CODE 0x00000
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
64 goto 0x1FF00 ; jump to bootloader
0
heinrichsweikamp
parents:
diff changeset
65
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
66 start_v CODE 0x00004 ; jump to application (cold-)start
0
heinrichsweikamp
parents:
diff changeset
67 goto start
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
68
0
heinrichsweikamp
parents:
diff changeset
69 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
70
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
71 boot CODE
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
72
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
73 ;=============================================================================
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
74 ; Entry point after cold start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
75 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
76 global start
0
heinrichsweikamp
parents:
diff changeset
77 start:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
78 ; clear RAM banks 0-14
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
79 lfsr FSR0,0x000 ; load start address into FSR0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
80 movlw 0x0F ; load end address into WREG (actually its high byte)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
81 start_clear_rambank:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
82 clrf POSTINC0 ; clear memory location and increment FSR0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
83 cpfseq FSR0H ; has FSR0 reached begin of bank 15, i.e. banks 0-14 done?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
84 bra start_clear_rambank ; NO - loop
0
heinrichsweikamp
parents:
diff changeset
85
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
86 ; initialize hardware (ports, timers, interrupts, etc.)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
87 call init_ostc ; also selects bank common and sets CPU to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
88
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
89 ; flag that later restart origins from a cold start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
90 bsf cold_start
0
heinrichsweikamp
parents:
diff changeset
91
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
92 ; initialize averaging for analog buttons
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
93 movlw .16 ; set averaging span
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
94 movff WREG,analog_counter ; write to counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
95
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
96 ; get button type from bootloader info
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
97 bsf analog_switches
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
98 movlw 0x7C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
99 movwf TBLPTRL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
100 movlw 0xF7
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
101 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
102 movlw 0x01
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
103 movwf TBLPTRU
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
104 TBLRD*+ ; read configuration byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
105 movlw 0x07 ; coding for analog buttons
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
106 cpfseq TABLAT ; equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
107 bcf analog_switches ; NO - no analog buttons
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
108
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
109 ; get screen type (2) from bootloader info
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
110 bsf screen_type2
614
a32212cd5ea9 work on new battery menu
heinrichsweikamp
parents: 612
diff changeset
111 movlw 0x80
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
112 movwf TBLPTRL ; only low byte adjustment needed, high and upper are still at 0x01F7xx
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
113 TBLRD*+ ; read configuration byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
114 movlw 0x83 ; coding for screen type 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
115 cpfseq TABLAT ; equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
116 bcf screen_type2 ; NO - not screen type 2
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
117
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
118 ; get button polarity from configuration data (EEPROM)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
119 movlw LOW .897
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
120 movwf EEADR
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
121 movlw HIGH .897
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
122 movwf EEADRH
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
123 call read_eeprom ; EEDATA into EEPROM @ EEADR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
124 clrf EEADRH ; reset EEADRH
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
125 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
126
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
127 ; initialize pressure sensor calibration
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
128 call get_calibration_data ; get calibration data from pressure sensor
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
129 call TFT_DisplayOff ; turn off display
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
130
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
131 ; wait for calibration data to take effect
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
132 bsf LEDr ; turn on red LED
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
133
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
134 ; first pass, will not have valid temperature yet
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
135 bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
136 btfss trigger_pres_update ; has the ISR confirmed a pressure update?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
137 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in
0
heinrichsweikamp
parents:
diff changeset
138
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
139 ; second pass - complete sensor initialization
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
140 bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
141 btfss trigger_pres_update ; has the ISR confirmed a pressure update?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
142 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in
0
heinrichsweikamp
parents:
diff changeset
143
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
144 ; sensor calibration completed, first valid pressure value is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
145 bcf LEDr ; turn off red LED again
0
heinrichsweikamp
parents:
diff changeset
146
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
147 ; load surface pressure into ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
148 ; initially needs to be done twice in order to shift the current absolute pressure through the
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
149 ; 15 minutes sampling buffer into the reference buffer from where it is loaded by the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
150 rcall sample_surface_pressure ; 1st pass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
151 rcall sample_surface_pressure ; 2nd pass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
152 btfsc update_surface_pressure ; has the ISR confirmed loading of the surface pressure?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
153 bra $-2 ; NO - not yet, loop until ISR has confirmed loading
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 545
diff changeset
154
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
155 ; reset all tissue pressures to surface pressure equilibrium state by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
156 call deco_clear_tissue ; (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
157 banksel common
0
heinrichsweikamp
parents:
diff changeset
158
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
159 ; restore tissue pressures from EEPROM (if available)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
160 movlw HIGH .512 ; =2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
161 movwf EEADRH ; set EEPROM address, high byte
582
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
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
164 movlw 0xAA ; coding for tissue pressures available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
165 cpfseq EEDATA ; tissue pressures available?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
166 bra start_1 ; NO - no tissue pressures available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
167 call restore_decodata_from_eeprom ; YES - reload tissue pressures from EEPROM
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
168
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
169 start_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
170 bsf reset_surface_interval ; request ISR to reset the surface interval timer
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
171
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
172 ; call rtc_init ; initialize the real time clock (will reset to firmware creation date)
0
heinrichsweikamp
parents:
diff changeset
173
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
174 ; check for power-on reset
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
175 btfsc RCON,POR ; was this a power-on reset?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
176 call use_old_prior_209 ; NO - migrate the last battery status from firmware 2.09 or earlier
464
0491a84fd0b8 CHANGE: Easier to understand "New Battery" menu (OSTC model dependent)
heinrichsweikamp
parents: 463
diff changeset
177
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
178 bcf use_old_batt_flag ; default to no reload of last battery data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
179 btfsc RCON,POR ; was this a power-on reset?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
180 bsf use_old_batt_flag ; NO - reload last battery data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
181
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
182 call lt2942_get_status ; check for gauge IC
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
183 btfss battery_gauge_available ; cR or 2 hardware?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
184 bra start_check_new_firmware ; NO - skip next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
185 movlw .30 ; YES - load default button sensitivity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
186 movff WREG,opt_cR_button_right ; - set default for left button
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
187 movff WREG,opt_cR_button_left ; - set default for right button
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
188 call piezo_config ; - configure buttons, 1st pass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
189 call piezo_config ; - configure buttons, 2nd pass
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
190
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
191 start_check_new_firmware:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
192 call TFT_boot ; initialize TFT (includes clear screen & backlight switch-off)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
193
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
194 ; show heinrichsweikamp logo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
195 WIN_TOP .40
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
196 WIN_LEFT .10
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
197 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
198
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
199 ; check if a new firmware was loaded, if yes reset option oPressureAdjust
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
200 movlw d'1' ; set EEPROM address to 0x101
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
201 movwf EEADR ; = 0x001
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
202 movwf EEADRH ; = 0x101
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
203 call read_eeprom ; read current version, major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
204 movff EEDATA,lo ; store major in lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
205 incf EEADR,F ; set EEPROM address to 0x102
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
206 call read_eeprom ; read current version, minor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
207 movff EEDATA,hi ; store minor in hi
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
208 clrf EEADRH ; reset EEADRH
0
heinrichsweikamp
parents:
diff changeset
209
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
210 movlw softwareversion_x ; get current major version
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
211 cpfseq lo ; compare with stored version, equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
212 bra start_check_new_firmware_new ; NO - reset some options and store new version in EEPROM
0
heinrichsweikamp
parents:
diff changeset
213
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
214 movlw softwareversion_y ; get current minor version
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
215 cpfseq hi ; compare with stored version, equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
216 bra start_check_new_firmware_new ; NO - reset some options and store new version in EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
217 bra start_check_new_firmware_old ; YES - both equal, do not reset options
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
218
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
219 start_check_new_firmware_new:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
220 ; new firmware version detected
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
221 call show_fw_mesg_update ; show firmware update message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
222
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
223 ; place "after-update reset" here...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
224 lfsr FSR0,oPressureAdjust ; memory address of option data
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
225 call option_reset ; reset oPressureAdjust to factory default
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
226 lfsr FSR0,oPressureAdjust ; memory address of option data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
227 call option_save ; save reseted value of oPressureAdjust in EEPROM
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
228
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
229 ; store current version in EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
230 movlw d'1' ; set EEPROM address to 0x101
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
231 movwf EEADR ; = 0x001
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
232 movwf EEADRH ; = 0x101
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
233 movlw softwareversion_x ; get version, major number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
234 movwf EEDATA ; prepare write
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
235 call write_eeprom ; execute write
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
236 incf EEADR,F ; set EEPROM address to 0x102
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
237 movlw softwareversion_y ; get version, minor number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
238 movwf EEDATA ; prepare write
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
239 call write_eeprom ; execute write
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
240 clrf EEADRH ; reset EEADRH
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
241 bra start_check_new_firmware_common ;
0
heinrichsweikamp
parents:
diff changeset
242
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
243 start_check_new_firmware_old:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
244 call show_fw_mesg_kept ; show firmware is kept message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
245
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
246 start_check_new_firmware_common:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
247 call TFT_Display_FadeIn ; display resulting screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
248 call backup_flash_page ; back-up the first 128 bytes from program flash memory to EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
249
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
250 ; pause 5 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
251 movlw .5 ; load loop counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
252 start_check_new_firmware_wait:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
253 call wait_1s ; wait <= 1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
254 decfsz WREG,W ; decrement loop counter, did it became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
255 bra start_check_new_firmware_wait ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
256 ;bra restart ; YES - proceed with restart
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
257
0
heinrichsweikamp
parents:
diff changeset
258
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
259 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
260 ; Entry point after warm start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
261 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
262 ; called on leaving sleep mode, surface menu, communication mode, and
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
263 ; when a start of a dive is detected in all modes except surface mode.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
264 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
265 global restart
0
heinrichsweikamp
parents:
diff changeset
266 restart:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
267 banksel common ; for safety purpose only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
268 clrf STKPTR ; clear return addresses stack
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
269 clrf CCP1CON ; stop PWM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
270 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
271
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
272 call request_speed_normal ; request CPU speed change to normal speed (for safety only)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
273
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
274 ; manage the option settings
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
275 btfsc surfmode_menu ; was restart entered by return from surface menu or comm mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
276 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
277
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
278 btfss surfmode_menu ; was restart entered by return from surface menu or comm mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
279 call option_restore_all ; NO - load all settings from EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
280
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
281 call option_check_all ; check all options and repair them if not within their min/max boundaries
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
282
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
283 btfsc option_repaired ; errors found & repaired during options check?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
284 call option_save_all ; YES - save corrected settings into EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
285
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
286 ; clear flag groups
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
287 clrf HW_descriptor ; hardware - OSTC model descriptor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
288 clrf HW_flags_state ; hardware - status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
289 clrf DM_flags_sensor ; hardware - O2 sensors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
290
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
291 clrf OS_flags_ISR1 ; operating system - ISR control 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
292 clrf OS_flags_ISR2 ; operating system - ISR control 2
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
293
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
294 clrf eventbase ; event triggers generated by ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
295
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
296 clrf DM_flags_deco ; dive deco modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
297
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
298 clrf MS_flags_control ; menu system - control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
299 clrf MS_flags_imprint ; menu system - data imprinting
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
300
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
301 clrf CVT_flags1 ; convert and display functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
302 clrf CVT_flags2 ; convert and display functions
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
303
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
304 ; TFT will be dimming soon, ignore ambient sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
305 bsf tft_is_dimming
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
306
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
307 ; configure the OSTC model descriptor (stored in HW_descriptor)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
308 bcf tft_power ; inverted, here needed for I2C_probe_OSTC_rx, to wake-up RX circuity
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
309 bsf ambient_sensor ; set ambient light sensor as available by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
310 bsf optical_input ; set optical input as available by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
311
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
312 call lt2942_get_status ; check for gauge IC
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
313 btfss battery_gauge_available ; OSTC 2, cR or TR?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
314 bra restart2 ; NO
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
315
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
316 ; OSTC 2, cR or TR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
317 call lt2942_init ; initialize battery gauge IC
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
318 bcf optical_input ; OSTC 2, cR and TR do not have an optical input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
319
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
320 banksel ANCON0 ; ANCON0 is outside access RAM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
321 bcf ANCON0,7 ; AN7 digital input
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
322 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
323 bcf lightsen_power ; power-down ambient light sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
324 bcf ambient_sensor ; no ambient light sensor by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
325 nop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
326 btfss PORTF,2 ; ambient light sensor available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
327 bsf ambient_sensor ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
328 banksel ANCON0 ; ANCON0 is outside access RAM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
329 bsf ANCON0,7 ; AN7 analog again
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
330 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
331 bsf lightsen_power ; power-up ambient light sensor again
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
332
243
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
333 restart2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
334 btfsc vusb_in ; USB power detected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
335 bra restart3 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
336 bcf PORTE,0 ; start comm
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
337 WAITMS d'5' ; wait 5 ms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
338 btfss vusb_in ; USB power detected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
339 bra restart3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
340 bsf ble_available ; YES - BLE available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
341
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
342 restart3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
343 bsf PORTE,0 ; stop comm
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
344 btfsc ble_available ; BLE available?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
345 bra restart4 ; YES - can't be a cR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
346 btfss battery_gauge_available ; rechargeable?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
347 bra restart4 ; NO - can't be a cR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
348 bsf analog_o2_input ; set flag for analog
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
349
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
350 restart4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
351 bsf lv_core ; default to low voltage core
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
352 movlw 0x80 ; point to 0x1F780
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
353 movwf TBLPTRL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
354 movlw 0xF7
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
355 movwf TBLPTRH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
356 movlw 0x01
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
357 movwf TBLPTRU
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
358 TBLRD*+ ; read from 0x1F780
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
359 movlw 0x83 ; coding for low voltage core, part 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
360 cpfseq TABLAT ; equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
361 bra restart4a ; NO - no low voltage core then
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
362 movlw 0x81 ; point to 0x1F781
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
363 movwf TBLPTRL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
364 TBLRD*+ ; read from 0x1F781
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
365 movlw 0x94 ; coding for low voltage core, part 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
366 cpfseq TABLAT ; equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
367 restart4a:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
368 bcf lv_core ; NO - no low voltage core then
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
369
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
370
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
371 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
372
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
373 ; set TR functions as deactivated by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
374 bcf tr_functions_activated ; clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
375
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
376 ; search for TR module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
377 WAITMS .200 ; wait 200 ms while RX module boots up
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
378 call I2C_probe_OSTC_rx ; check for RX module and set ostc_rx_present flag if found
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
379 btfss ostc_rx_present ; RX module detected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
380 bra restart5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
381
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
382 ; check if TR module firmware is up to date
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
383 movff rx_firmware_cur_major,hi ; copy current firmware on RX module to bank common, major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
384 movff rx_firmware_cur_minor,lo ; copy current firmware on RX module to bank common, minor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
385 call rx_firmware_new_major ; get latest firmware version into WREG, major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
386 cpfseq hi ; equal to current firmware on RX module, major ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
387 bra restart4b ; NO - update
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
388 call rx_firmware_new_minor ; YES - get latest firmware version into WREG, minor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
389 cpfseq lo ; - equal to current firmware on RX module, minor ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
390 bra restart4b ; NO - update TR module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
391 bra restart4e ; YES - no need to update
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
392
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
393 restart4b:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
394 ; print TR module update message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
395 call TFT_boot ; initialize TFT (includes clear screen & backlight switch-off)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
396 WIN_TOP .40 ; show heinrichsweikamp logo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
397 WIN_LEFT .10
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
398 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
399 WIN_SMALL .10,.130
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
400 STRCAT_PRINT "Updating TR Module..." ; print update message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
401 call TFT_Display_FadeIn ; display screen
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
402 WIN_SMALL .10,.160
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
403 STRCAT "TR Update " ; prepare result message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
404
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
405 ; update firmware in RX module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
406 call I2C_sleep_accelerometer ; stop accelerometer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
407 call I2C_sleep_compass ; stop compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
408 call update_tr_module ; update TR module
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
409
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
410 WIN_SMALL .10,.160 ; set next output position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
411 STRCAT "Update " ; common part of result message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
412 btfss ostc_rx_present ; data transfer successful and TR module up & running again?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
413 bra restart4c ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
414 STRCAT "to " ; YES - print success message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
415 call TFT_print_firmware_rx ; - print installed version
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
416 STRCAT_PRINT " done" ; - complete result message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
417 bra restart4d ; - show message for a while
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
418
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
419 restart4c:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
420 STRCAT_PRINT "failed" ; complete result message - failure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
421
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
422 restart4d:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
423 call wait_1s ; wait (up to) 1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
424 call wait_1s ; wait (another full) 1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
425 call wait_1s ; wait (another full) 1 second
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
426
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
427 restart4e:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
428 btfss ostc_rx_present ; TR module up & running?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
429 bra restart5 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
430 movff opt_TR_mode,WREG ; YES - get TR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
431 tstfsz WREG ; - TR mode <> off ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
432 bsf tr_functions_activated ; YES - set TR functions as activated
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
433
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
434 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
435
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
436
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
437 restart5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
438 ; manage hardware
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
439 btfss analog_o2_input ; OSTC with analog input?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
440 bsf TRISB,3 ; NO - shut down power supply for S8 bulkhead
0
heinrichsweikamp
parents:
diff changeset
441
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
442 btfss battery_gauge_available ; OSTC with gauge IC?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
443 bsf TRISG,0 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
444
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
445 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
446
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
447 btfsc use_old_batt_flag ; shall reload last battery data?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
448 call get_battery_data ; YES - get last battery data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
449
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
450 ; set screen orientation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
451 bcf flip_screen ; set default screen orientation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
452 TSTOSC opt_flip_screen ; shall show screen outputs upside down? (=1: flip the screen)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
453 bsf flip_screen ; YES - set upside-down orientation
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
454
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
455 ; check if high-altitude mode is applicable
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
456 bcf high_altitude_mode ; disable high altitude mode by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
457 MOVII pressure_abs_ref, sub_a ; copy last surface pressure to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
458 MOVLI high_altitude_threshold+1,sub_b ; copy high-altitude threshold (880 mbar) + 1 to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
459 call cmpU16 ; sub_a - sub_b = pressure_abs_ref - (high_altitude_threshold + 1)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
460 btfsc neg_flag ; result negative (absolute pressure <= 880 mbar) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
461 bsf high_altitude_mode ; YES - enable high altitude mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
462
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
463 ; check if there was a cold start, if yes do initial computation of further deco data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
464 btfss cold_start ; did a cold start?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
465 bra restart6 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
466 bcf cold_start ; YES - clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
467 call deco_calc_dive_interval_1min ; - calculate tissues for 1 minute at surface conditions (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
468 call deco_calc_desaturation_time ; - calculate desaturation and no-fly/no-altitude time (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
469 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
470
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
471 restart6:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
472 ; the dive mode flag can not be set right after cold start, must have been in surface mode before
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
473 btfsc divemode ; shall enter dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
474 goto diveloop ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
475
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
476 btfsc RCON,POR ; was this a power-on reset?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
477 goto surfloop ; NO - enter surface mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
478 bsf RCON,POR ; YES - acknowledge detection and re-arm detector
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
479 goto do_new_battery_select ; - prompt for battery selection, will proceed to surface mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
480
0
heinrichsweikamp
parents:
diff changeset
481
heinrichsweikamp
parents:
diff changeset
482 ;=============================================================================
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
483 ; Setup all flags and parameters for dive mode and simulator computations
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
484 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
485 ; called from divemode.asm, menu_tree.asm and surfmode.asm
0
heinrichsweikamp
parents:
diff changeset
486 ;
heinrichsweikamp
parents:
diff changeset
487 global restart_set_modes_and_flags
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
488 restart_set_modes_and_flags:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
489 call option_restore_all ; restore all options settings from EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
490
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
491 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
492 call disable_ir_s8 ; switch off IR/S8 digital interface by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
493 ENDIF
24
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
494
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
495 ; setup sampling rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
496 movlw .2 ; default to 2 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
497 movwf sampling_rate ; write setting
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
498 TSTOSS opt_sampling_rate ; check option: 1= 10s, 0= 2s
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
499 bra restart_set_modes_and_flags1 ; 0 - 2 seconds selected, done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
500 movlw .10 ; 1 - change to 10 seconds
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
501 movwf sampling_rate ; - write setting
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
502
24
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
503 restart_set_modes_and_flags1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
504 clrf DM_flags_deco ; clear all deco mode flags
0
heinrichsweikamp
parents:
diff changeset
505
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
506 ; initialize active_gas and active_dil for surface mode pressure display
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
507 call get_first_gas_to_WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
508 movwf active_gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
509
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
510 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
511 call get_first_dil_to_WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
512 movwf active_dil
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
513 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
514
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
515 ; configure saturation / desaturation safety factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
516 movff opt_sat_multiplier_gf, char_I_saturation_multiplier ; use factors for GF mode by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
517 movff opt_desat_multiplier_gf,char_I_desaturation_multiplier ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
518 TSTOSC char_I_deco_model ; get deco model ZH-L16-GF (1) selected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
519 bra restart_set_modes_and_flags2 ; YES - keep them
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
520 movff opt_sat_multiplier_non_gf, char_I_saturation_multiplier ; NO - overwrite them with non-GF factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
521 movff opt_desat_multiplier_non_gf,char_I_desaturation_multiplier ; - ...
0
heinrichsweikamp
parents:
diff changeset
522
heinrichsweikamp
parents:
diff changeset
523 restart_set_modes_and_flags2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
524 ; configure GF settings, GF high is needed for color-coding the current GF (supersaturation) factor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
525 movff opt_GF_low, char_I_GF_Low_percentage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
526 movff opt_GF_high,char_I_GF_High_percentage
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
527
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
528 movff opt_dive_mode,lo ; get dive mode: 0= OC, 1= CCR, 2= gauge, 3= apnea, 4= pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
529 tstfsz lo ; OC?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
530 bra restart_set_modes_and_flags3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
531 bsf FLAG_oc_mode ; YES - set OC flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
532 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
533 call option_cleanup_oTrMode_no_CCR ; - revert TR mode from 'CCR Dil+O2' to 'on'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
534 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
535 return ; - done
0
heinrichsweikamp
parents:
diff changeset
536
heinrichsweikamp
parents:
diff changeset
537 restart_set_modes_and_flags3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
538 decfsz lo,F ; CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
539 bra restart_set_modes_and_flags4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
540 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
541 bsf FLAG_ccr_mode ; YES - set CCR flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
542 call option_cleanup_oCCRMode_CCR ; - revert CCR mode 'Sensor' to 'fixed SP' if no sensor interface available
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
543 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
544 call option_cleanup_oTrMode_CCR ; - revert TR mode from 'ind.double' to 'on'
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
545 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
546 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
547 call enable_ir_s8 ; - enable IR/S8 digital interface
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
548 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
549 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
550 return ; - done
0
heinrichsweikamp
parents:
diff changeset
551
heinrichsweikamp
parents:
diff changeset
552 restart_set_modes_and_flags4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
553 decfsz lo,F ; Gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
554 bra restart_set_modes_and_flags5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
555 bsf FLAG_gauge_mode ; YES - set gauge flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
556 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
557 call option_cleanup_oTrMode_no_CCR ; - revert TR mode from 'CCR Dil+O2' to 'on'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
558 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
559 return ; - done
0
heinrichsweikamp
parents:
diff changeset
560
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
561 restart_set_modes_and_flags5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
562 decfsz lo,F ; Apnea mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
563 bra restart_set_modes_and_flags6 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
564 bsf FLAG_apnoe_mode ; YES - set apnea flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
565 movlw samplingrate_apnoe ; get apnoe sampling rate
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
566 movwf sampling_rate ; overwrite user-selected 2/10 seconds setting with apnoe default
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
567 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
568 call option_cleanup_oTrMode_no_CCR ; - revert TR mode from 'CCR Dil+O2' to 'on'
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
569 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
570 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
571
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
572 restart_set_modes_and_flags6:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
573 ; pSCR mode then
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
574 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
575 bsf FLAG_pscr_mode ; - set pSCR mode flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
576 call option_cleanup_oCCRMode_pSCR ; - revert AutoSP to calculated SP, additionally revert Sensor to fixed SP if no sensor interface available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
577 IFDEF _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
578 call option_cleanup_oTrMode_no_CCR ; - revert TR mode from 'CCR Dil+O2' to 'on'
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
579 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
580 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
581 call enable_ir_s8 ; - enable IR/S8 digital interface
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
582 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
583 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
584 return ; - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 545
diff changeset
585
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
586
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
587 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
588 ; Sample and store the current surface pressure, update ISR and deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
589 ; with the surface pressure sampled on last invocation.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
590 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
591 global sample_surface_pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
592 sample_surface_pressure:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
593 ; make sure the ISR does not read the surface pressure reference buffer while it is updated
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
594 bcf update_surface_pressure ; cancel any pending load request
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
595
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
596 ; propagate the surface pressure sampled on last invocation to the reference pressure buffer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
597 MOVII pressure_abs_sampled,pressure_abs_ref
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
598
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
599 ; update surface pressure in the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
600 bsf update_surface_pressure ; request ISR to update its surface pressure
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
601
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
602 ; update surface pressure in the deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
603 MOVII pressure_abs_ref,int_I_pres_surface
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
604
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
605 ; sample current absolute pressure (ISR-safe 2 byte copy)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
606 SMOVII pressure_abs,pressure_abs_sampled
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
607
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
608 ; limit sampled pressure to max allowed surface pressure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
609 MOVLI max_surfpressure, sub_a ; load upper limit into sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
610 MOVII pressure_abs_sampled,sub_b ; copy sampled pressure to sub_b
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
611 call cmpU16 ; sub_a - sub_b = max_surfpressure - pressure_abs_sampled
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
612 btfss neg_flag ; sampled pressure > max_surfpressure ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
613 return ; NO - below limit, done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
614 MOVII sub_a,pressure_abs_sampled ; YES - limit to max_surfpressure (still stored in sub_a)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
615 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
616
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
617
0
heinrichsweikamp
parents:
diff changeset
618 END