annotate src/ghostwriter.asm @ 637:cdff88f5a4a0

Battery menu for OSTC plus
author heinrichsweikamp
date Sun, 17 May 2020 09:34:18 +0200
parents 4050675965ea
children 75e90cd0c2c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
3 ; File ghostwriter.asm * combined next generation V3.09.4k
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Ghostwriter (Log profile recorder)
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-11-27 : [mH] Creation
heinrichsweikamp
parents:
diff changeset
11
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
12 #include "hwos.inc" ; Mandatory header
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
14 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
15 #include "surfmode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
16 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
17 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
18 #include "tft_outputs.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
19 #include "divemode.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
20 #include "rtc.inc"
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
21 #include "logbook.inc"
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
22 #include "convert.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
23
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
24
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
25 extern deco_pull_tissues_from_vault
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
26
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
27
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
28 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
29 ; Macros - write PROFILE Data to FLASH (all macros are bank-safe)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
30
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
31 FLASH_LIT_PROFILE macro literal ; write 1 byte LITERAL to FLASH profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
32 movlw literal
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
33 rcall ghostwrite_WREG_profile_exec
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
34 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
35
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
36 FLASH_WREG_PROFILE macro ; write 1 byte from WREG to FLASH profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
37 rcall ghostwrite_WREG_profile_exec
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
38 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
39
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
40 FLASH_CC_PROFILE macro memory_address ; write 1 byte from memory to FLASH profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
41 MOVCC memory_address,WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
42 rcall ghostwrite_WREG_profile_exec
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
43 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
44
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
45 FLASH_II_PROFILE macro memory_address ; write 2 byte from memory to FLASH profile data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
46 lfsr FSR0,memory_address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
47 rcall ghostwrite_II_profile_exec
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
48 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
49
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
50
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
51 ;-----------------------------------------------------------------------------
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
52 ; private local Variables
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
53
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
54 CBLOCK local3 ; max size is 16 Byte !!!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
55 divisor_temperature ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
56 divisor_deco ; divisor used to time the sampling of dive data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
57 divisor_supersat ; divisor used to time the sampling of dive data
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
58 divisor_ppo2_sensors ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
59 divisor_decoplan ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
60 divisor_cns ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
61 divisor_tank ; divisor used to time the sampling of dive data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
62 ProfileFlagByte ; used to store events
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
63 ENDC ; used: 8 byte, remaining: 8 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
64
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
65
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
66 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
67 ghostwrite1 CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
68 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
69
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
70 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
71 ; prepare Data Recording
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
72 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
73 global init_recording_params ; initialize profile recording parameters
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
74 init_recording_params:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
75 movlw div_temperature ; get divisor for temperature storage
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
76 movwf divisor_temperature ; initialize divisor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
77
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
78 movlw div_deco ; get divisor for deco status
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
79 movwf divisor_deco ; initialize divisor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
80
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
81 movlw div_gf ; get divisor for saturation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
82 movwf divisor_supersat ; initialize divisor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
83
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
84 movlw div_decoplan ; get divisor for deco plan
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
85 movwf divisor_decoplan ; initialize divisor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
86
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
87 movlw div_cns ; get divisor for CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
88 movwf divisor_cns ; initialize divisor
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
89
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
90 IFDEF _rx_functions
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
91 clrf WREG ; default to no tank data logging
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
92 btfsc tr_functions_activated ; TR functions activated?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
93 movlw div_tank ; YES - get divisor for tank data
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
94 movwf divisor_tank ; initialize divisor
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
95 ENDIF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
96
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
97 IFDEF _external_sensor
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
98 movlw div_ppo2_sensors ; get divisor for ppO2 sensor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
99 movwf divisor_ppo2_sensors ; initialize divisor by default
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
100 btfsc FLAG_ccr_mode ; in CCR mode?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
101 bra init_recording_params_2 ; YES - keep divisor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
102 btfsc FLAG_pscr_mode ; NO - in pSCR mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
103 bra init_recording_params_2 ; YES - keep divisor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
104 clrf divisor_ppo2_sensors ; NO - clear divisor again
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
105 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
106
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
107 init_recording_params_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
108 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
109
0
heinrichsweikamp
parents:
diff changeset
110
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
111 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
112 ghostwrite2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
113 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
114
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
115 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116 ; sample and store a Set of Dive Data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
117 ;
0
heinrichsweikamp
parents:
diff changeset
118 global store_dive_data
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 535
diff changeset
119 store_dive_data:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
120 bcf trigger_sample_divedata ; clear flag
0
heinrichsweikamp
parents:
diff changeset
121
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
122 ifndef _DEBUG
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
123 ; In DEBUG compile, write simulated dives to logbook
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
124 btfsc sensor_override_active ; in simulator mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
125 return ; YES - no dive data stored in simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
126 endif
0
heinrichsweikamp
parents:
diff changeset
127
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
128 btfss FLAG_apnoe_mode ; in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
129 bra store_dive_data_1 ; NO - proceed
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
130 TSTOSS opt_store_apnoe ; YES - logging in apnoe mode enabled?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
131 return ; NO - done
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
132
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
133 store_dive_data_1:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
134 ; store depth with every sample
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
135 MOVII pressure_rel_cur_cached,mpr ; copy current relative pressure to MPR
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
136 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
137 FLASH_II_PROFILE mpr ; store depth
0
heinrichsweikamp
parents:
diff changeset
138
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
139 ; first, find out how many bytes will be appended to this sample set
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
140 clrf ProfileFlagByte ; start with no bytes to append
0
heinrichsweikamp
parents:
diff changeset
141
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
142 ; check extended information
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
143 decfsz divisor_temperature,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
144 bra check_extended1 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
145 movlw infolength_temperature ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
146 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
147 check_extended1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
148 decfsz divisor_deco,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
149 bra check_extended2 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
150 movlw infolength_deco ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
151 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
152 check_extended2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
153 decfsz divisor_supersat,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
154 bra check_extended3 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
155 movlw infolength_gf ; YES - get length of extra data
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
156 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
157 check_extended3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
158 IFDEF _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
159 decfsz divisor_ppo2_sensors,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
160 bra check_extended4 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
161 movlw infolength_ppo2_sensors ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
162 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
163 ENDIF
0
heinrichsweikamp
parents:
diff changeset
164 check_extended4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
165 decfsz divisor_decoplan,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
166 bra check_extended5 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
167 movlw infolength_decoplan ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
168 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
169 check_extended5:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
170 decfsz divisor_cns,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
171 bra check_extended6 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
172 movlw infolength_cns ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
173 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
0
heinrichsweikamp
parents:
diff changeset
174 check_extended6:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
175 IFDEF _rx_functions
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
176 decfsz divisor_tank,W ; check divisor if it will become 0, dump decremented value to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
177 bra check_extended7 ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
178 movlw infolength_tank ; YES - get length of extra data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
179 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
180 ENDIF
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
181
0
heinrichsweikamp
parents:
diff changeset
182 check_extended7:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
183 ; second, check global event flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
184 btfss event_occured ; check global event flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
185 bra store_dive_data3 ; no event
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
186
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
187 incf ProfileFlagByte,F ; add one byte (the event byte 1)
0
heinrichsweikamp
parents:
diff changeset
188
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
189 clrf event_byte1 ; reset event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
190 clrf event_byte2 ; reset event byte 2
0
heinrichsweikamp
parents:
diff changeset
191
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
192 movf alarm_type,W ; type of alarm Bit 0-3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
193 addwf event_byte1,F ; copy to event byte 1, bit 0-3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
194 clrf alarm_type ; reset alarm type
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
195
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
196 ; third, check events and add additional bytes
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
197 btfss event_gas_change_gas6 ; did a change to gas 6 occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
198 bra check_event2 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
199 movlw d'2' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
200 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
201 bsf event_byte1,4 ; - set flag in event byte 1
0
heinrichsweikamp
parents:
diff changeset
202 check_event2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
203 btfss event_gas_change ; did a gas change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
204 bra check_event3 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
205 movlw d'1' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
206 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
207 bsf event_byte1,5 ; - set flag in event byte 1
0
heinrichsweikamp
parents:
diff changeset
208 check_event3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
209 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
210 btfss event_SP_change ; did a setpoint change occur?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
211 bra check_event4 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
212 movlw d'1' ; YES - set information length
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
213 addwf ProfileFlagByte,F ; - add to ProfileFlagByte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
214 bsf event_byte1,6 ; - set flag in event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
215 ENDIF
0
heinrichsweikamp
parents:
diff changeset
216 check_event4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
217 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
218 btfss event_bailout ; did a gas change due to bailout occur?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
219 bra check_event5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
220 movlw d'2' ; information length
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
221 addwf ProfileFlagByte,F ; add to ProfileFlagByte
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
222 bsf event_byte2,0 ; set flag in event byte 2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
223 bsf event_byte1,7 ; =1: another event byte is available
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
224 ENDIF
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
225
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
226 check_event5:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
227 ; more events in future time...
0
heinrichsweikamp
parents:
diff changeset
228
heinrichsweikamp
parents:
diff changeset
229 store_dive_data3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
230 btfsc event_byte1,7 ; is another event byte available?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
231 incf ProfileFlagByte,F ; YES - add one byte (the event byte 2)
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
232
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
233 btfsc event_occured ; global event flag set?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
234 bsf ProfileFlagByte,7 ; YES - set event byte 1 flag in ProfileFlagByte
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
235
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
236 FLASH_CC_PROFILE ProfileFlagByte ; store ProfileFlagByte
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
237
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
238 btfss event_occured ; global event flag set?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
239 bra store_dive_data4 ; NO - no events to store
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
240
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
241 ; store the EventByte(s) + additional bytes now
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
242 FLASH_CC_PROFILE event_byte1 ; store 1st event byte
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 97
diff changeset
243
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
244 btfss event_byte1,7 ; another event byte available?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
245 bra store_dive_data3a ; NO - skip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
246 FLASH_CC_PROFILE event_byte2 ; YES - store 2nd event byte
0
heinrichsweikamp
parents:
diff changeset
247
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
248 store_dive_data3a:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
249 btfss event_gas_change_gas6 ; did a change to gas 6 occur?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
250 bra store_dive_data3b ; NO - skip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
251 FLASH_CC_PROFILE char_I_O2_ratio ; YES - store gas 6 O2 ratio
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
252 IFDEF _helium
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
253 FLASH_CC_PROFILE char_I_He_ratio ; - store gas 6 He ratio
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
254 ELSE
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
255 FLASH_LIT_PROFILE .0 ; - store He ratio as zero
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
256 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
257 bcf event_gas_change_gas6 ; - clear event flag
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
258
0
heinrichsweikamp
parents:
diff changeset
259 store_dive_data3b:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
260 btfss event_gas_change ; did a gas change occur?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
261 bra store_dive_data3c ; NO - skip
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
262 IFDEF _ccr_pscr
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
263 movf active_dil,W ; YES - get active diluent by default
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
264 btfsc FLAG_oc_mode ; - in OC mode?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
265 movf active_gas,W ; YES - replace by active gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
266 btfsc bailout_mode ; - in bailout?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
267 ENDIF
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
268 movf active_gas,W ; (YES) - get (replace with) active OC (bailout) gas
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
269 FLASH_WREG_PROFILE ; - store active gas/diluent
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
270 bcf event_gas_change ; - clear event flag
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
271
0
heinrichsweikamp
parents:
diff changeset
272 store_dive_data3c:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
273 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
274 btfss event_SP_change ; did a setpoint change occur?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
275 bra store_dive_data3d ; NO - skip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
276 FLASH_CC_PROFILE char_I_const_ppO2 ; YES - store setpoint
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
277 bcf event_SP_change ; - clear event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
278 ENDIF
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
279
0
heinrichsweikamp
parents:
diff changeset
280 store_dive_data3d:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
281 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
282 btfss event_bailout ; did a gas change due to bailout occur?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
283 bra store_dive_data4 ; NO - skip
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
284 FLASH_CC_PROFILE char_I_O2_ratio ; YES - store O2 ratio of bailout gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
285 IFDEF _helium
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
286 FLASH_CC_PROFILE char_I_He_ratio ; - store He ratio of bailout gas
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
287 ELSE
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
288 FLASH_LIT_PROFILE .0 ; - store He ratio as zero
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
289 ENDIF ; helium
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
290 bcf event_bailout ; - clear event flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
291 ENDIF ; _ccr_pscr
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
292
0
heinrichsweikamp
parents:
diff changeset
293 store_dive_data4:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
294 ; Store extended information
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
295 decfsz divisor_temperature,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
296 bra store_dive_data4a ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
297 rcall store_dive_temperature ; YES - store temperature
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
298 store_dive_data4a:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
299 btfsc divisor_temperature,7 ; did the divisor under-run?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
300 clrf divisor_temperature ; YES - reset timer
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
301
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
302 decfsz divisor_deco,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
303 bra store_dive_data4b ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
304 rcall store_dive_decodata ; YES - store deco data
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
305 store_dive_data4b:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
306 btfsc divisor_deco,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
307 clrf divisor_deco ; YES - reset timer
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
308
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
309 decfsz divisor_supersat,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
310 bra store_dive_data4c ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
311 rcall store_dive_supersat ; YES - store supersaturation
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
312 store_dive_data4c:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
313 btfsc divisor_supersat,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
314 clrf divisor_supersat ; YES - reset timer
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
315
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
316 IFDEF _external_sensor
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
317 decfsz divisor_ppo2_sensors,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
318 bra store_dive_data4d ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
319 rcall store_dive_ppO2_sensors ; YES - store sensor data
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
320 store_dive_data4d:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
321 btfsc divisor_ppo2_sensors,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
322 clrf divisor_ppo2_sensors ; YES - reset timer
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
323 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
324
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
325 decfsz divisor_decoplan,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
326 bra store_dive_data4e ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
327 rcall store_dive_decoplan ; YES - store deco plan
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
328 store_dive_data4e:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
329 btfsc divisor_decoplan,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
330 clrf divisor_decoplan ; YES - reset timer
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
331
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
332 decfsz divisor_cns,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
333 bra store_dive_data4f ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
334 rcall store_dive_cns ; YES - store CNS
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
335 store_dive_data4f:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
336 btfsc divisor_cns,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
337 clrf divisor_cns ; YES - reset timer
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
338
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
339 IFDEF _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
340 decfsz divisor_tank,F ; decrement timer, did it became 0 ?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
341 bra store_dive_data4g ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
342 rcall store_dive_tank ; YES - store tank pressure
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
343 store_dive_data4g:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
344 btfsc divisor_tank,7 ; did the timer under-run?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
345 clrf divisor_tank ; YES - reset timer
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
346 ENDIF
0
heinrichsweikamp
parents:
diff changeset
347
heinrichsweikamp
parents:
diff changeset
348 store_dive_data5:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
349 bcf event_occured ; clear the global event flag
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
350 clrf event_byte1 ; reset event byte 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
351 clrf event_byte2 ; reset event byte 2
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
352 return ; done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
353
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
354
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
355 IFDEF _rx_functions
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
356 store_dive_tank:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
357 FLASH_II_PROFILE int_O_tank_pressure ; store tank pressure
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
358 movlw div_tank ; get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
359 movwf divisor_tank ; reload timer
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
360 return
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
361 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
362
0
heinrichsweikamp
parents:
diff changeset
363 store_dive_cns:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
364 MOVII int_O_CNS_current,mpr ; get current CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
365 bcf mpr+1,int_warning_flag ; clear warning flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
366 bcf mpr+1,int_attention_flag ; clear attention flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
367 FLASH_II_PROFILE mpr ; store CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
368 movlw div_cns ; get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
369 movwf divisor_cns ; reload timer
0
heinrichsweikamp
parents:
diff changeset
370 return
heinrichsweikamp
parents:
diff changeset
371
heinrichsweikamp
parents:
diff changeset
372 store_dive_decoplan:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
373 ; store the deco plan
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
374 lfsr FSR1,char_O_deco_time_for_log ; load base address of deco stop times table
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
375 movlw NUM_STOPS_LOG ; load size of deco stop times table
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
376 movwf lo ; copy size to loop counter
0
heinrichsweikamp
parents:
diff changeset
377 store_dive_decoplan_loop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
378 movf POSTINC1,W ; get a stop time
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
379 FLASH_WREG_PROFILE ; store it
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
380 decfsz lo,F ; decrement loop counter, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
381 bra store_dive_decoplan_loop ; NO - loop
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
382 movlw div_decoplan ; YES - get sampling rate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
383 movwf divisor_decoplan ; - reload timer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
384 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
385
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
386
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
387 IFDEF _external_sensor
0
heinrichsweikamp
parents:
diff changeset
388 store_dive_ppO2_sensors:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
389 FLASH_CC_PROFILE sensor1_ppO2 ; store sensor 1 ppO2 (in 0.01 bar steps)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
390 SMOVII sensor1_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
391 FLASH_II_PROFILE mpr ; store sensor 1 mV
0
heinrichsweikamp
parents:
diff changeset
392
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
393 FLASH_CC_PROFILE sensor2_ppO2 ; store sensor 2 ppO2 (in 0.01 bar steps)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
394 SMOVII sensor2_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
395 FLASH_II_PROFILE mpr ; store sensor 2 mV
0
heinrichsweikamp
parents:
diff changeset
396
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
397 FLASH_CC_PROFILE sensor3_ppO2 ; store sensor 3 ppO2 (in 0.01 bar steps)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
398 SMOVII sensor3_mv,mpr ; ISR-safe 2 byte copy of o2_mv_sensor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
399 FLASH_II_PROFILE mpr ; store sensor 3 mV
0
heinrichsweikamp
parents:
diff changeset
400
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
401 movlw div_ppo2_sensors ; get sampling rate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
402 movwf divisor_ppo2_sensors ; reload timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
403 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
404 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
405
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
406 store_dive_supersat:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
407 FLASH_CC_PROFILE int_O_lead_supersat+0 ; store leading tissue's supersaturation (value is limited to 255, only lower byte is used for the value)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
408 movlw div_gf ; get sampling rate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
409 movwf divisor_supersat ; reload timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
410 return ; done
0
heinrichsweikamp
parents:
diff changeset
411
heinrichsweikamp
parents:
diff changeset
412 store_dive_decodata:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
413 ; Check if deco stops are necessary
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
414 movff char_O_deco_depth,WREG ; get depth of the first stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
415 tstfsz WREG ; depth of first stop > 0 m (aka in deco) ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
416 bra store_dive_decodata_deco ; YES
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
417 ;bra store_dive_decodata_ndl ; NO
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
418
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
419 store_dive_decodata_ndl:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
420 FLASH_LIT_PROFILE .0 ; store depth of first stop as zero (encodes NDL dive)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
421 FLASH_CC_PROFILE int_O_NDL_norm+0 ; store NDL time from normal plan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
422 bra store_dive_decodata_common
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
423
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
424 store_dive_decodata_deco:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
425 FLASH_CC_PROFILE char_O_deco_depth ; store depth of the first stop in meters
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
426 FLASH_CC_PROFILE char_O_deco_time ; store duration of the first stop in minutes
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
427 ;bra store_dive_decodata_common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
428
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
429 store_dive_decodata_common:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
430 movlw div_deco ; get sampling rate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
431 movwf divisor_deco ; reload timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
432 return ; done
0
heinrichsweikamp
parents:
diff changeset
433
heinrichsweikamp
parents:
diff changeset
434 store_dive_temperature:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
435 SMOVII temperature_cur,mpr ; ISR-safe 2 byte copy of current temperature
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
436 FLASH_II_PROFILE mpr ; store temperature
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
437 movlw div_temperature ; get sampling rate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
438 movwf divisor_temperature ; reload timer
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
439 return ; done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
440
0
heinrichsweikamp
parents:
diff changeset
441
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
442 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
443 ; flash writing through the macros
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
444 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
445 ghostwrite_II_profile_exec:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
446 movf POSTINC0,W ; get byte into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 call ext_flash_write_byte_0x20_incdc ; write to external flash and increment ext_flash_dive_counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
448 movf POSTINC0,W ; get next byte into WREG
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
449 ghostwrite_WREG_profile_exec:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
450 goto ext_flash_write_byte_0x20_incdc ; write to external flash and increment ext_flash_dive_counter (and return)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
451 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
452 ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
heinrichsweikamp
parents:
diff changeset
453
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
454
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
455 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
456 ; finish Dive Data Recording and write Header
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
457 ;
0
heinrichsweikamp
parents:
diff changeset
458 global ghostwriter_end_dive
heinrichsweikamp
parents:
diff changeset
459 ghostwriter_end_dive:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
460 ; save end-of-profile pointer for later storage in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
461 MOVTT ext_flash_address,ext_flash_log_pointer
0
heinrichsweikamp
parents:
diff changeset
462
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
463 ; remember last custom view shown in dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
464 movff active_customview,customview_divemode
39
e4e91fe8b09d remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents: 35
diff changeset
465
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
466 ; reset gas/diluent lost & staged flags
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
467 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
468 IFDEF _ccr_pscr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
469 movlw 2*NUM_GAS ; load loop counter with number of gases + diluents = 2*5
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
470 ELSE
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
471 movlw NUM_GAS ; load loop counter with number of gases = 5
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
472 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
473 ghostwriter_end_dive_0:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
474 bcf INDF1,gas_lost ; clear lost flag and keep index at present gas/dil
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
475 bcf POSTINC1,gas_staged ; clear staged flag and advance index to next gas/dil
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
476 decfsz WREG ; decrement loop counter and check if it became zero
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
477 bra ghostwriter_end_dive_0 ; NO - not yet, loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
478
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
479 ; clear bailout state (if applicable)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
480 bcf bailout_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
481
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
482 ; check if dive is worth storage at all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
483 btfss divetime_longer_1min ; dive longer than one minute?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
484 goto ghostwriter_end_dive_common ; NO - discard everything
0
heinrichsweikamp
parents:
diff changeset
485
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
486 ifndef _DEBUG
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
487 ; in DEBUG compile, write simulated dives to logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
488 btfsc sensor_override_active ; in simulator mode?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
489 goto ghostwriter_end_dive_common ; YES - discard everything
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
490 endif
0
heinrichsweikamp
parents:
diff changeset
491
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
492 ; calculate desaturation time
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
493 call deco_calc_desaturation_time ; call the C-code
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
494 banksel common ; back to bank common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
495
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
496 ; condition apnoe mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
497 btfss FLAG_apnoe_mode ; are we in apnoe mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
498 bra ghostwriter_end_dive_00 ; NO - proceed
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
499 MOVII apnoe_max_pressure,pressure_rel_max_cached ; YES - get max pressure of all yoyo dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
500
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
501 ghostwriter_end_dive_00:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
502 ; compute max depth for storage and last dive statistics
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
503 MOVII pressure_rel_max_cached,mpr ; get max pressure
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
504 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
505 MOVII mpr,lastdive_maxdepth ; store for last dive statistics
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
506
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
507 ; compute avg depth for storage and last dive statistics
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
508 MOVII pressure_rel_avg_total,mpr ; get average pressure
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
509 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm]
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
510 MOVII mpr,lastdive_avgdepth ; store in last dive statistics
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
511
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
512 ; get dive duration for last dive statistics
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
513 SMOVTT counted_divetime_mins,lastdive_duration ; ISR-safe 3 byte copy of minutes:2 and seconds
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
514
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
515 ; check logging of apnoe mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
516 btfss FLAG_apnoe_mode ; are we in apnoe mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
517 bra ghostwriter_end_dive_1 ; NO - proceed
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
518 TSTOSS opt_store_apnoe ; YES - logging in apnoe mode enabled?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
519 goto ghostwriter_end_dive_cleanup ; NO - skip logging but do the after-dive cleanup
35
eca4a201d8cf change apnea timeout, do no longer store apnea dives in logbook
heinrichsweikamp
parents: 23
diff changeset
520
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
521 ghostwriter_end_dive_1:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
522
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
523 ;---- dive finished (and longer than one minute) -------------------------
0
heinrichsweikamp
parents:
diff changeset
524
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
525 ; close profile recording
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
526 FLASH_LIT_PROFILE 0xFD ; write end-of-profile code, byte 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
527 FLASH_LIT_PROFILE 0xFD ; write end-of-profile code, byte 2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
528
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
529 ; save end-of-profile pointer for later storage in header and EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
530 MOVTT ext_flash_address,ext_flash_log_pointer
0
heinrichsweikamp
parents:
diff changeset
531
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
532 ; go back again to start of profile data to store the profile length (number of recorded bytes)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
533 call ghostwriter_load_pointer
0
heinrichsweikamp
parents:
diff changeset
534
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
535 ; skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" header, i.e. the first 6 bytes
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
536 EXT_FLASH_INC_ADDRESS_0x20 d'6'
0
heinrichsweikamp
parents:
diff changeset
537
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
538 ; store dive length (NO ext_flash_length_counter increase, NO page delete)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
539 movf ext_flash_length_counter+0,W ; get length of profile data, low byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
540 call ext_flash_write_byte_0x20_nodel ; write to flash
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
541 movf ext_flash_length_counter+1,W ; get length of profile data, high byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
542 call ext_flash_write_byte_0x20_nodel ; write to flash
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
543 movf ext_flash_length_counter+2,W ; get length of profile data, upper byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
544 call ext_flash_write_byte_0x20_nodel ; write to flash
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
545
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
546 ; ... profile recording done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
547
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
548 ; read, increment, and store updated total number of dives
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
549 call eeprom_total_dives_read ; read total number of dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
550 INCI mpr ; increment by one
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
551 call eeprom_total_dives_write ; store updated number of total dives
0
heinrichsweikamp
parents:
diff changeset
552
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
553 ; prepare header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
554 CLRR header_buffer,.256 ; initialize header to all zeros
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
555
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
556 ; store header start code
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
557 MOVLI 0xFAFA,mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
558 MOVII mpr,header_buffer+index_header_start
0
heinrichsweikamp
parents:
diff changeset
559
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
560 ; store pointer to begin of dive profile
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
561 EEPROM_TT_READ eeprom_log_pointer,mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
562 MOVTT mpr,header_buffer+index_profile_start_address
0
heinrichsweikamp
parents:
diff changeset
563
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
564 ; store pointer to end of dive profile
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
565 MOVTT ext_flash_log_pointer,header_buffer+index_profile_end_address
0
heinrichsweikamp
parents:
diff changeset
566
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
567 ; write the profile format version (defined in hwos.inc)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
568 movlw logbook_profile_version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
569 MOVCC WREG,header_buffer+index_profile_version
0
heinrichsweikamp
parents:
diff changeset
570
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
571 ; store dive length (in units of recording entries)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
572 MOVTT ext_flash_length_counter,header_buffer+index_profile_byte_count
0
heinrichsweikamp
parents:
diff changeset
573
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
574 ; store time time & date of dive begin
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
575 MOVTT start_year,header_buffer+index_date
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
576 MOVTT start_hour,header_buffer+index_time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
577
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
578 ; store max depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
579 MOVII lastdive_maxdepth,header_buffer+index_max_depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
580
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
581 ; store dive time (ISR-safe 3 byte copy of minutes:2 and seconds)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
582 SMOVTT counted_divetime_mins,header_buffer+index_divetime
0
heinrichsweikamp
parents:
diff changeset
583
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
584 ; store minimum temperature
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
585 MOVII temperature_min,header_buffer+index_min_temp
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
586
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
587 ; store surface pressure (as used by deco engine)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
588 MOVII int_I_pres_surface,header_buffer+index_surface_press
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
589
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
590 ; store desaturation time
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
591 MOVII int_O_desaturation_time,header_buffer+index_desattime
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
592
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
593 ; store gases / diluents
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
594 lfsr FSR1,header_buffer+index_gas1 ; load FSR1 with base address of gases / diluents in header
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
595
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
596 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
597 btfsc FLAG_ccr_mode ; in CCR mode?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
598 bra end_dive_gaslist_diluent ; YES - write diluent gas list
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
599 btfsc FLAG_pscr_mode ; NO - in pSCR mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
600 bra end_dive_gaslist_diluent ; YES - write diluent gas list
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
601 ;bra end_dive_gaslist_gas ; NO - write OC gas list
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
602 ENDIF
0
heinrichsweikamp
parents:
diff changeset
603
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
604 end_dive_gaslist_gas: ; write OC gases
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
605 lfsr FSR0,opt_gas_O2_ratio-.1 ; set base address to (opt_gas_O2_ratio - 1) because of pre-increment statement
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
606 bra end_dive_gaslist_common ; write all 5 OC gases
0
heinrichsweikamp
parents:
diff changeset
607
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
608 IFDEF _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
609 end_dive_gaslist_diluent: ; write diluents
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
610 lfsr FSR0,opt_dil_O2_ratio-.1 ; set base address to (opt_dil_O2_ratio - 1) because of pre-increment statement
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
611 ;bra end_dive_gaslist_common ; write all 5 diluents
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
612 ENDIF
0
heinrichsweikamp
parents:
diff changeset
613
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
614 end_dive_gaslist_common: ; helper function for writing gas list entries
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
615
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
616 ; Memory Map:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
617 ; -------------------------
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
618 ; opt_gas_O2_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
619 ; opt_dil_O2_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
620 ; opt_gas_He_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
621 ; opt_dil_He_ratio res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
622 ; opt_gas_type res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
623 ; opt_dil_type res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
624 ; opt_gas_change res 5
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
625 ; opt_dil_change res 5
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
626
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
627 movlw .5 ; 5 gases to store
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
628 movwf lo ; use lo as counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
629 end_dive_gaslist_loop:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
630 movff PREINC0,POSTINC1 ; increment FSR0 address and copy O2 ratio to buffer
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
631 movlw .10 ; offset for H2 ratios
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
632 movff PLUSW0,POSTINC1 ; copy H2 ratio to buffer
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
633 movlw .30 ; offset for change depths
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
634 movff PLUSW0,POSTINC1 ; copy change depth to buffer
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
635 movlw .20 ; offset for types
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
636 movff PLUSW0,POSTINC1 ; copy type to buffer
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
637 decfsz lo ; decrement counter, did it became 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
638 bra end_dive_gaslist_loop ; NO - loop
0
heinrichsweikamp
parents:
diff changeset
639
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
640 ; store major firmware version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
641 movlw fw_version_major
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
642 MOVCC WREG,header_buffer+index_firmware+0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
643
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
644 ; store minor firmware version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
645 movlw fw_version_minor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
646 MOVCC WREG,header_buffer+index_firmware+1
0
heinrichsweikamp
parents:
diff changeset
647
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
648 ; store battery voltage
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
649 MOVII batt_voltage,header_buffer+index_battery_voltage
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
650
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
651 ; store sampling rate
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
652 MOVCC sampling_rate,header_buffer+index_samplingrate
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
653
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
654 ; store CNS at beginning of dive
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
655 MOVII CNS_start,header_buffer+index_cns_start
0
heinrichsweikamp
parents:
diff changeset
656
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
657 ; store supersaturations
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
658 MOVCC supersat_start, header_buffer+index_supersat_start
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
659 MOVCC int_O_lead_supersat+0,header_buffer+index_supersat_end ; low byte only needed
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
660
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
661 ; store logbook offset
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
662 call eeprom_log_offset_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
663 MOVII mpr,header_buffer+index_logoffset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
664
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
665 ; increment log offset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
666 rcall increment_log_offset
5
ed1dec74d5fd Put logbook offset into dive header
heinrichsweikamp
parents: 0
diff changeset
667
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
668 ; store battery level
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
669 MOVCC batt_percent,header_buffer+index_batt_percent
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
670
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
671 IFDEF _ccr_pscr
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
672 ; store setpoints
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
673 lfsr FSR0,opt_setpoint_cbar ; base address of ppO2 values
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
674 lfsr FSR1,opt_setpoint_change ; base address of change depths
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
675 lfsr FSR2,header_buffer+index_sp1 ; base address of setpoint data in header buffer
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
676 movlw .5 ; 5 setpoints (ppO2, depth) to be stored
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
677 movwf lo ; use lo as counter
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
678 end_dive_sp_loop:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
679 movff POSTINC0,POSTINC2 ; copy ppO2 value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
680 movff POSTINC1,POSTINC2 ; copy change depth
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
681 decfsz lo ; decrement counter, did it became 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
682 bra end_dive_sp_loop ; NO - loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
683 ELSE
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
684 ; just leave the zero bytes written during header initialization in place
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
685 ENDIF
0
heinrichsweikamp
parents:
diff changeset
686
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
687 ; store salinity
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
688 MOVCC opt_salinity,header_buffer+index_salinity
0
heinrichsweikamp
parents:
diff changeset
689
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
690 ; store CNS at end of dive
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
691 MOVII int_O_CNS_current,mpr ; get CNS into mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
692 bcf mpr+1,int_warning_flag ; clear warning flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
693 bcf mpr+1,int_attention_flag ; clear attention flag
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
694 MOVII mpr,header_buffer+index_cns_end ; store CNS
0
heinrichsweikamp
parents:
diff changeset
695
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
696 ; store average depth
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
697 MOVII lastdive_avgdepth,header_buffer+index_avr_depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
698
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
699 ; store total dive time (ISR-safe 2 byte copy)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
700 SMOVII total_divetime_secs,header_buffer+index_total_seconds
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
701
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
702 ; store GF low/high or saturation/desaturation multiplier
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
703 movff char_I_model,WREG ; get deco model
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
704 xorlw .1 ; deco model = ZH-L16-GF ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
705 bz end_dive_gf ; YES - store GFs
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
706 ;bnz end_dive_sat ; NO - store sat/desat
0
heinrichsweikamp
parents:
diff changeset
707
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
708 end_dive_sat:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
709 movff char_I_saturation_multiplier, header_buffer+index_factor_sat_desat+0 ; saturation multiplier
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
710 movff char_I_desaturation_multiplier,header_buffer+index_factor_sat_desat+1 ; desaturation multiplier
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
711 bra end_dive_sat_gf_done ; continue
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
712
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
713 end_dive_gf:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
714 movff char_I_GF_Low_percentage, header_buffer+index_gf_lo_hi+0 ; GF low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
715 movff char_I_GF_High_percentage, header_buffer+index_gf_lo_hi+1 ; GF high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
716 ;bra end_dive_sat_gf_done ; continue
0
heinrichsweikamp
parents:
diff changeset
717
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
718 end_dive_sat_gf_done:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
719 ; store deco model
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
720 MOVCC char_I_model,header_buffer+index_decomodel
0
heinrichsweikamp
parents:
diff changeset
721
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
722 ; store total dive number
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
723 call eeprom_total_dives_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
724 MOVII mpr,header_buffer+index_total_dives
0
heinrichsweikamp
parents:
diff changeset
725
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
726 ; store dive mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
727 MOVCC opt_dive_mode,header_buffer+index_divemode
0
heinrichsweikamp
parents:
diff changeset
728
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
729 ; store tissue data - total tissue pressure
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
730 lfsr FSR1,char_O_tissue_pressure ; load base address of total tissue pressures (chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
731 lfsr FSR2,header_buffer+index_tissue_pres_total ; load corresponding base address in header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
732 bsf aux_flag ; clear bit 7 (on-/off-gassing flag bit)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
733 movlw .16 ; 16 tissues to copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
734 rcall copy_tissuepres_to_header ; store the tissue pressures
0
heinrichsweikamp
parents:
diff changeset
735
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
736 ; store tissue data - N2 floats
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
737 lfsr FSR1,0x700 ; load base address of N2 tissue pressures (floats)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
738 ;lfsr FSR2,header_buffer+index_tissue_pres_N2 ; load corresponding base address in header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
739 bcf aux_flag ; do not touch bit 7
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
740 movlw .64 ; 16 tissue x 4 byte/tissue to copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
741 rcall copy_tissuepres_to_header ; store the tissue pressures
0
heinrichsweikamp
parents:
diff changeset
742
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
743 ; store tissue data - tissue supersaturations
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
744 lfsr FSR1,char_O_tissue_saturation ; load base address of tissue saturations (chars)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
745 ;lfsr FSR2,header_buffer+index_tissue_supersat ; load corresponding base address in header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
746 bsf aux_flag ; clear bit 7 (on-/off-gassing flag bit)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
747 movlw .16 ; 16 tissues to copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
748 rcall copy_tissuepres_to_header ; store the tissue pressures
0
heinrichsweikamp
parents:
diff changeset
749
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
750 ; store tissue data - He floats
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
751 lfsr FSR1,0x740 ; load base address of He tissue pressures (floats)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
752 ;lfsr FSR2,header_buffer+index_tissue_pres_He ; load corresponding base address in header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
753 bcf aux_flag ; do not touch bit 7
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
754 movlw .64 ; 16 tissue x 4 byte/tissue to copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
755 rcall copy_tissuepres_to_header ; store the tissue pressures
0
heinrichsweikamp
parents:
diff changeset
756
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
757 ; store last stop depth
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
758 MOVCC char_I_last_stop_depth,header_buffer+index_last_stop
0
heinrichsweikamp
parents:
diff changeset
759
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
760 ; store deco distance
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
761 ; -> the deco distance concept is disposed of, so just store a hard-coded zero
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
762 ; --> so just leave the zero written during header initialization in place
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
763 ;clrf WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
764 ;MOVCC WREG,header_buffer+index_decodistance
0
heinrichsweikamp
parents:
diff changeset
765
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
766 IFDEF _external_sensor
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
767 ; store last HUD data (ISR-safe 3 byte copy)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
768 SMOVTT hud_status_byte,header_buffer+index_hud_data
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
769 ELSE
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
770 ; just leave the zero bytes in place
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
771 ENDIF
0
heinrichsweikamp
parents:
diff changeset
772
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
773 ; store battery gauge registers [nAs] (ISR-safe 6 byte copy)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
774 SMOVSS battery_gauge,header_buffer+index_battery_gauge
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
775
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
776 ; write header stop code
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
777 MOVLI 0xFBFB,mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
778 MOVII mpr,header_buffer+index_header_stop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
779
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
780 ; store header in the FLASH
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
781 call eeprom_total_dives_read ; read total number of dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
782 decf mpr+0,W ; compute index from low(total number of dives)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
783 call log_header_addr_by_index ; compute header start address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
784 call ext_flash_erase_4kB ; erase the FLASH 4 kB block where the header will be stored
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
785 FLASH_RR_WRITE header_buffer,.256 ; write the header to the FLASH
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
786
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
787 ghostwriter_end_dive_cleanup:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
788 call eeprom_deco_data_write ; update deco data in EEPROM
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
789 bsf reset_surface_interval ; request ISR to reset the surface interval timer
0
heinrichsweikamp
parents:
diff changeset
790
heinrichsweikamp
parents:
diff changeset
791 ghostwriter_end_dive_common:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
792 ; memorize current ext_flash_log_pointer in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
793 EEPROM_TT_WRITE ext_flash_log_pointer,eeprom_log_pointer
0
heinrichsweikamp
parents:
diff changeset
794
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
795 ; terminate simulator mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
796 btfss simulatormode ; in simulator mode, i.e. need to restore tissue pressures?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
797 bra ghostwriter_end_dive_common_1 ; NO - continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
798 bcf simulatormode ; YES - end simulator mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
799 bcf sensor_override_request ; - request ISR to terminate the simulator mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
800 btfsc sensor_override_active ; - has the ISR confirmed termination of simulator mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
801 bra $-2 ; NO - not yet, loop waiting for the ISR
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
802
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
803 ifndef _DEBUG
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
804 ; in DEBUG compile, keep tissue pressures from simulated dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
805 call deco_pull_tissues_from_vault ; - restore tissue pressures (C-code)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
806 banksel common ; - back to bank common
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
807 endif
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 601
diff changeset
808
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
809 ghostwriter_end_dive_common_1:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
810 ; restart the timebase
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
811 bsf reset_timebase ; request ISR to reset the timebase
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
812 ; btfsc reset_timebase ; has the ISR confirmed reset of timebase?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
813 ; bra $-2 ; NO - not yet, loop waiting for the ISR
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
814
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
815 ; update battery gauge into EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
816 call eeprom_battery_gauge_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
817
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
818 ; catch-up simulator runtime / calculate deco data for surface mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
819 movff simulator_time,char_I_dive_interval ; get the simulator runtime, reads 0 if exiting from a real dive
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
820 call deco_calc_dive_interval ; catch up with tissue desaturation when exiting from simulator,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
821 ; else calculates for 2 seconds only when exiting from a real dive,
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
822 ; needed to update CNS, GF and tissue graphics for surface display.
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
823 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time after catch-up
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
824 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
825
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
826 ; the last surface pressure sample may have been taken while being submerged a bit already,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
827 ; therefore it will be replaced by the sample taken one more before, which is the one that
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
828 ; became the surface pressure reference used while this dive.
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
829 MOVII pressure_abs_ref,pressure_abs_sampled
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
830
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
831 ; done with post-dive operations, return to surface loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
832 goto surfloop
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
833
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
834
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
835 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
836 ; Helper Function - copy Tissue Pressures
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
837 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
838 copy_tissuepres_to_header:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
839 movwf eeprom_loop ; initialize loop counter (EEPROM var used here)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
840 copy_tissuepres_to_header_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
841 movf POSTINC1,W ; copy tissue pressure to WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
842 btfsc aux_flag ; shall clear bit 7 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
843 bcf WREG,7 ; YES - clear bit for on-gassing/off-gassing
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
844 movwf POSTINC2 ; copy WREG to header buffer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
845 decfsz eeprom_loop,F ; decrement loop counter, all done?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
846 bra copy_tissuepres_to_header_loop ; NO - loop
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
847 return ; YES - done
219
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
848
4b2622e0fd50 init new 4kB Page in logbook memory when pointer is not valid.
heinrichsweikamp
parents: 185
diff changeset
849
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
850 ;-----------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
851 ; Helper Function - increment Log Offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
852 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
853 increment_log_offset:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
854 call eeprom_log_offset_read ; read current logbook offset into mpr
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
855 movf mpr+0,W ; get low byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
856 iorwf mpr+1,W ; inclusive-or with high byte, result zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
857 bz increment_log_offset_1 ; YES - skip offset correction
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
858 INCI mpr ; NO - increment offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
859 call eeprom_log_offset_write ; - store incremented offset as new offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
860 increment_log_offset_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
861 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
862
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
863
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
864 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
865 ; start Dive Data Recording (write short Header with Dive Number)
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
866 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
867 global ghostwriter_short_header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
868 ghostwriter_short_header:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
869 ; get pointer for profile storing
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
870 rcall ghostwriter_load_pointer
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
871
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
872 ; the following code is used to write a clean new dive after the previous
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
873 ; hasn't been stored correctly. e.g. after a power loss during the dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
874 FLASH_II_READ_0x20 mpr ; read first two bytes
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
875 incfsz mpr+0,F ; is 1st byte = 0xFF ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
876 bra ghostwriter_short_header_init ; NO - initialize page
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
877 incfsz mpr+1,F ; - is 2nd byte = 0xFF ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
878 bra ghostwriter_short_header_init ; NO - initialize page
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
879 bra ghostwriter_short_header_2 ; YES - page is clean, can continue
0
heinrichsweikamp
parents:
diff changeset
880
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
881 ghostwriter_short_header_init:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
882 clrf ext_flash_address+0 ; low byte: set to zero
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
883 movlw 0xF0 ; high byte: keep upper nibble, set lower nibble to zero
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
884 andwf ext_flash_address+1,F ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
885 movlw .16 ; increment ext_flash_address to next multiple of 16*256
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
886 addwf ext_flash_address+1,F ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
887 movlw .0 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
888 addwfc ext_flash_address+2,F ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
889 movlw 0x20 ; at address 0x200000 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
890 cpfseq ext_flash_address+2 ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
891 bra ghostwriter_short_header_init_2 ; NO - continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
892 clrf ext_flash_address+2 ; YES - rollover to 0x000000
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
893
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
894 ghostwriter_short_header_init_2:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
895 ; update pointer in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
896 EEPROM_TT_WRITE ext_flash_address,eeprom_log_pointer
0
heinrichsweikamp
parents:
diff changeset
897
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
898 ghostwriter_short_header_2:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
899 ; reload the pointer (required after above checks)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
900 rcall ghostwriter_load_pointer ; reload ext_flash_address from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
901
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
902 ; clear dive length counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
903 CLRT ext_flash_length_counter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
904
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
905 ; write short start header with dive number into profile memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
906 FLASH_LIT_PROFILE 0xFA ; 1st byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
907 FLASH_LIT_PROFILE 0xFA ; 2nd byte
278
dfac47ac2e1d BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents: 275
diff changeset
908
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
909 ; load total number of dives
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
910 call eeprom_total_dives_read ; read total number of dives into mpr:2
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
911 incf mpr+0,F ; increment low byte + 1
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
912 FLASH_II_PROFILE mpr ; write mpr:2 to FLASH
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
913
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
914 ; close short header
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
915 FLASH_LIT_PROFILE 0xFA ; 1st byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
916 FLASH_LIT_PROFILE 0xFA ; 2nd byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
917
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
918 ; Keep room for dive length ext_flash_length_counter:3 (stored at the end of the dive),
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
919 ; writing 0xFF here is mandatory because 0xFF can be overwritten when closing the dive.
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
920 ; The stored dive length counter itself is not part of the counted dive length.
278
dfac47ac2e1d BUGFIX: There was a 1:4096 chance that a portion of a dive was not stored correctly resulting in download issues
heinrichsweikamp
parents: 275
diff changeset
921
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
922 setf WREG ; write 0xFF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
923 call ext_flash_write_byte_0x20 ; write to profile (no dive length increment)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
924 setf WREG ; write 0xFF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
925 call ext_flash_write_byte_0x20 ; write to profile (no dive length increment)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
926 setf WREG ; write 0xFF
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
927 call ext_flash_write_byte_0x20 ; write to profile (no dive length increment)
0
heinrichsweikamp
parents:
diff changeset
928
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
929 ; store sizes and sampling rates of recording datasets
0
heinrichsweikamp
parents:
diff changeset
930
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
931 FLASH_CC_PROFILE sampling_rate ; get general sampling rate
0
heinrichsweikamp
parents:
diff changeset
932
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
933 FLASH_LIT_PROFILE .7 ; number of additional datasets
0
heinrichsweikamp
parents:
diff changeset
934
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
935 FLASH_LIT_PROFILE .0 ; type: temperature
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
936 FLASH_LIT_PROFILE infolength_temperature ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
937 FLASH_LIT_PROFILE div_temperature ; get sampling rate
0
heinrichsweikamp
parents:
diff changeset
938
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
939
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
940 FLASH_LIT_PROFILE .1 ; type: +++
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
941 FLASH_LIT_PROFILE infolength_deco ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
942 FLASH_LIT_PROFILE div_deco ; get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
943
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
944 FLASH_LIT_PROFILE .2 ; type: saturation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
945 FLASH_LIT_PROFILE infolength_gf ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
946 FLASH_LIT_PROFILE div_gf ; get sampling rate
0
heinrichsweikamp
parents:
diff changeset
947
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
948 FLASH_LIT_PROFILE .3 ; type: ppO2 sensor data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
949 FLASH_LIT_PROFILE infolength_ppo2_sensors ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
950 movlw .0 ; default to no ppO2 data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
951 IFDEF _external_sensor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
952 btfsc FLAG_ccr_mode ; in CCR mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
953 movlw div_ppo2_sensors ; YES - get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
954 btfsc FLAG_pscr_mode ; in pSCR mode?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
955 movlw div_ppo2_sensors ; YES - get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
956 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
957 FLASH_WREG_PROFILE ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
958
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
959 FLASH_LIT_PROFILE .4 ; type: deco plan (stop times)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
960 FLASH_LIT_PROFILE infolength_decoplan ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
961 FLASH_LIT_PROFILE div_decoplan ; get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
962
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
963 FLASH_LIT_PROFILE .5 ; type: CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
964 FLASH_LIT_PROFILE infolength_cns ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
965 FLASH_LIT_PROFILE div_cns ; get sampling rate
0
heinrichsweikamp
parents:
diff changeset
966
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
967 FLASH_LIT_PROFILE .6 ; type: tank pressure
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
968 FLASH_LIT_PROFILE infolength_tank ; get size of recording data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
969 movlw .0 ; default to no tank pressure data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
970 IFDEF _rx_functions
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
971 btfsc tr_functions_activated ; TR functions activated?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
972 movlw div_tank ; YES - get sampling rate
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
973 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
974 FLASH_WREG_PROFILE ; WREG -> profile in ext. flash
0
heinrichsweikamp
parents:
diff changeset
975
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
976 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
977
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
978
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
979 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
980 ; Helper Function - load ext_flash_address from EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
981 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
982 ghostwriter_load_pointer:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
983 EEPROM_TT_READ eeprom_log_pointer,ext_flash_address
0
heinrichsweikamp
parents:
diff changeset
984 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
985
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
986 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
987
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
988 END