annotate src/start.asm @ 641:1212d39c9f6f

3.14 beta work
author heinrichsweikamp
date Sat, 21 Nov 2020 17:46:29 +0100
parents 8c1f1f334275
children 7d8a4c60ec1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
3 ; File start.asm * combined next generation V3.11.1
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
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
31 extern backup_flash_page
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
32 extern eeprom_deco_data_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
33 extern option_restore_and_check_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
34 extern option_restore_and_check
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
35 extern option_check_and_store_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
36 extern option_check_and_store
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
37 extern option_reset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
38 extern rtc_init
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
39 extern 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
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
44 extern oFirmwareMajor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
45 extern oFirmwareMinor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
46 extern oPressureAdjust
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
47
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
48 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
49 extern option_cleanup_oCCRMode_pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
50 extern option_cleanup_oCCRMode_CCR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
51 extern get_first_dil_to_WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
52 ENDIF
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
53
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
54 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
55 extern option_cleanup_oTrMode_CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
56 extern option_cleanup_oTrMode_no_CCR
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
57 ENDIF
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
58
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
59 IFDEF _rx_update
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
60 extern rx_firmware_new_major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
61 extern rx_firmware_new_minor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
62 extern dyn_show_firmware_rx
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
63 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
64
0
heinrichsweikamp
parents:
diff changeset
65
heinrichsweikamp
parents:
diff changeset
66 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
67 ; Reset Vector: Entry Point on Device Wake-up and hard Reset
0
heinrichsweikamp
parents:
diff changeset
68 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
69 reset_v CODE 0x00000
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
70 goto 0x1FF00 ; jump to bootloader
0
heinrichsweikamp
parents:
diff changeset
71
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
72 start_v CODE 0x00004 ; jump to application (cold-)start
0
heinrichsweikamp
parents:
diff changeset
73 goto start
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
74 ;
0
heinrichsweikamp
parents:
diff changeset
75 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
76
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
77
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
78 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
79 ; Firmware Identification
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
80 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
81 fingerprint CODE 0x0000A
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
82 db fw_version_major, fw_version_minor ; major, minor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
83 db fw_version_beta, FW_ID ; beta/release, firmware ID
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
84 db firmware_creation_year, firmware_creation_month ; creation year, month
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
85 db firmware_creation_day, FW_CONF ; creation day, firmware configuration
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
86 db 0x00, 0x00 ; reserved for future use
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
87 db 0x00, 0x00 ; reserved for future use
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
88 db 0x00, 0x00 ; reserved for future use
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
89 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
90 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
91
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
92
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
93 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
94 boot1 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
95 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
96
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
97
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
98 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
99 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
100 ; Entry Point after cold Start
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
101 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
102 global start
0
heinrichsweikamp
parents:
diff changeset
103 start:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
104
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
105 ; clear RAM banks 0-14
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
106 lfsr FSR0,0x000 ; load start address into FSR0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
107 movlw 0x0F ; load end address into WREG (actually its high byte)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
108 start_clear_rambank:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
109 clrf POSTINC0 ; clear memory location and increment FSR0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
110 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
111 bra start_clear_rambank ; NO - loop
0
heinrichsweikamp
parents:
diff changeset
112
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
113 ; initialize averaging for analog buttons before IRQ gets enabled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
114 movlw .16 ; set averaging span
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
115 movff WREG,analog_counter ; write to counter (in bank isr_backup)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
116
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
117 ; initialize hardware (ports, timers) and start interrupts
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
118 call init_ostc ; also selects bank common and sets CPU to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
119
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
120 ; flag that later restart origins from a cold start
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
121 bsf cold_start
0
heinrichsweikamp
parents:
diff changeset
122
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
123 ; get button type from bootloader info
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
124 bsf analog_switches ; assume analog buttons by default
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
125 movlw 0x7C ; set up read from 0x01F77C
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
126 movwf TBLPTRL ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
127 movlw 0xF7 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
128 movwf TBLPTRH ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
129 movlw 0x01 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
130 movwf TBLPTRU ; ...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
131 TBLRD*+ ; read configuration byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
132 movlw 0x07 ; coding for analog buttons
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
133 cpfseq TABLAT ; equal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
134 bcf analog_switches ; NO - no analog buttons
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
135
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
136 ; get screen type (2) from bootloader info
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
137 bsf screen_type2 ; set flags for later clear of the false one
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
138 bsf screen_type3 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
139 movlw 0x80 ; set up read from 0x01F780
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
140 movwf TBLPTRL ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
141 ;movlw 0xF7 ; high and upper are still at 0x01F7xx
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
142 ;movwf TBLPTRH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
143 ;movlw 0x01 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
144 ;movwf TBLPTRU ; ...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
145 TBLRD*+ ; read configuration byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
146 movlw 0x83 ; coding for screen type 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
147 cpfseq TABLAT ; equal?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
148 bcf screen_type2 ; NO - not screen type 2
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
149 movlw 0x84 ; coding for screen type 3
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
150 cpfseq TABLAT ; equal?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
151 bcf screen_type3 ; NO - not screen type 3
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
152
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
153 ; get button polarity from configuration data (EEPROM)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
154 EEPROM_CC_READ eeprom_button_polarity,button_polarity
475
237afdfb4918 2.12 release candidate...
heinrichsweikamp
parents: 474
diff changeset
155
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
156 ; initialize pressure sensor calibration
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
157 call get_calibration_data ; get calibration data from pressure sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
158
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
159 call TFT_DisplayOff ; turn off display
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
160 bsf LEDr ; turn on red LED
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
161
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
162 ; wait for valid temperature and pressure
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
163 WAITS .3 ; wait 3 seconds
0
heinrichsweikamp
parents:
diff changeset
164
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
165 ; sensor calibration completed, first valid pressure value is available
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
166 bcf LEDr ; turn off red LED
0
heinrichsweikamp
parents:
diff changeset
167
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
168 ; initial loading of the surface pressure into the ISR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
169 ; needs to be done twice in order to shift the current absolute pressure through
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
170 ; the sampling buffer into the reference buffer from where it is loaded by the ISR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
171 call sample_surface_pressure ; 1st pass
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
172 call sample_surface_pressure ; 2nd pass
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
173
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
174 ; wait until initial surface pressure value has been loaded into the ISR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
175 btfsc update_surface_pressure ; has the ISR confirmed loading of the surface pressure?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
176 bra $-2 ; NO - not yet, loop until ISR has confirmed loading
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 545
diff changeset
177
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
178 ; reset all tissue pressures to surface pressure equilibrium state by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
179 call deco_clear_tissue ; (C-code)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
180 banksel common ; back to bank common
0
heinrichsweikamp
parents:
diff changeset
181
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
182 ; restore deco status from EEPROM (if possible)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
183 EEPROM_CC_READ eeprom_deco_data_validity,WREG ; read deco data validity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
184 xorlw DECO_DATA_VALID_TOKEN ; deco data valid?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
185 bnz start_clean ; NO - start "clean"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
186 EEPROM_CC_READ eeprom_deco_data_version,WREG ; YES - read deco data format version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
187 xorlw eeprom_vault_version ; - deco data format compatible?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
188 bnz start_clean ; NO - start "clean"
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
189 call eeprom_deco_data_read ; YES - restore deco data from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
190 bra start_common ; - continue with common part
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
191
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
192 start_clean:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
193 bsf reset_surface_interval ; request ISR to reset the surface interval timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
194 btfss RCON,POR ; was there a power outage ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
195 call rtc_init ; YES - initialize RTC to firmware creation date
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
196
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
197 start_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
198 ; check for power-on reset
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
199 btfsc RCON,POR ; was this a power-on reset?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
200 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
201
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
202 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
203 btfsc RCON,POR ; was this a power-on reset?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
204 bsf use_old_batt_flag ; NO - reload last battery data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
205
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
206 call lt2942_get_status ; check for gauge IC
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
207 btfss battery_gauge_available ; cR or 2 hardware?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
208 bra start_check_new_firmware ; NO - skip next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
209 movlw .30 ; YES - load default button sensitivity
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
210 movff WREG,opt_cR_button_right ; - set default for left button
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
211 movff WREG,opt_cR_button_left ; - set default for right button
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
212 call piezo_config ; - configure buttons, 1st pass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
213 call piezo_config ; - configure buttons, 2nd pass
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
214
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
215 start_check_new_firmware:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
216 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
217
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
218 ; show heinrichsweikamp logo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
219 WIN_TOP .40
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
220 WIN_LEFT .10
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
221 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
222
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
223 ; check if a new firmware was loaded
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
224 lfsr FSR0,oFirmwareMajor ; address firmware version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
225 call option_restore_and_check ; read firmware version, major
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
226 call option_restore_and_check ; read firmware version, minor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
227 call option_restore_and_check ; read firmware version, beta
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
228
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
229 movff opt_fw_version_major,WREG ; get stored major version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
230 xorlw fw_version_major ; compare with currently active version, equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
231 bnz start_check_new_firmware_new ; NO - a new firmware was loaded
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
232
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
233 movff opt_fw_version_minor,WREG ; get stored minor version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
234 xorlw fw_version_minor ; compare with currently active version, equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
235 bnz start_check_new_firmware_new ; NO - a new firmware was loaded
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
236
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
237 movff opt_fw_version_beta,WREG ; get stored beta version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
238 xorlw fw_version_beta ; compare with currently active version, equal?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
239 bnz start_check_new_firmware_new ; NO - a new firmware was loaded
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
240 ;bz start_check_new_firmware_old ; YES - same firmware as before
0
heinrichsweikamp
parents:
diff changeset
241
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
242 start_check_new_firmware_old:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
243 call TFT_message_fw_kept ; show firmware is kept message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
244 bra start_check_new_firmware_common ; continue with common part
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
245
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
246 start_check_new_firmware_new:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
247 call TFT_message_fw_update ; show firmware is updated message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
248
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
249 ; ; reset the pressure sensor correction to factory default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
250 ; lfsr FSR0,oPressureAdjust ; address pressure sensor correction
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
251 ; call option_reset ; set correction to default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
252 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
253 ; lfsr FSR0,oPressureAdjust ; address pressure sensor correction
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
254 ; call option_check_and_store ; update correction in EEPROM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
255
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
256 start_check_new_firmware_common:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
257 call TFT_Display_FadeIn ; display resulting screen
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
258
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
259 call backup_flash_page ; back-up the first 128 bytes from program flash memory to EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
260 call option_restore_and_check_all ; restore all option values from EEPROM and check them
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
261
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
262 WAITS .5 ; wait 5 second
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
263
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
264 goto restart ; proceed with restart
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
265
0
heinrichsweikamp
parents:
diff changeset
266
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
267 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
268 boot2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
269 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
270
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
271
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
272 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
273 ; Sample and store the current Surface Pressure
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
274 ; Update ISR and Deco Engine with Pressure sampled on last Invocation
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
275 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
276 global sample_surface_pressure
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
277 sample_surface_pressure:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
278 ; make sure the ISR does not read the surface pressure reference buffer while it is updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
279 bcf update_surface_pressure ; cancel any pending load request
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
280
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
281 ; propagate the surface pressure sampled on last invocation to the reference pressure buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
282 MOVII pressure_abs_sampled,pressure_abs_ref
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
283
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
284 ; update surface pressure in the ISR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
285 bsf update_surface_pressure ; request ISR to update its surface pressure
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
286
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
287 ; update surface pressure in the deco engine
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
288 MOVII pressure_abs_ref,int_I_pres_surface
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
289
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
290 ; sample current absolute pressure (ISR-safe 2 byte copy)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
291 SMOVII pressure_abs,pressure_abs_sampled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
292
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
293 ; limit sampled pressure to max allowed surface pressure
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
294 MOVLI max_surfpressure, sub_a ; load upper limit into sub_a
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
295 MOVII pressure_abs_sampled,sub_b ; copy sampled pressure to sub_b
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
296 call cmpU16 ; sub_a - sub_b = max_surfpressure - pressure_abs_sampled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
297 btfss neg_flag ; sampled pressure > max_surfpressure ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
298 return ; NO - below limit, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
299 MOVII sub_a,pressure_abs_sampled ; YES - limit to max_surfpressure (still stored in sub_a)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
300 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
301
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
302
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
303 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
304 boot3 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
305 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
306
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
307
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
308 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
309 ; Entry Point for warm Start
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
310 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
311 ; called on leaving sleep mode, surface menu, communication mode, and
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
312 ; when a start of a dive is detected in all modes except surface mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
313 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
314 global restart
0
heinrichsweikamp
parents:
diff changeset
315 restart:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
316
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
317 ; for safety purpose only
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
318 banksel common ; select bank common
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
319 clrf STKPTR ; clear return addresses stack
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
320 call request_speed_normal ; request CPU speed change to normal speed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
321
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
322 bsf tft_is_dimming ; ignore ambient sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
323
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
324 ; clear flag groups
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
325 clrf HW_descriptor ; hardware - OSTC model descriptor
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
326 clrf HW_flags_state1 ; hardware - states
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
327 ; ; DO NOT clear HW_flags_state2 !
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
328 clrf DM_flags_sensor ; hardware - O2 sensors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
329 clrf OS_flags_ISR1 ; operating system - ISR control 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
330 clrf OS_flags_ISR2 ; operating system - ISR control 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
331 clrf eventbase ; event triggers generated by ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
332 clrf DM_flags_deco ; dive deco modes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
333 clrf MS_flags_control ; menu system - control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
334 clrf MS_flags_imprint ; menu system - data imprinting
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
335 clrf CVT_flags1 ; control of numerical outputs 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
336 clrf CVT_flags2 ; control of numerical outputs 2
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
337
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
338 ; 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
339 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
340 bsf ambient_sensor ; set ambient light sensor as available by default
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
341 bsf ext_input_optical ; set optical input as available by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
342
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
343 call lt2942_get_status ; check for gauge IC
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
344 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
345 bra restart2 ; NO
236
e2ea74646127 configure hardware_flag byte
heinrichsweikamp
parents: 235
diff changeset
346
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
347 ; OSTC 2, cR or TR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
348 call lt2942_init ; initialize battery gauge IC
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
349 bcf ext_input_optical ; OSTC 2, cR and TR do not have an optical input
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
350
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
351 banksel ANCON0 ; ANCON0 is outside access RAM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
352 bcf ANCON0,7 ; AN7 digital input
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
353 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
354 bcf lightsen_power ; power-down ambient light sensor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
355 bcf ambient_sensor ; no ambient light sensor by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
356 nop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
357 btfss PORTF,2 ; ambient light sensor available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
358 bsf ambient_sensor ; YES
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
359 banksel ANCON0 ; ANCON0 is outside access RAM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
360 bsf ANCON0,7 ; AN7 analog again
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
361 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
362 bsf lightsen_power ; power-up ambient light sensor again
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
363
243
ee81f46714cb auto-select correct settings menu
heinrichsweikamp
parents: 236
diff changeset
364 restart2:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
365 IFNDEF _hwos_sport
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
366 btfsc vusb_in ; USB power detected?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
367 bra restart3 ; YES - no BT then
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
368 bcf PORTE,0 ; NO - power up BT chip (if available)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
369 WAITMS d'5' ; - wait 5 ms
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
370 btfss vusb_in ; - BT chip detected?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
371 bra restart3 ; NO - no BT then
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
372 ENDIF
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
373 bsf ble_available ; YES - BT available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
374
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
375 restart3:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
376 bsf PORTE,0 ; power down BT chip
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
377 btfsc ble_available ; BT available?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
378 bra restart4 ; YES - can't be a cR then
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
379 btfss battery_gauge_available ; NO - rechargeable?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
380 bra restart4 ; NO - can't be a cR
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
381 bsf ext_input_s8_ana ; YES - it's a cR, S8/analog sensor input available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
382
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
383 restart4:
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
384 ; Do the check for BLE-cR
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
385 IFDEF _external_sensor
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
386 bsf mcp_power ; power-up instrumentation amp (used by S8 and analog input)
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
387 banksel BAUDCON2 ; select bank for IO register access
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
388 movlw b'00000000' ; speed generator configuration: BRG16=0, normal for S8
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
389 movwf BAUDCON2 ; ...
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
390 movlw b'00100000' ; TX configuration: BRGH=0, SYNC=0
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
391 movwf TXSTA2 ; ...
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
392 movlw .25 ; speed configuration: SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
393 movwf SPBRG2 ; ...
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
394 movlw b'10010000' ; RX configuration
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
395 movwf RCSTA2 ; ...
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
396 banksel common ; back to bank common
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
397 call get_analog_inputs
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
398 movff sensor1_mv+1,lo
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
399 movlw .58 ; ~ >1,500V
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
400 cpfslt lo ; >58 on the high byte -> confident that there is cR circuity
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
401 bsf ext_input_s8_ana ; YES - it's a cR, S8/analog sensor input available
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
402 call disable_ir_s8_analog ; power-down circuity again
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
403 ENDIF
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
404 bsf lv_core ; default to low voltage core
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
405 movlw 0x80 ; point to 0x1F780
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
406 movwf TBLPTRL ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
407 movlw 0xF7 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
408 movwf TBLPTRH ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
409 movlw 0x01 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
410 movwf TBLPTRU ; ...
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
411 TBLRD*+ ; read from 0x1F780
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
412 movlw 0x83 ; coding for low voltage core, part 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
413 cpfseq TABLAT ; equal?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
414 bra restart4a ; NO - no low voltage core then
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
415 movlw 0x81 ; YES - point to 0x1F781
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
416 movwf TBLPTRL ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
417 TBLRD*+ ; - read from 0x1F781
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
418 movlw 0x94 ; - coding for low voltage core, part 2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
419 cpfseq TABLAT ; - equal?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
420 restart4a:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
421 bcf lv_core ; NO - no low voltage core then
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
422
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
423 ; OSTC sport 2019 hardware does not have an optical input
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
424 btfsc lv_core ; low voltage core?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
425 bcf ext_input_optical ; YES - no optical input available
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
426 btfsc lv_core ; low voltage core?
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
427 bcf ext_input_s8_ana ; YES - can't be a cR, S8/analog sensor input disabled
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
428
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
429 ; check FLASH for block-write capability
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
430 bsf flash_block_write ; default to block-write capability available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
431 call ext_flash_read_jedec ; read JEDEC IDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
432 movlw 0x26 ; device type 26h supports block-write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
433 cpfseq hi ; dive type = 26h ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
434 bcf flash_block_write ; NO - revoke capability
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
435
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
436
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
437 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
438
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
439 ; set TR functions as deactivated by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
440 bcf tr_functions_activated ; clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
441
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
442 ; search for TR module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
443 WAITMS .200 ; wait 200 ms while RX module boots up
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
444 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
445 btfss ostc_rx_present ; RX module detected?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
446 bra restart5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
447
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
448 IFDEF _rx_update
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
449
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
450 ; check if TR module firmware is up to date
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
451 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
452 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
453 call rx_firmware_new_major ; get latest firmware version into WREG, major
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
454 cpfseq hi ; equal to current firmware on RX module, major ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
455 bra restart4b ; NO - update
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
456 call rx_firmware_new_minor ; YES - get latest firmware version into WREG, minor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
457 cpfseq lo ; - equal to current firmware on RX module, minor ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
458 bra restart4b ; NO - update TR module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
459 bra restart4e ; YES - no need to update
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
460
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
461 restart4b:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
462 ; print TR module update message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
463 call TFT_boot ; initialize TFT (includes clear screen & backlight switch-off)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
464 WIN_TOP .40 ; set position
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
465 WIN_LEFT .10 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
466 TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block ; show heinrichsweikamp logo
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
467 WIN_SMALL .10,.130 ; set position
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
468 STRCAT_PRINT "Updating TR Module..." ; print update message
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
469 call TFT_Display_FadeIn ; dimm up backlight to show outputs
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
470
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
471 ; update firmware in RX module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
472 call I2C_sleep_compass ; stop compass
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
473 call update_tr_module ; update TR module
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
474
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
475 WIN_SMALL .10,.160 ; set next output position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
476 STRCAT "Update " ; common part of result message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
477 btfss ostc_rx_present ; data transfer successful and TR module up & running again?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
478 bra restart4c ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
479 STRCAT "to " ; YES - print success message
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
480 call dyn_show_firmware_rx ; - print installed version
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
481 STRCAT_PRINT " done" ; - complete result message
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
482 bra restart4d ; - show message for a while
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
483
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
484 restart4c:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
485 STRCAT_PRINT "failed" ; complete result message - failure
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
486
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
487 restart4d:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
488 WAITS .3 ; wait 3 seconds
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
489
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
490 ENDIF ; _rx_update
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
491
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
492 restart4e:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
493 btfss ostc_rx_present ; TR module up & running?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
494 bra restart5 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
495 movff opt_TR_mode,WREG ; YES - get TR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
496 tstfsz WREG ; - TR mode <> off ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
497 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
498
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
499 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
500
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
501
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
502 restart5:
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
503 ; configure button_hold_down_allowed flag
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
504 btfsc lv_core
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
505 bsf button_hold_down_allowed,A ; OSTC sport mod. 2019
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
506 btfsc ext_input_optical
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
507 bsf button_hold_down_allowed,A ; OSTC3/old sport
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
508
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
509 ; manage hardware
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
510 btfss ext_input_s8_ana ; OSTC with S8/analog input?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
511 bsf TRISB,3 ; NO - shut down power supply for S8 bulkhead
0
heinrichsweikamp
parents:
diff changeset
512
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
513 btfss battery_gauge_available ; OSTC with gauge IC?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
514 bsf TRISG,0 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
515
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
516 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
517
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
518 btfsc use_old_batt_flag ; shall reload last battery data?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
519 call get_battery_data ; YES - get last battery data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
520
633
690c48db7b5b 3.09 beta 2 release
heinrichsweikamp
parents: 631
diff changeset
521 ; check if option values have changed and thus if the EEPROM needs to be updated
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
522 btfsc option_changed ; do the options need to be stored to EEPROM ?
633
690c48db7b5b 3.09 beta 2 release
heinrichsweikamp
parents: 631
diff changeset
523 call option_check_and_store_all ; YES - check and store all option values in EEPROM
690c48db7b5b 3.09 beta 2 release
heinrichsweikamp
parents: 631
diff changeset
524
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
525 ; set screen orientation
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
526 bcf flip_screen ; disable upside-down orientation by default
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
527 TSTOSC opt_flip_screen ; shall show screen outputs upside down? (=1: flip the screen)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
528 bsf flip_screen ; YES - enable upside-down orientation
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
529
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
530 ; check if high-altitude mode is applicable
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
531 bcf high_altitude_mode ; disable high altitude mode by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
532 MOVII pressure_abs_ref, sub_a ; copy last surface pressure to sub_a
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
533 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
534 call cmpU16 ; sub_a - sub_b = pressure_abs_ref - (high_altitude_threshold + 1)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
535 btfsc neg_flag ; result negative (absolute pressure <= 880 mbar) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
536 bsf high_altitude_mode ; YES - enable high altitude mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
537
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
538 ; 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
539 btfss cold_start ; did a cold start?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
540 bra restart6 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
541 bcf cold_start ; YES - clear flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
542 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
543 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
544 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
545
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
546 restart6:
640
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
547 btfsc ext_input_s8_ana ; analog sensor input available?
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
548 bra restart7 ; Yes, continue
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
549 ; no sensors, reconfigure TRIS and ANSEL bits for AN8
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
550 bcf TRISF,3
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
551 banksel 0xF16 ; addresses F16h ... F5Fh are not part of the access RAM
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
552 bcf ANCON1,0 ; ANSEL1: AN8 -> no analog input
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
553 banksel common ; back to bank common
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
554
8c1f1f334275 3.13 release
heinrichsweikamp
parents: 634
diff changeset
555 restart7:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
556 btfsc divemode ; shall enter dive mode?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
557 goto diveloop ; YES - enter dive mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
558 btfsc RCON,POR ; NO - was this a power-on reset?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
559 goto surfloop ; NO - enter surface mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
560 bsf RCON,POR ; YES - acknowledge detection and re-arm detector
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
561 goto new_battery_select ; - prompt for battery selection, will proceed to surface mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
562
0
heinrichsweikamp
parents:
diff changeset
563
heinrichsweikamp
parents:
diff changeset
564 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
565 boot4 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
566 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
567
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
568 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
569 ; Setup of all Flags and Parameters for Dive Mode and Simulator Computations
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
570 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
571 ; called from divemode.asm, menu_tree.asm and surfmode.asm
0
heinrichsweikamp
parents:
diff changeset
572 ;
heinrichsweikamp
parents:
diff changeset
573 global restart_set_modes_and_flags
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
574 restart_set_modes_and_flags:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
575 call disable_ir_s8_analog ; switch off IR/S8/analog interface by default (for all compile versions!)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
576
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
577 IFDEF _external_sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
578 WAITMS d'100' ; wait 100 ms to S8-HUD powered down properly
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
579 ENDIF
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
580
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
581 ; setup sampling rate for dice data recording
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
582 movlw .2 ; default to 2 seconds
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
583 TSTOSC opt_sampling_rate ; check option: 0= 2s, 1= 10s
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
584 movlw .10 ; 1 - change to 10 seconds
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
585 movwf sampling_rate ; store selection
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
586
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
587 ; clear all deco mode flags
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
588 clrf DM_flags_deco
0
heinrichsweikamp
parents:
diff changeset
589
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
590 ; 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
591 call get_first_gas_to_WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
592 movwf active_gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
593
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
594 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
595 call get_first_dil_to_WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
596 movwf active_dil
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
597 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
598
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
599 ; configure saturation / desaturation safety factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
600 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
601 movff opt_desat_multiplier_gf,char_I_desaturation_multiplier ; ...
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
602 TSTOSC char_I_model ; get deco model ZH-L16-GF (1) selected?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
603 bra restart_set_modes_and_flags2 ; YES - keep them
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
604 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
605 movff opt_desat_multiplier_non_gf,char_I_desaturation_multiplier ; - ...
0
heinrichsweikamp
parents:
diff changeset
606
heinrichsweikamp
parents:
diff changeset
607 restart_set_modes_and_flags2:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
608
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
609 ; 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
610 movff opt_GF_low, char_I_GF_Low_percentage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
611 movff opt_GF_high,char_I_GF_High_percentage
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
612
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
613 ; dive mode specific setup
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
614 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
615 tstfsz lo ; OC?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
616 bra restart_set_modes_and_flags3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
617 bsf FLAG_oc_mode ; YES - set OC flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
618 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
619 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
620 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
621 return ; - done
0
heinrichsweikamp
parents:
diff changeset
622
heinrichsweikamp
parents:
diff changeset
623 restart_set_modes_and_flags3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
624 decfsz lo,F ; CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
625 bra restart_set_modes_and_flags4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
626 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
627 bsf FLAG_ccr_mode ; YES - set CCR flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
628 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
629 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
630 call option_cleanup_oTrMode_CCR ; - revert TR mode from 'ind.double' to 'on'
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
631 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
632 IFDEF _external_sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
633 call enable_ir_s8_analog ; - enable IR/S8/analog interface
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
634 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
635 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
636 return ; - done
0
heinrichsweikamp
parents:
diff changeset
637
heinrichsweikamp
parents:
diff changeset
638 restart_set_modes_and_flags4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
639 decfsz lo,F ; Gauge mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
640 bra restart_set_modes_and_flags5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
641 bsf FLAG_gauge_mode ; YES - set gauge flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 592
diff changeset
642 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
643 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
644 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
645 return ; - done
0
heinrichsweikamp
parents:
diff changeset
646
480
ad8acade5567 NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents: 475
diff changeset
647 restart_set_modes_and_flags5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
648 decfsz lo,F ; Apnea mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
649 bra restart_set_modes_and_flags6 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
650 bsf FLAG_apnoe_mode ; YES - set apnea flag
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
651 movlw samplingrate_apnoe ; - get apnoe sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
652 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
653 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
654 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
655 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
656 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
657
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
658 restart_set_modes_and_flags6:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
659 ; pSCR mode then
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
660 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
661 bsf FLAG_pscr_mode ; - set pSCR mode flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
662 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
663 IFDEF _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
664 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
665 ENDIF ; _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
666 IFDEF _external_sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
667 call enable_ir_s8_analog ; - enable IR/S8/analog interface
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
668 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
669 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 615
diff changeset
670 return ; - done
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 545
diff changeset
671
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
672 ;-----------------------------------------------------------------------------
410
d3087a8ed7e1 BUGFIX: Fix rare issue after battery change (OSTC3 did not start properly)
heinrichsweikamp
parents: 375
diff changeset
673
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 633
diff changeset
674 END