Mercurial > public > hwos_code
comparison src/ghostwriter.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | b7eb98dbd800 |
children | 08a0162d3ca1 |
comparison
equal
deleted
inserted
replaced
581:f5de1ff88814 | 582:b455b31ce022 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File ghostwriter.asm REFACTORED VERSION 2.94 | 3 ; File ghostwriter.asm REFACTORED VERSION 2.98 |
4 ; | 4 ; |
5 ; Ghostwriter (Log profile recorder) | 5 ; Ghostwriter (Log profile recorder) |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2011-11-27 : [mH] Creation | 10 ; 2011-11-27 : [mH] Creation |
11 | 11 |
12 #include "hwos.inc" ; Mandatory header | 12 #include "hwos.inc" ; Mandatory header |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | 13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c |
14 #include "external_flash.inc" | 14 #include "external_flash.inc" |
15 #include "surfmode.inc" | 15 #include "surfmode.inc" |
16 #include "eeprom_rs232.inc" | 16 #include "eeprom_rs232.inc" |
17 #include "strings.inc" | 17 #include "strings.inc" |
18 #include "isr.inc" | 18 #include "isr.inc" |
19 #include "tft_outputs.inc" | 19 #include "tft_outputs.inc" |
20 #include "divemode.inc" | 20 #include "divemode.inc" |
21 #include "rtc.inc" | 21 #include "rtc.inc" |
22 | 22 |
23 ghostwriter CODE | 23 |
24 ;---- Private local variables ------------------------------------------------- | |
25 | |
26 CBLOCK local2 ; max size is 16 Byte !!! | |
27 divisor_temperature ; divisor used to time the sampling of dive data | |
28 divisor_deco ; divisor used to time the sampling of dive data | |
29 divisor_gf ; divisor used to time the sampling of dive data | |
30 divisor_ppo2_sensors ; divisor used to time the sampling of dive data | |
31 divisor_decoplan ; divisor used to time the sampling of dive data | |
32 divisor_cns ; divisor used to time the sampling of dive data | |
33 divisor_tank ; divisor used to time the sampling of dive data | |
34 ProfileFlagByte ; used to store events | |
35 ENDC ; used: 8 byte, remaining: 8 byte | |
36 | |
37 | |
38 ghostwriter CODE | |
39 | |
40 ;============================================================================= | |
41 | |
42 | |
43 global init_recording_params ; Initialize profile recording parameters | |
44 init_recording_params: | |
45 movff samplingrate,samplesecs_value; to avoid EEPROM access in the ISR | |
46 movlw div_temperature | |
47 movwf divisor_temperature ; load divisors for profile storage | |
48 movlw div_deco | |
49 movwf divisor_deco | |
50 movlw div_gf | |
51 movwf divisor_gf | |
52 movlw div_ppo2_sensors | |
53 movwf divisor_ppo2_sensors | |
54 movlw div_decoplan | |
55 movwf divisor_decoplan | |
56 movlw div_cns | |
57 movwf divisor_cns | |
58 movlw div_tank | |
59 movwf divisor_tank | |
60 btfss FLAG_apnoe_mode ; In Apnoe mode? | |
61 bra init_recording_params_1 ; NO | |
62 movlw samplingrate_apnoe ; YES - overwrite some parameters in Apnoe mode | |
63 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
64 init_recording_params_1: | |
65 btfsc FLAG_ccr_mode ; in CCR mode? | |
66 bra init_recording_params_2 ; YES | |
67 btfsc FLAG_pscr_mode ; in pSCR mode? | |
68 bra init_recording_params_2 ; YES | |
69 ; in OC Mode, disable ppO2 logging | |
70 movlw .0 | |
71 movwf divisor_ppo2_sensors | |
72 init_recording_params_2: | |
73 return | |
74 | |
24 | 75 |
25 global store_dive_data | 76 global store_dive_data |
26 store_dive_data: | 77 store_dive_data: |
27 bcf store_sample ; clear flag | 78 bcf store_sample ; clear flag |
28 | 79 |
29 ifndef __DEBUG | 80 ifndef __DEBUG |
30 btfsc simulatormode_active ; Are we in simulator mode? | 81 btfsc simulatormode_active ; Are we in simulator mode? |
31 return ; Yes, discard everything | 82 return ; Yes, discard everything |
32 endif | 83 endif |
33 | 84 |
34 btfsc FLAG_apnoe_mode ; In Apnoe mode? | 85 btfsc FLAG_apnoe_mode ; In Apnoe mode? |
35 return ; Yes, discard everything | 86 return ; Yes, discard everything |
36 | 87 |
37 SAFE_2BYTE_COPY rel_pressure, lo | 88 SAFE_2BYTE_COPY rel_pressure, lo |
38 movf lo,W ; store depth with every sample | 89 movf lo,W ; store depth with every sample |
39 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 90 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
40 movf hi,W | 91 movf hi,W |
41 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 92 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
42 | 93 |
43 ;First, find out how many bytes will append to this sample.... | 94 ; First, find out how many bytes will append to this sample.... |
44 clrf ProfileFlagByte ; clear number of bytes to append | 95 clrf ProfileFlagByte ; clear number of bytes to append |
45 | 96 |
46 ; Check Extented informations | 97 ; Check Extended informations |
47 decfsz divisor_temperature,W ; Check divisor | 98 decfsz divisor_temperature,W ; Check divisor |
48 bra check_extended1 | 99 bra check_extended1 |
49 movlw infolength_temperature | 100 movlw infolength_temperature |
50 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 101 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
51 check_extended1: | 102 check_extended1: |
52 decfsz divisor_deco,W ; Check divisor | 103 decfsz divisor_deco,W ; Check divisor |
53 bra check_extended2 | 104 bra check_extended2 |
54 movlw infolength_deco | 105 movlw infolength_deco |
55 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 106 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
56 check_extended2: | 107 check_extended2: |
57 decfsz divisor_gf,W ; Check divisor | 108 decfsz divisor_gf,W ; Check divisor |
58 bra check_extended3 | 109 bra check_extended3 |
59 movlw infolength_gf | 110 movlw infolength_gf |
60 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 111 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
61 check_extended3: | 112 check_extended3: |
62 decfsz divisor_ppo2_sensors,W ; Check divisor | 113 decfsz divisor_ppo2_sensors,W ; Check divisor |
63 bra check_extended4 | 114 bra check_extended4 |
64 movlw infolength_ppo2_sensors | 115 movlw infolength_ppo2_sensors |
65 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 116 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
66 check_extended4: | 117 check_extended4: |
67 decfsz divisor_decoplan,W ; Check divisor | 118 decfsz divisor_decoplan,W ; Check divisor |
68 bra check_extended5 | 119 bra check_extended5 |
69 movlw infolength_decoplan | 120 movlw infolength_decoplan |
70 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 121 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
71 check_extended5: | 122 check_extended5: |
72 decfsz divisor_cns,W ; Check divisor | 123 decfsz divisor_cns,W ; Check divisor |
73 bra check_extended6 | 124 bra check_extended6 |
74 movlw infolength_cns | 125 movlw infolength_cns |
75 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 126 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
76 check_extended6: | 127 check_extended6: |
77 decfsz divisor_tank,W ; Check divisor | 128 decfsz divisor_tank,W ; Check divisor |
78 bra check_extended7 | 129 bra check_extended7 |
79 movlw infolength_tank | 130 movlw infolength_tank |
80 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 131 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
81 check_extended7: | 132 check_extended7: |
82 | 133 |
83 ; Second, check global event flag | 134 ; Second, check global event flag |
84 btfss event_occured ; Check global event flag | 135 btfss event_occured ; Check global event flag |
85 bra store_dive_data3 ; No Event | 136 bra store_dive_data3 ; No Event |
86 | 137 |
87 incf ProfileFlagByte,F ; add one byte (The EventByte) | 138 incf ProfileFlagByte,F ; add one byte (The EventByte1) |
88 | 139 |
89 clrf EventByte ; reset EventByte | 140 clrf EventByte1 ; reset EventByte1 |
90 clrf EventByte2 ; reset EventByte2 | 141 clrf EventByte2 ; reset EventByte2 |
91 | 142 |
92 movf AlarmType,W ; Type of Alarm Bit 0-3 | 143 movf AlarmType,W ; Type of Alarm Bit 0-3 |
93 addwf EventByte,F ; Copy to EventByte Bit 0-3 | 144 addwf EventByte1,F ; Copy to EventByte1 Bit 0-3 |
94 clrf AlarmType ; Reset AlarmType | 145 clrf AlarmType ; Reset AlarmType |
95 | 146 |
96 ; Third, check events and add additional bytes | 147 ; Third, check events and add additional bytes |
97 btfss gas6_changed ; Check flag | 148 btfss gas6_changed ; Check flag |
98 bra check_event2 | 149 bra check_event2 |
99 movlw d'2' ; Information length | 150 movlw d'2' ; Information length |
100 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 151 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
101 bsf EventByte,4 ; Also set Flag in EventByte! | 152 bsf EventByte1,4 ; Also set Flag in EventByte1! |
102 check_event2: | 153 check_event2: |
103 btfss stored_gas_changed ; Check flag | 154 btfss stored_gas_changed ; Check flag |
104 bra check_event3 | 155 bra check_event3 |
105 movlw d'1' ; Information length | 156 movlw d'1' ; Information length |
106 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 157 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
107 bsf EventByte,5 ; Also set Flag in EventByte! | 158 bsf EventByte1,5 ; Also set Flag in EventByte1! |
108 check_event3: | 159 check_event3: |
109 btfss setpoint_changed ; Check flag | 160 btfss setpoint_changed ; Check flag |
110 bra check_event4 | 161 bra check_event4 |
111 movlw d'1' ; Information length | 162 movlw d'1' ; Information length |
112 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 163 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
113 bsf EventByte,6 ; Also set Flag in EventByte! | 164 bsf EventByte1,6 ; Also set Flag in EventByte1! |
114 check_event4: | 165 check_event4: |
115 btfss bailoutgas_event ; =1: bailout was selected or a gaschange during bailout | 166 btfss bailoutgas_event ; =1: bailout was selected or a gas change during bailout |
116 bra check_event5 | 167 bra check_event5 |
117 movlw d'2' ; Information length | 168 movlw d'2' ; Information length |
118 addwf ProfileFlagByte,F ; add to ProfileFlagByte | 169 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
119 bsf EventByte2,0 ; set flag in EventByte2! | 170 bsf EventByte2,0 ; set flag in EventByte2! |
120 bsf EventByte,7 ; =1: Another Eventbyte is available | 171 bsf EventByte1,7 ; =1: Another EventByte1 is available |
121 | 172 |
122 check_event5: | 173 check_event5: |
123 ; more events? | 174 ; more events? |
124 | 175 |
125 store_dive_data3: | 176 store_dive_data3: |
126 btfsc EventByte,7 ; =1: Another Eventbyte is available | 177 btfsc EventByte1,7 ; =1: Another EventByte1 is available |
127 incf ProfileFlagByte,F ; add one byte (The EventByte2) | 178 incf ProfileFlagByte,F ; add one byte (The EventByte2) |
128 | 179 |
129 btfsc event_occured ; Check global event flag | 180 btfsc event_occured ; Check global event flag |
130 bsf ProfileFlagByte,7 ; Set EventByte Flag in ProfileFlagByte | 181 bsf ProfileFlagByte,7 ; Set EventByte1 Flag in ProfileFlagByte |
131 | 182 |
132 movf ProfileFlagByte,W ; finally, write ProfileFlagByte! | 183 movf ProfileFlagByte,W ; finally, write ProfileFlagByte! |
133 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 184 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
134 | 185 |
135 btfss event_occured ; Check global event flag (again) | 186 btfss event_occured ; Check global event flag (again) |
136 bra store_dive_data4 ; No Event | 187 bra store_dive_data4 ; No Event |
137 | 188 |
138 ; Store the EventByte(s) + additional bytes now | 189 ; Store the EventByte(s) + additional bytes now |
139 movf EventByte,W | 190 movf EventByte1,W |
140 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 191 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
141 | 192 |
142 movf EventByte2,W ; Write second event byte... | 193 movf EventByte2,W ; Write second event byte... |
143 btfsc EventByte,7 ; =1: Another Eventbyte is available | 194 btfsc EventByte1,7 ; =1: Another EventByte1 is available |
144 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 195 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
145 | 196 |
146 btfss gas6_changed ; Check flag | 197 btfss gas6_changed ; Check flag |
147 bra store_dive_data3b | 198 bra store_dive_data3b |
148 movff char_I_O2_ratio,WREG | 199 movff char_I_O2_ratio,WREG ; store gas 6 o2 ratio |
149 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 200 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
150 movff char_I_He_ratio,WREG | 201 movff char_I_He_ratio,WREG ; store gas 6 He ratio |
151 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 202 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
152 bcf gas6_changed ; Clear this event | 203 bcf gas6_changed ; Clear this event |
153 store_dive_data3b: | 204 store_dive_data3b: |
154 btfss stored_gas_changed ; Check flag | 205 btfss stored_gas_changed ; Check flag |
155 bra store_dive_data3c | 206 bra store_dive_data3c |
156 movf active_gas,W ; Store active gas | 207 movf active_gas,W ; Store active gas |
157 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 208 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
158 bcf stored_gas_changed ; Clear this event | 209 bcf stored_gas_changed ; Clear this event |
159 store_dive_data3c: | 210 store_dive_data3c: |
160 btfss setpoint_changed ; Check flag | 211 btfss setpoint_changed ; Check flag |
161 bra store_dive_data3d | 212 bra store_dive_data3d |
162 movff char_I_const_ppO2,WREG | 213 movff char_I_const_ppO2,WREG ; store setpoint |
163 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 214 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
164 bcf setpoint_changed ; Clear this event | 215 bcf setpoint_changed ; Clear this event |
165 store_dive_data3d: | 216 store_dive_data3d: |
166 btfss bailoutgas_event ; Check flag | 217 btfss bailoutgas_event ; Check flag |
167 bra store_dive_data3e | 218 bra store_dive_data4 |
168 movff char_I_O2_ratio,WREG | 219 movff char_I_O2_ratio,WREG ; store O2 ratio of bailout gas |
169 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 220 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
170 movff char_I_He_ratio,WREG | 221 movff char_I_He_ratio,WREG ; store He ratio of bailout gas |
171 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 222 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
172 bcf bailoutgas_event ; Clear this event | 223 bcf bailoutgas_event ; Clear this event |
173 store_dive_data3e: | |
174 | 224 |
175 store_dive_data4: | 225 store_dive_data4: |
176 | |
177 ; Store extended informations | 226 ; Store extended informations |
178 decfsz divisor_temperature,F ; Check divisor | 227 decfsz divisor_temperature,F ; Check divisor |
179 bra store_extended1 | 228 bra store_extended1 |
180 rcall store_dive_temperature | 229 rcall store_dive_temperature |
181 store_extended1: | 230 store_extended1: |
182 decfsz divisor_deco,F ; Check divisor | 231 decfsz divisor_deco,F ; Check divisor |
183 bra store_extended2 | 232 bra store_extended2 |
184 rcall store_dive_decodata | 233 rcall store_dive_decodata |
185 store_extended2: | 234 store_extended2: |
186 decfsz divisor_gf,F ; Check divisor | 235 decfsz divisor_gf,F ; Check divisor |
187 bra store_extended3 | 236 bra store_extended3 |
188 rcall store_dive_gf | 237 rcall store_dive_gf |
189 store_extended3: | 238 store_extended3: |
190 decfsz divisor_ppo2_sensors,F ; Check divisor | 239 decfsz divisor_ppo2_sensors,F ; Check divisor |
191 bra store_extended4 | 240 bra store_extended4 |
192 rcall store_dive_ppO2_sensors | 241 rcall store_dive_ppO2_sensors |
193 store_extended4: | 242 store_extended4: |
194 decfsz divisor_decoplan,F ; Check divisor | 243 decfsz divisor_decoplan,F ; Check divisor |
195 bra store_extended5 | 244 bra store_extended5 |
196 rcall store_dive_decoplan | 245 rcall store_dive_decoplan |
197 store_extended5: | 246 store_extended5: |
198 decfsz divisor_cns,F ; Check divisor | 247 decfsz divisor_cns,F ; Check divisor |
199 bra store_extended6 | 248 bra store_extended6 |
200 rcall store_dive_cns | 249 rcall store_dive_cns |
201 store_extended6: | 250 store_extended6: |
202 decfsz divisor_tank,F ; Check divisor | 251 decfsz divisor_tank,F ; Check divisor |
203 bra store_extended7 | 252 bra store_extended7 |
204 rcall store_dive_tank | 253 rcall store_dive_tank |
205 store_extended7: | 254 store_extended7: |
206 | 255 |
207 ; The next block is required to take care of "store never" | 256 ; The next block is required to take care of "store never" |
208 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | 257 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) |
209 clrf divisor_temperature ; And clear register again, so it will never reach zero... | 258 clrf divisor_temperature ; And clear register again, so it will never reach zero... |
210 btfsc divisor_deco,7 | 259 btfsc divisor_deco,7 |
211 clrf divisor_deco | 260 clrf divisor_deco |
212 btfsc divisor_gf,7 | 261 btfsc divisor_gf,7 |
213 clrf divisor_gf | 262 clrf divisor_gf |
214 btfsc divisor_ppo2_sensors,7 | 263 btfsc divisor_ppo2_sensors,7 |
219 clrf divisor_cns | 268 clrf divisor_cns |
220 btfsc divisor_tank,7 | 269 btfsc divisor_tank,7 |
221 clrf divisor_tank | 270 clrf divisor_tank |
222 | 271 |
223 store_dive_data5: | 272 store_dive_data5: |
224 bcf event_occured ; Clear the global event flag | 273 bcf event_occured ; Clear the global event flag |
225 clrf EventByte ; reset EventByte | 274 clrf EventByte1 ; reset EventByte1 |
226 clrf EventByte2 ; reset EventByte2 | 275 clrf EventByte2 ; reset EventByte2 |
227 return ; Done. (Sample with all informations written to external flash) | 276 return ; Done. (Sample with all informations written to external flash) |
228 | 277 |
229 store_dive_cns: | 278 store_dive_cns: |
230 movff int_O_CNS_fraction+0,WREG | 279 movff int_O_CNS_fraction+0,WREG |
231 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
232 movff int_O_CNS_fraction+1,WREG | 281 movff int_O_CNS_fraction+1,WREG |
233 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 282 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
234 movlw div_cns | 283 movlw div_cns |
235 movwf divisor_cns ; Reload divisor from CF | 284 movwf divisor_cns ; Reload divisor from CF |
236 return | 285 return |
237 | 286 |
238 store_dive_tank: | 287 store_dive_tank: |
239 movlw div_tank | 288 movlw div_tank |
240 movwf divisor_tank ; Reload divisor from CF | 289 movwf divisor_tank ; Reload divisor from CF |
241 return | 290 return |
242 | 291 |
243 store_dive_decoplan: | 292 store_dive_decoplan: |
244 ; Store the decoplan | 293 ; Store the deco plan |
245 lfsr FSR1,char_O_deco_time_for_log+.0 | 294 lfsr FSR1,char_O_deco_time_for_log+.0 |
246 movlw .15 | 295 movlw .15 |
247 movwf lo | 296 movwf lo |
248 store_dive_decoplan_loop: | 297 store_dive_decoplan_loop: |
249 movf POSTINC1,W | 298 movf POSTINC1,W |
250 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 299 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
251 decfsz lo,F | 300 decfsz lo,F |
252 bra store_dive_decoplan_loop | 301 bra store_dive_decoplan_loop |
253 movlw div_decoplan | 302 movlw div_decoplan |
254 movwf divisor_decoplan ; Reload divisor from CF | 303 movwf divisor_decoplan ; Reload divisor from CF |
255 return | 304 return |
256 | 305 |
257 store_dive_ppO2_sensors: | 306 store_dive_ppO2_sensors: |
258 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps) | 307 movf o2_ppo2_sensor1,W ; Sensor1 ppO2 (in 0.01bar steps) |
259 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 308 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
260 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 309 SAFE_2BYTE_COPY o2_mv_sensor1,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
261 movf lo,W ; in 0.1mV steps | 310 movf lo,W ; in 0.1mV steps |
262 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 311 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
263 movf hi,W ; in 0.1mV steps | 312 movf hi,W ; in 0.1mV steps |
264 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 313 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
265 | 314 |
266 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps) | 315 movf o2_ppo2_sensor2,W ; Sensor2 ppO2 (in 0.01bar steps) |
267 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 316 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
268 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 317 SAFE_2BYTE_COPY o2_mv_sensor2,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
269 movf lo,W ; in 0.1mV steps | 318 movf lo,W ; in 0.1mV steps |
270 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 319 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
271 movf hi,W ; in 0.1mV steps | 320 movf hi,W ; in 0.1mV steps |
272 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 321 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
273 | 322 |
274 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps) | 323 movf o2_ppo2_sensor3,W ; Sensor3 ppO2 (in 0.01bar steps) |
275 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 324 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
276 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here... | 325 SAFE_2BYTE_COPY o2_mv_sensor3,lo ; o2_mv_sensor may be modified via ISR during the two writes here... |
277 movf lo,W ; in 0.1mV steps | 326 movf lo,W ; in 0.1mV steps |
278 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 327 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
279 movf hi,W ; in 0.1mV steps | 328 movf hi,W ; in 0.1mV steps |
280 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 329 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
281 | 330 |
282 movlw div_ppo2_sensors | 331 movlw div_ppo2_sensors |
283 movwf divisor_ppo2_sensors ; Reload divisor | 332 movwf divisor_ppo2_sensors ; Reload divisor |
284 return | 333 return |
285 | 334 |
286 store_dive_gf: | 335 store_dive_gf: |
287 movff int_O_gradient_factor+0,WREG ; gradient factor absolute (range is limited to 255, only lower byte used for value) | 336 movff int_O_gradient_factor+0,WREG; gradient factor absolute (range is limited to 255, only lower byte used for value) |
288 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 337 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
289 movlw div_gf | 338 movlw div_gf |
290 movwf divisor_gf ; Reload divisor | 339 movwf divisor_gf ; Reload divisor |
291 return | 340 return |
292 | 341 |
293 store_dive_decodata: | 342 store_dive_decodata: |
294 movf decodata+0,W ; =0:no stop dive, if in deco mode: ceiling in m | 343 ; Check if deco stops are necessary |
295 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 344 movff char_O_first_deco_depth,WREG; get ceiling |
296 movf decodata+1,W ; no stop time of length of first stop | 345 tstfsz WREG ; ceiling < 0m (aka in deco) ? |
297 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 346 bra store_dive_decodata_deco ; YES |
347 ; NO - within NDL | |
348 clrf WREG ; =0: no stop dive | |
349 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
350 movff char_O_nullzeit,WREG ; remaining NDL time | |
351 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
352 bra store_dive_decodata_common | |
353 store_dive_decodata_deco: | |
354 ; YES - in deco | |
355 movff char_O_first_deco_depth,WREG; ceiling in m | |
356 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
357 movff char_O_first_deco_time,WREG ; length of first stop in minutes | |
358 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
359 store_dive_decodata_common: | |
298 movlw div_deco | 360 movlw div_deco |
299 movwf divisor_deco ; Reload divisor | 361 movwf divisor_deco ; Reload divisor |
300 return | 362 return |
301 | 363 |
302 store_dive_temperature: | 364 store_dive_temperature: |
303 SAFE_2BYTE_COPY temperature,lo | 365 SAFE_2BYTE_COPY temperature,lo |
304 movf lo,W ; append temperature to current sample! | 366 movf lo,W ; append temperature to current sample! |
305 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 367 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
306 movf hi,W | 368 movf hi,W |
307 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 369 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
308 movlw div_temperature | 370 movlw div_temperature |
309 movwf divisor_temperature ; Reload divisor | 371 movwf divisor_temperature ; Reload divisor |
310 return | 372 return |
311 | 373 |
312 ghostwrite_byte_header: | 374 ghostwrite_byte_header: |
313 goto write_byte_ext_flash_plus_header ; (This call will also delete the 4kB TOC entry first) | 375 goto write_byte_ext_flash_plus_header ; (This call will also delete the 4kB TOC entry first) |
314 ; returns... | 376 ; returns... |
315 | 377 |
316 ghostwrite_byte_profile: | 378 ghostwrite_byte_profile: |
317 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000 | 379 goto write_byte_ext_flash_plus ; writes byte and increases address with banking at 0x200000 |
318 ; returns... | 380 ; returns... |
319 | 381 |
320 global ghostwriter_end_dive | 382 global ghostwriter_end_dive |
321 ghostwriter_end_dive: | 383 ghostwriter_end_dive: |
322 movff ext_flash_address+0,ext_flash_log_pointer+0 | 384 movff ext_flash_address+0,ext_flash_log_pointer+0 |
323 movff ext_flash_address+1,ext_flash_log_pointer+1 | 385 movff ext_flash_address+1,ext_flash_log_pointer+1 |
324 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header | 386 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header |
325 | 387 |
326 movff menupos3,customview_divemode ; store last customview | 388 movff menupos3,customview_divemode ; store last custom view |
327 | 389 |
328 btfss realdive ; dive longer then one minute | 390 btfss realdive ; dive longer then one minute |
329 goto ghostwriter_end_dive_common ; No, discard everything | 391 goto ghostwriter_end_dive_common ; No, discard everything |
330 | 392 |
331 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | 393 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
332 ifndef __DEBUG | 394 ifndef __DEBUG |
333 btfsc simulatormode_active ; Are we in simulator mode? | 395 btfsc simulatormode_active ; Are we in simulator mode? |
334 goto ghostwriter_end_dive_common_sim ; Yes, discard everything | 396 goto ghostwriter_end_dive_common_sim ; Yes, discard everything |
335 endif | 397 endif |
336 | 398 |
337 btfsc FLAG_apnoe_mode ; In Apnoe mode? | 399 btfsc FLAG_apnoe_mode ; In Apnoe mode? |
338 goto ghostwriter_end_dive_common ; Yes, discard everything | 400 goto ghostwriter_end_dive_common ; Yes, discard everything |
339 | 401 |
340 ; Dive finished (and longer then one minute) | 402 ; Dive finished (and longer then one minute) |
341 | 403 |
342 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | 404 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives |
343 call apnoe_calc_maxdepth | 405 call apnoe_calc_maxdepth |
344 | 406 |
345 ; calculate desaturation time | 407 ; calculate desaturation time |
346 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! | 408 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! |
347 movff last_surfpressure_30min+1,int_I_pres_surface+1 | 409 movff last_surfpressure_30min+1,int_I_pres_surface+1 |
348 | 410 |
349 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode | 411 call deco_calc_dive_interval_1min ; calculate deco in surface mode |
350 | 412 call deco_calc_desaturation_time ; calculate desaturation time |
351 call deco_calc_desaturation_time ; calculate desaturation time | 413 banksel common ; select ram bank 1 |
352 movlb b'00000001' ; select ram bank 1 | 414 |
353 | 415 movlw 0xFD ; .... End-of-Profile Bytes |
354 movlw 0xFD ; .... End-of-Profile Bytes | 416 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
355 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | |
356 movlw 0xFD | 417 movlw 0xFD |
357 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash | 418 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. Flash |
358 movff ext_flash_address+0,ext_flash_log_pointer+0 | 419 movff ext_flash_address+0,ext_flash_log_pointer+0 |
359 movff ext_flash_address+1,ext_flash_log_pointer+1 | 420 movff ext_flash_address+1,ext_flash_log_pointer+1 |
360 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header | 421 movff ext_flash_address+2,ext_flash_log_pointer+2 ; Save end-of-profile pointer to store in header |
361 | 422 |
362 ; Set to first address again to store dive length ext_flash_dive_counter:3 | 423 ; Set to first address again to store dive length ext_flash_dive_counter:3 |
363 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 424 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 |
364 | 425 |
365 incf_ext_flash_address_0x20 d'6' ; Skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header | 426 incf_ext_flash_address_0x20 d'6' ; Skip internal "0xFA 0xFA #Divenumber:2 0xFA 0xFA" Header |
366 ; Store dive length | 427 ; Store dive length |
367 movf ext_flash_dive_counter+0,W | 428 movf ext_flash_dive_counter+0,W |
368 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 429 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
369 movf ext_flash_dive_counter+1,W | 430 movf ext_flash_dive_counter+1,W |
370 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 431 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
371 movf ext_flash_dive_counter+2,W | 432 movf ext_flash_dive_counter+2,W |
372 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page | 433 call write_byte_ext_flash_plus_nodel ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) and does NOT delete 4kB page |
373 | 434 |
374 ; profile recording done. | 435 ; profile recording done. |
375 | 436 |
376 ; Load total number of dives | 437 ; Load total number of dives |
377 read_int_eeprom .2 | 438 read_int_eeprom .2 |
378 movff EEDATA,lo | 439 movff EEDATA,lo |
379 read_int_eeprom .3 | 440 read_int_eeprom .3 |
380 movff EEDATA,hi | 441 movff EEDATA,hi |
381 ; +1 increase total dive counter | 442 ; +1 ; increase total dive counter |
382 infsnz lo,F | 443 infsnz lo,F |
383 incf hi,F | 444 incf hi,F |
384 ; Store new number in EEPROM | 445 ; Store new number in EEPROM |
385 movff lo,EEDATA | 446 movff lo,EEDATA |
386 write_int_eeprom .2 | 447 write_int_eeprom .2 |
387 movff hi,EEDATA | 448 movff hi,EEDATA |
388 write_int_eeprom .3 | 449 write_int_eeprom .3 |
389 | 450 |
390 decf lo,F ; -1 | 451 decf lo,F ; -1 |
452 | |
391 ; Set ext_flash_address:3 to TOC entry of this dive | 453 ; Set ext_flash_address:3 to TOC entry of this dive |
392 ; 1st: 200000h-200FFFh -> lo=0 | 454 ; 1st: 200000h-200FFFh -> lo=0 |
393 ; 2nd: 201000h-201FFFh -> lo=1 | 455 ; 2nd: 201000h-201FFFh -> lo=1 |
394 ; 3rd: 202000h-202FFFh -> lo=2 | 456 ; 3rd: 202000h-202FFFh -> lo=2 |
395 ; 255: 2FF000h-2FFFFFh -> lo=255 | 457 ; 255: 2FF000h-2FFFFFh -> lo=255 |
397 clrf ext_flash_address+0 | 459 clrf ext_flash_address+0 |
398 clrf ext_flash_address+1 | 460 clrf ext_flash_address+1 |
399 movlw 0x20 | 461 movlw 0x20 |
400 movwf ext_flash_address+2 | 462 movwf ext_flash_address+2 |
401 movlw .16 | 463 movlw .16 |
402 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | 464 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) |
403 movf PRODL,W | 465 movf PRODL,W |
404 addwf ext_flash_address+1,F | 466 addwf ext_flash_address+1,F |
405 movf PRODH,W | 467 movf PRODH,W |
406 addwfc ext_flash_address+2,F | 468 addwfc ext_flash_address+2,F |
407 | 469 |
408 ; Now, write header | 470 ; Now, write header |
409 | 471 |
410 movlw 0xFA ; Header start | 472 movlw 0xFA ; Header start |
411 rcall ghostwrite_byte_header ; (This call will also delete the 4kB TOC entry first) | 473 rcall ghostwrite_byte_header ; (This call will also delete the 4kB TOC entry first) |
412 movlw 0xFA | 474 movlw 0xFA |
413 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 475 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
414 | 476 |
415 ; store pointer to begin of diveprofile | 477 ; store pointer to begin of dive profile |
416 read_int_eeprom .4 | 478 read_int_eeprom .4 |
417 movf EEDATA,W | 479 movf EEDATA,W |
418 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 480 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
419 read_int_eeprom .5 | 481 read_int_eeprom .5 |
420 movf EEDATA,W | 482 movf EEDATA,W |
421 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 483 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
422 read_int_eeprom .6 | 484 read_int_eeprom .6 |
423 movf EEDATA,W | 485 movf EEDATA,W |
424 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 486 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
425 | 487 |
426 ; store pointer to end of diveprofile | 488 ; store pointer to end of dive profile |
427 movf ext_flash_log_pointer+0,W | 489 movf ext_flash_log_pointer+0,W |
428 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 490 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
429 movf ext_flash_log_pointer+1,W | 491 movf ext_flash_log_pointer+1,W |
430 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 492 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
431 movf ext_flash_log_pointer+2,W | 493 movf ext_flash_log_pointer+2,W |
432 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 494 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
433 | 495 |
434 ; write rest of header | 496 ; write rest of header |
435 movlw logbook_profile_version ; Defined in hwos.inc | 497 movlw logbook_profile_version ; Defined in hwos.inc |
436 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 498 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
437 | 499 |
438 ; Store dive length | 500 ; Store dive length |
439 movf ext_flash_dive_counter+0,W | 501 movf ext_flash_dive_counter+0,W |
440 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 502 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
441 movf ext_flash_dive_counter+1,W | 503 movf ext_flash_dive_counter+1,W |
442 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 504 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
443 movf ext_flash_dive_counter+2,W | 505 movf ext_flash_dive_counter+2,W |
444 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 506 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
445 | 507 |
446 movff start_year,WREG ; Date | 508 movff start_year,WREG ; Date |
447 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 509 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
448 movff start_month,WREG | 510 movff start_month,WREG |
449 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 511 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
450 movff start_day,WREG | 512 movff start_day,WREG |
451 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 513 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
452 movff start_hours,WREG ; Start of dive time | 514 movff start_hours,WREG ; Start of dive time |
453 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 515 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
454 movff start_mins,WREG | 516 movff start_mins,WREG |
455 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 517 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
456 | 518 |
457 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | 519 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) |
458 bra end_dive1 ; Store normal depth | 520 bra end_dive1 ; Store normal depth |
459 | 521 |
460 movff apnoe_max_pressure+0,lo | 522 movff apnoe_max_pressure+0,lo |
461 movff apnoe_max_pressure+1,hi | 523 movff apnoe_max_pressure+1,hi |
462 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 524 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
463 movff lo,apnoe_max_pressure+0 | 525 movff lo,apnoe_max_pressure+0 |
464 movff hi,apnoe_max_pressure+1 | 526 movff hi,apnoe_max_pressure+1 |
465 | 527 |
466 movf apnoe_max_pressure+0,W ; Max. depth | 528 movf apnoe_max_pressure+0,W ; Max. depth |
467 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 529 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
468 movf apnoe_max_pressure+1,W | 530 movf apnoe_max_pressure+1,W |
469 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 531 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
470 bra end_dive2 ; skip normal max. depth | 532 bra end_dive2 ; skip normal max. depth |
471 | 533 |
472 end_dive1: | 534 end_dive1: |
473 movff max_pressure+0,lo | 535 movff max_pressure+0,lo |
474 movff max_pressure+1,hi | 536 movff max_pressure+1,hi |
475 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 537 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
476 movff lo,max_pressure+0 | 538 movff lo,max_pressure+0 |
477 movff hi,max_pressure+1 | 539 movff hi,max_pressure+1 |
478 | 540 |
479 movff max_pressure+0,WREG ; Max. depth | 541 movff max_pressure+0,WREG ; Max. depth |
480 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 542 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
481 movff max_pressure+1,WREG | 543 movff max_pressure+1,WREG |
482 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 544 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
483 | 545 |
484 end_dive2: | 546 end_dive2: |
485 movf divemins+0,W ; divetime minutes | 547 movf divemins+0,W ; dive time minutes |
486 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 548 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
487 movf divemins+1,W | 549 movf divemins+1,W |
488 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 550 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
489 movf divesecs,W ; divetime seconds | 551 movf divesecs,W ; dive time seconds |
490 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 552 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
491 movff minimum_temperature+0,WREG ; minimum temperature | 553 movff minimum_temperature+0,WREG ; minimum temperature |
492 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 554 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
493 movff minimum_temperature+1,WREG | 555 movff minimum_temperature+1,WREG |
494 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 556 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
495 movff last_surfpressure_30min+0,WREG ; airpressure before dive | 557 movff last_surfpressure_30min+0,WREG ; air pressure before dive |
496 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 558 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
497 movff last_surfpressure_30min+1,WREG | 559 movff last_surfpressure_30min+1,WREG |
498 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 560 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
499 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes | 561 movff int_O_desaturation_time+0,WREG ; desaturation time in minutes |
500 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 562 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
501 movff int_O_desaturation_time+1,WREG | 563 movff int_O_desaturation_time+1,WREG |
502 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 564 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
503 | 565 |
504 btfss FLAG_ccr_mode ; In CCR mode... | 566 btfss FLAG_ccr_mode ; In CCR mode... |
505 bra end_dive_oc_gaslist ; No, write OC gases | 567 bra end_dive_oc_gaslist ; No, write OC gases |
506 ; Write Diluents... | 568 ; Write Diluents... |
507 movff opt_dil_O2_ratio+0,WREG | 569 movff opt_dil_O2_ratio+0,WREG |
508 rcall ghostwrite_byte_header ; %O2 | 570 rcall ghostwrite_byte_header ; %O2 |
509 movff opt_dil_He_ratio+0,WREG | 571 movff opt_dil_He_ratio+0,WREG |
510 rcall ghostwrite_byte_header ; %He | 572 rcall ghostwrite_byte_header ; %He |
511 movff char_I_dil_change+0,WREG | 573 movff char_I_dil_change+0,WREG |
512 rcall ghostwrite_byte_header ; Configured change depth in m | 574 rcall ghostwrite_byte_header ; Configured change depth in m |
513 movff opt_dil_type+0,WREG | 575 movff opt_dil_type+0,WREG |
514 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 576 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal |
515 | 577 |
516 movff opt_dil_O2_ratio+1,WREG | 578 movff opt_dil_O2_ratio+1,WREG |
517 rcall ghostwrite_byte_header ; %O2 | 579 rcall ghostwrite_byte_header ; %O2 |
518 movff opt_dil_He_ratio+1,WREG | 580 movff opt_dil_He_ratio+1,WREG |
519 rcall ghostwrite_byte_header ; %He | 581 rcall ghostwrite_byte_header ; %He |
520 movff char_I_dil_change+1,WREG | 582 movff char_I_dil_change+1,WREG |
521 rcall ghostwrite_byte_header ; Configured change depth in m | 583 rcall ghostwrite_byte_header ; Configured change depth in m |
522 movff opt_dil_type+1,WREG | 584 movff opt_dil_type+1,WREG |
523 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 585 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal |
524 | 586 |
525 movff opt_dil_O2_ratio+2,WREG | 587 movff opt_dil_O2_ratio+2,WREG |
526 rcall ghostwrite_byte_header ; %O2 | 588 rcall ghostwrite_byte_header ; %O2 |
527 movff opt_dil_He_ratio+2,WREG | 589 movff opt_dil_He_ratio+2,WREG |
528 rcall ghostwrite_byte_header ; %He | 590 rcall ghostwrite_byte_header ; %He |
529 movff char_I_dil_change+2,WREG | 591 movff char_I_dil_change+2,WREG |
530 rcall ghostwrite_byte_header ; Configured change depth in m | 592 rcall ghostwrite_byte_header ; Configured change depth in m |
531 movff opt_dil_type+2,WREG | 593 movff opt_dil_type+2,WREG |
532 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 594 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal |
533 | 595 |
534 movff opt_dil_O2_ratio+3,WREG | 596 movff opt_dil_O2_ratio+3,WREG |
535 rcall ghostwrite_byte_header ; %O2 | 597 rcall ghostwrite_byte_header ; %O2 |
536 movff opt_dil_He_ratio+3,WREG | 598 movff opt_dil_He_ratio+3,WREG |
537 rcall ghostwrite_byte_header ; %He | 599 rcall ghostwrite_byte_header ; %He |
538 movff char_I_dil_change+3,WREG | 600 movff char_I_dil_change+3,WREG |
539 rcall ghostwrite_byte_header ; Configured change depth in m | 601 rcall ghostwrite_byte_header ; Configured change depth in m |
540 movff opt_dil_type+3,WREG | 602 movff opt_dil_type+3,WREG |
541 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 603 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal |
542 | 604 |
543 movff opt_dil_O2_ratio+4,WREG | 605 movff opt_dil_O2_ratio+4,WREG |
544 rcall ghostwrite_byte_header ; %O2 | 606 rcall ghostwrite_byte_header ; %O2 |
545 movff opt_dil_He_ratio+4,WREG | 607 movff opt_dil_He_ratio+4,WREG |
546 rcall ghostwrite_byte_header ; %He | 608 rcall ghostwrite_byte_header ; %He |
547 movff char_I_dil_change+4,WREG | 609 movff char_I_dil_change+4,WREG |
548 rcall ghostwrite_byte_header ; Configured change depth in m | 610 rcall ghostwrite_byte_header ; Configured change depth in m |
549 movff opt_dil_type+4,WREG | 611 movff opt_dil_type+4,WREG |
550 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal | 612 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2=Normal |
551 bra end_dive_oc_cc_common | 613 bra end_dive_oc_cc_common |
552 | 614 |
553 end_dive_oc_gaslist: ; OC Gases... | 615 end_dive_oc_gaslist: ; OC Gases... |
554 movff opt_gas_O2_ratio+0,WREG | 616 movff opt_gas_O2_ratio+0,WREG |
555 rcall ghostwrite_byte_header ; %O2 | 617 rcall ghostwrite_byte_header ; %O2 |
556 movff opt_gas_He_ratio+0,WREG | 618 movff opt_gas_He_ratio+0,WREG |
557 rcall ghostwrite_byte_header ; %He | 619 rcall ghostwrite_byte_header ; %He |
558 movff opt_OC_bail_gas_change+0,WREG | 620 movff opt_OC_bail_gas_change+0,WREG |
559 rcall ghostwrite_byte_header ; Configured change depth in m | 621 rcall ghostwrite_byte_header ; Configured change depth in m |
560 movff opt_gas_type+0,WREG | 622 movff opt_gas_type+0,WREG |
561 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 623 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
562 | 624 |
563 movff opt_gas_O2_ratio+1,WREG | 625 movff opt_gas_O2_ratio+1,WREG |
564 rcall ghostwrite_byte_header ; %O2 | 626 rcall ghostwrite_byte_header ; %O2 |
565 movff opt_gas_He_ratio+1,WREG | 627 movff opt_gas_He_ratio+1,WREG |
566 rcall ghostwrite_byte_header ; %He | 628 rcall ghostwrite_byte_header ; %He |
567 movff opt_OC_bail_gas_change+1,WREG | 629 movff opt_OC_bail_gas_change+1,WREG |
568 rcall ghostwrite_byte_header ; Configured change depth in m | 630 rcall ghostwrite_byte_header ; Configured change depth in m |
569 movff opt_gas_type+1,WREG | 631 movff opt_gas_type+1,WREG |
570 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 632 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
571 | 633 |
572 movff opt_gas_O2_ratio+2,WREG | 634 movff opt_gas_O2_ratio+2,WREG |
573 rcall ghostwrite_byte_header ; %O2 | 635 rcall ghostwrite_byte_header ; %O2 |
574 movff opt_gas_He_ratio+2,WREG | 636 movff opt_gas_He_ratio+2,WREG |
575 rcall ghostwrite_byte_header ; %He | 637 rcall ghostwrite_byte_header ; %He |
576 movff opt_OC_bail_gas_change+2,WREG | 638 movff opt_OC_bail_gas_change+2,WREG |
577 rcall ghostwrite_byte_header ; Configured change depth in m | 639 rcall ghostwrite_byte_header ; Configured change depth in m |
578 movff opt_gas_type+2,WREG | 640 movff opt_gas_type+2,WREG |
579 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 641 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
580 | 642 |
581 movff opt_gas_O2_ratio+3,WREG | 643 movff opt_gas_O2_ratio+3,WREG |
582 rcall ghostwrite_byte_header ; %O2 | 644 rcall ghostwrite_byte_header ; %O2 |
583 movff opt_gas_He_ratio+3,WREG | 645 movff opt_gas_He_ratio+3,WREG |
584 rcall ghostwrite_byte_header ; %He | 646 rcall ghostwrite_byte_header ; %He |
585 movff opt_OC_bail_gas_change+3,WREG | 647 movff opt_OC_bail_gas_change+3,WREG |
586 rcall ghostwrite_byte_header ; Configured change depth in m | 648 rcall ghostwrite_byte_header ; Configured change depth in m |
587 movff opt_gas_type+3,WREG | 649 movff opt_gas_type+3,WREG |
588 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 650 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
589 | 651 |
590 movff opt_gas_O2_ratio+4,WREG | 652 movff opt_gas_O2_ratio+4,WREG |
591 rcall ghostwrite_byte_header ; %O2 | 653 rcall ghostwrite_byte_header ; %O2 |
592 movff opt_gas_He_ratio+4,WREG | 654 movff opt_gas_He_ratio+4,WREG |
593 rcall ghostwrite_byte_header ; %He | 655 rcall ghostwrite_byte_header ; %He |
594 movff opt_OC_bail_gas_change+4,WREG | 656 movff opt_OC_bail_gas_change+4,WREG |
595 rcall ghostwrite_byte_header ; Configured change depth in m | 657 rcall ghostwrite_byte_header ; Configured change depth in m |
596 movff opt_gas_type+4,WREG | 658 movff opt_gas_type+4,WREG |
597 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco | 659 rcall ghostwrite_byte_header ; 0=Disabled, 1=First, 2= Travel, 3= Deco |
598 ; bra end_dive_oc_cc_common | 660 ; bra end_dive_oc_cc_common |
599 | 661 |
600 end_dive_oc_cc_common: | 662 end_dive_oc_cc_common: |
601 movlw softwareversion_x ; Firmware version | 663 movlw softwareversion_x ; Firmware version |
602 rcall ghostwrite_byte_header | 664 rcall ghostwrite_byte_header |
603 movlw softwareversion_y | 665 movlw softwareversion_y |
604 rcall ghostwrite_byte_header | 666 rcall ghostwrite_byte_header |
605 movf batt_voltage+0,W ; Battery voltage | 667 movf batt_voltage+0,W ; Battery voltage |
606 rcall ghostwrite_byte_header | 668 rcall ghostwrite_byte_header |
607 movf batt_voltage+1,W | 669 movf batt_voltage+1,W |
608 rcall ghostwrite_byte_header | 670 rcall ghostwrite_byte_header |
609 | 671 |
610 movf samplingrate,W ; Sampling rate | 672 movf samplingrate,W ; Sampling rate |
611 btfsc FLAG_apnoe_mode ; Apnoe mode? | 673 btfsc FLAG_apnoe_mode ; Apnoe mode? |
612 movlw samplingrate_apnoe ; Apnoe sampling rate | 674 movlw samplingrate_apnoe ; Apnoe sampling rate |
613 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 675 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
614 | 676 |
615 ; CNS at beginning of dive | 677 ; CNS at beginning of dive |
616 movff CNS_start+0,WREG | 678 movff CNS_start+0,WREG |
617 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 679 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
618 movff CNS_start+1,WREG | 680 movff CNS_start+1,WREG |
619 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 681 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
620 ; Gradient factor | 682 ; Gradient factor |
621 movff GF_start,WREG | 683 movff GF_start,WREG |
622 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 684 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
623 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use | 685 movff int_O_gradient_factor+0,WREG ; value limited to 255, only lower byte in use |
624 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 686 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
625 | 687 |
626 ; Logbook offset | 688 ; Logbook offset |
627 call do_logoffset_common_read; Read into lo:hi | 689 call do_logoffset_common_read ; Read into lo:hi |
628 movf lo,W | 690 movf lo,W |
629 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 691 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
630 movf hi,W | 692 movf hi,W |
631 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 693 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
632 | 694 |
633 ; Battery info at Byte 59 | 695 ; Battery info at Byte 59 |
634 movf batt_percent,W ; 0-100 | 696 movf batt_percent,W ; 0-100 |
635 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 697 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
636 ; Store 5 Setpoints | 698 ; Store 5 Setpoints |
637 movff char_I_setpoint_cbar+0,WREG | 699 movff char_I_setpoint_cbar+0,WREG |
638 rcall ghostwrite_byte_header ; Setpoint in cbar | 700 rcall ghostwrite_byte_header ; Setpoint in cbar |
639 movff char_I_setpoint_change+0,WREG | 701 movff char_I_setpoint_change+0,WREG |
640 rcall ghostwrite_byte_header ; Change depth | 702 rcall ghostwrite_byte_header ; Change depth |
641 movff char_I_setpoint_cbar+1,WREG | 703 movff char_I_setpoint_cbar+1,WREG |
642 rcall ghostwrite_byte_header ; Setpoint in cbar | 704 rcall ghostwrite_byte_header ; Setpoint in cbar |
643 movff char_I_setpoint_change+1,WREG | 705 movff char_I_setpoint_change+1,WREG |
644 rcall ghostwrite_byte_header ; Change depth | 706 rcall ghostwrite_byte_header ; Change depth |
645 movff char_I_setpoint_cbar+2,WREG | 707 movff char_I_setpoint_cbar+2,WREG |
646 rcall ghostwrite_byte_header ; Setpoint in cbar | 708 rcall ghostwrite_byte_header ; Setpoint in cbar |
647 movff char_I_setpoint_change+2,WREG | 709 movff char_I_setpoint_change+2,WREG |
648 rcall ghostwrite_byte_header ; Change depth | 710 rcall ghostwrite_byte_header ; Change depth |
649 movff char_I_setpoint_cbar+3,WREG | 711 movff char_I_setpoint_cbar+3,WREG |
650 rcall ghostwrite_byte_header ; Setpoint in cbar | 712 rcall ghostwrite_byte_header ; Setpoint in cbar |
651 movff char_I_setpoint_change+3,WREG | 713 movff char_I_setpoint_change+3,WREG |
652 rcall ghostwrite_byte_header ; Change depth | 714 rcall ghostwrite_byte_header ; Change depth |
653 movff char_I_setpoint_cbar+4,WREG | 715 movff char_I_setpoint_cbar+4,WREG |
654 rcall ghostwrite_byte_header ; Setpoint in cbar | 716 rcall ghostwrite_byte_header ; Setpoint in cbar |
655 movff char_I_setpoint_change+4,WREG | 717 movff char_I_setpoint_change+4,WREG |
656 rcall ghostwrite_byte_header ; Change depth | 718 rcall ghostwrite_byte_header ; Change depth |
657 | 719 |
658 movff opt_salinity,WREG ; Salinity (0-4%) | 720 movff opt_salinity,WREG ; Salinity (0-4%) |
659 rcall ghostwrite_byte_header ; Store Salinity to Dive | 721 rcall ghostwrite_byte_header ; Store Salinity to Dive |
660 | 722 |
661 movff int_O_CNS_fraction+0,WREG ; copy into bank1 | 723 movff int_O_CNS_fraction+0,WREG ; copy into bank1 |
662 rcall ghostwrite_byte_header; Stores CNS% | 724 rcall ghostwrite_byte_header ; Stores CNS% |
663 movff int_O_CNS_fraction+1,WREG ; copy into bank1 | 725 movff int_O_CNS_fraction+1,WREG ; copy into bank1 |
664 rcall ghostwrite_byte_header; Stores CNS% | 726 rcall ghostwrite_byte_header ; Stores CNS% |
665 | 727 |
666 movff avg_rel_pressure_total+0,WREG ; Average Depth | 728 movff avg_rel_pressure_total+0,WREG ; Average Depth |
667 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 729 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
668 movff avg_rel_pressure_total+1,WREG ; Average Depth | 730 movff avg_rel_pressure_total+1,WREG ; Average Depth |
669 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 731 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
670 | 732 |
671 movff total_divetime_seconds+0,WREG ; Total dive time (Regardless of start_dive_threshold) | 733 movff total_divetime_seconds+0,WREG ; Total dive time (Regardless of start_dive_threshold) |
672 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 734 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
673 movff total_divetime_seconds+1,WREG ; Total dive time (Regardless of start_dive_threshold) | 735 movff total_divetime_seconds+1,WREG ; Total dive time (Regardless of start_dive_threshold) |
674 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 736 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
675 | 737 |
676 movff char_I_GF_Low_percentage,WREG ; GF_lo | 738 movff char_I_GF_Low_percentage,WREG ; GF_lo |
677 movff char_I_deco_model,lo | 739 movff char_I_deco_model,lo |
678 decfsz lo,F ; jump over next line if char_I_deco_model == 1 | 740 decfsz lo,F ; jump over next line if char_I_deco_model == 1 |
679 movff char_I_saturation_multiplier,WREG ; Saturation Multiplier | 741 movff char_I_saturation_multiplier,WREG ; Saturation Multiplier |
680 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 742 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
681 | 743 |
682 movff char_I_GF_High_percentage,WREG ; GF_hi | 744 movff char_I_GF_High_percentage,WREG ; GF_hi |
683 movff char_I_deco_model,lo | 745 movff char_I_deco_model,lo |
684 decfsz lo,F ; jump over next line if char_I_deco_model == 1 | 746 decfsz lo,F ; jump over next line if char_I_deco_model == 1 |
685 movff char_I_desaturation_multiplier,WREG ; Desaturation Multiplier | 747 movff char_I_desaturation_multiplier,WREG ; Desaturation Multiplier |
686 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 748 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
687 | 749 |
688 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | 750 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF |
689 rcall ghostwrite_byte_header; writes byte and increases address (no banking) | 751 rcall ghostwrite_byte_header ; writes byte and increases address (no banking) |
690 | 752 |
691 read_int_eeprom .2 | 753 read_int_eeprom .2 |
692 movf EEDATA,W | 754 movf EEDATA,W |
693 rcall ghostwrite_byte_header ; Total dive counter, low | 755 rcall ghostwrite_byte_header ; Total dive counter, low |
694 read_int_eeprom .3 | 756 read_int_eeprom .3 |
695 movf EEDATA,W | 757 movf EEDATA,W |
696 rcall ghostwrite_byte_header ; Total dive counter, high | 758 rcall ghostwrite_byte_header ; Total dive counter, high |
697 | 759 |
698 movff opt_dive_mode,WREG | 760 movff opt_dive_mode,WREG |
699 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | 761 rcall ghostwrite_byte_header ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR |
700 | 762 |
701 ; Store all tissue data available | 763 ; Store all tissue data available |
702 movlw .16 | 764 movlw .16 |
703 movwf lo | 765 movwf lo |
704 lfsr FSR1,char_O_tissue_N2_saturation+0 | 766 lfsr FSR1,char_O_tissue_N2_saturation+0 |
705 end_dive_store_tissues_N2: | 767 end_dive_store_tissues_N2: |
706 movf POSTINC1,W | 768 movf POSTINC1,W |
707 bcf WREG,7 ; clear flag bit for ongassing/offgassing | 769 bcf WREG,7 ; clear flag bit for ongassing/offgassing |
708 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 770 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
709 decfsz lo,F | 771 decfsz lo,F |
710 bra end_dive_store_tissues_N2 ; No | 772 bra end_dive_store_tissues_N2 ; No |
711 | 773 |
712 movlw .64 | 774 movlw .64 |
713 movwf lo | 775 movwf lo |
714 lfsr FSR1,0x700;pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes | 776 lfsr FSR1,0x700 ; pres_tissue_N2+0 ; 16*4Byte Float = 64Bytes |
715 end_dive_store_tissues_N2_2: | 777 end_dive_store_tissues_N2_2: |
716 movf POSTINC1,W | 778 movf POSTINC1,W |
717 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 779 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
718 decfsz lo,F | 780 decfsz lo,F |
719 bra end_dive_store_tissues_N2_2 ; No | 781 bra end_dive_store_tissues_N2_2 ; No |
720 | 782 |
721 movlw .16 | 783 movlw .16 |
722 movwf lo | 784 movwf lo |
723 lfsr FSR1,char_O_tissue_He_saturation+0 | 785 lfsr FSR1,char_O_tissue_He_saturation+0 |
724 end_dive_store_tissues_He: | 786 end_dive_store_tissues_He: |
725 movf POSTINC1,W | 787 movf POSTINC1,W |
726 bcf WREG,7 ; clear flag bit for ongassing/offgassing | 788 bcf WREG,7 ; clear flag bit for ongassing/offgassing |
727 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 789 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
728 decfsz lo,F | 790 decfsz lo,F |
729 bra end_dive_store_tissues_He ; No | 791 bra end_dive_store_tissues_He ; No |
730 | 792 |
731 movlw .64 | 793 movlw .64 |
732 movwf lo | 794 movwf lo |
733 lfsr FSR1,0x740;pres_tissue_He+0 ; 16*4Byte Float = 64Bytes | 795 lfsr FSR1,0x740 ; pres_tissue_He+0 ; 16*4Byte Float = 64Bytes |
734 end_dive_store_tissues_He_2: | 796 end_dive_store_tissues_He_2: |
735 movf POSTINC1,W | 797 movf POSTINC1,W |
736 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 798 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
737 decfsz lo,F | 799 decfsz lo,F |
738 bra end_dive_store_tissues_He_2 ; No | 800 bra end_dive_store_tissues_He_2 ; No |
739 | 801 |
740 ; Some deco stuff | 802 ; Some deco stuff |
741 movff char_I_depth_last_deco,WREG ; last stop [m] | 803 movff char_I_depth_last_deco,WREG ; last stop [m] |
742 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 804 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
743 movff char_I_deco_distance,WREG ; assumed distance to shown stop | 805 movff char_I_deco_distance,WREG ; assumed distance to shown stop |
744 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 806 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
745 | 807 |
746 ; Last HUD data | 808 ; Last HUD data |
747 movff hud_battery_mv+0,WREG ; Last HUD battery value | 809 movff hud_battery_mv+0,WREG ; Last HUD battery value |
748 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 810 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
749 movff hud_battery_mv+1,WREG ; Last HUD battery value | 811 movff hud_battery_mv+1,WREG ; Last HUD battery value |
750 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 812 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
751 movff hud_status_byte,WREG ; Last HUD status | 813 movff hud_status_byte,WREG ; Last HUD status |
752 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 814 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
753 | 815 |
754 ; Battery gauge registers [nAs] | 816 ; Battery gauge registers [nAs] |
755 movff battery_gauge+0,WREG ; Battery gauge register | 817 movff battery_gauge+0,WREG ; Battery gauge register |
756 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 818 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
757 movff battery_gauge+1,WREG ; Battery gauge register | 819 movff battery_gauge+1,WREG ; Battery gauge register |
758 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 820 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
759 movff battery_gauge+2,WREG ; Battery gauge register | 821 movff battery_gauge+2,WREG ; Battery gauge register |
760 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 822 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
761 movff battery_gauge+3,WREG ; Battery gauge register | 823 movff battery_gauge+3,WREG ; Battery gauge register |
762 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 824 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
763 movff battery_gauge+4,WREG ; Battery gauge register | 825 movff battery_gauge+4,WREG ; Battery gauge register |
764 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 826 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
765 movff battery_gauge+5,WREG ; Battery gauge register | 827 movff battery_gauge+5,WREG ; Battery gauge register |
766 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 828 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
767 | 829 |
768 ; Header stop | 830 ; Header stop |
769 movlw 0xFB | 831 movlw 0xFB |
770 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 832 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
771 movlw 0xFB | 833 movlw 0xFB |
772 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash | 834 rcall ghostwrite_byte_header ; WREG -> Header in ext. flash |
773 | 835 |
774 call divemode_store_statistics ; Store/update statistics for this unit | 836 call divemode_store_statistics ; Store/update statistics for this unit |
775 | 837 |
776 clrf surface_interval+0 | 838 clrf surface_interval+0 |
777 clrf surface_interval+1 ; Clear surface interval timer | 839 clrf surface_interval+1 ; Clear surface interval timer |
778 | 840 |
779 ghostwriter_end_dive_common: | 841 ghostwriter_end_dive_common: |
780 ; Update ext_flash_log_pointer into EEPROM | 842 ; Update ext_flash_log_pointer into EEPROM |
781 clrf EEADRH | 843 clrf EEADRH |
782 movff ext_flash_log_pointer+0,EEDATA | 844 movff ext_flash_log_pointer+0,EEDATA |
784 movff ext_flash_log_pointer+1,EEDATA | 846 movff ext_flash_log_pointer+1,EEDATA |
785 write_int_eeprom .5 | 847 write_int_eeprom .5 |
786 movff ext_flash_log_pointer+2,EEDATA | 848 movff ext_flash_log_pointer+2,EEDATA |
787 write_int_eeprom .6 | 849 write_int_eeprom .6 |
788 | 850 |
789 bcf simulatormode_active ; if we were in simulator mode | 851 bcf simulatormode_active ; if we were in simulator mode |
790 | 852 |
791 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... | 853 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
792 ifndef __DEBUG | 854 ifndef __DEBUG |
793 extern deco_pull_tissues_from_vault | 855 extern deco_pull_tissues_from_vault |
794 btfsc restore_deco_data ; Restore decodata? | 856 btfsc restore_deco_data ; Restore decodata? |
795 call deco_pull_tissues_from_vault | 857 call deco_pull_tissues_from_vault |
796 banksel common ; Bank1 | 858 banksel common ; Bank1 |
797 endif | 859 endif |
798 call update_battery_registers ; update battery registers into EEPROM | 860 call update_battery_registers ; update battery registers into EEPROM |
799 goto surfloop ; and return to surfaceloop | 861 goto surfloop ; and return to surface loop |
800 | 862 |
801 ghostwriter_end_dive_common_sim: | 863 ghostwriter_end_dive_common_sim: |
802 tstfsz surface_interval+0 ; Was interval zero? | 864 tstfsz surface_interval+0 ; Was interval zero? |
803 bra ghostwriter_end_dive_common_sim2 ; No | 865 bra ghostwriter_end_dive_common_sim2 ; No |
804 tstfsz surface_interval+1 ; Was interval zero? | 866 tstfsz surface_interval+1 ; Was interval zero? |
805 bra ghostwriter_end_dive_common_sim2 ; No | 867 bra ghostwriter_end_dive_common_sim2 ; No |
806 bra ghostwriter_end_dive_common ; Yes, done. | 868 bra ghostwriter_end_dive_common ; Yes, done. |
807 | 869 |
808 ghostwriter_end_dive_common_sim2: | 870 ghostwriter_end_dive_common_sim2: |
809 movf divemins+0,W | 871 movf divemins+0,W |
810 addwf surface_interval+0,F | 872 addwf surface_interval+0,F |
811 movf divemins+1,W | 873 movf divemins+1,W |
812 addwfc surface_interval+1 ; Add simulated divetime to surface interval | 874 addwfc surface_interval+1 ; Add simulated dive time to surface interval |
813 bra ghostwriter_end_dive_common | 875 bra ghostwriter_end_dive_common |
814 | 876 |
815 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6 | 877 ghostwriter_load_pointer: ; Load ext_flash_address:3 from EEPROM .4-.6 |
816 clrf EEADRH ; Make sure to select eeprom bank 0 | 878 clrf EEADRH ; Make sure to select EEPROM bank 0 |
817 read_int_eeprom .4 | 879 read_int_eeprom .4 |
818 movff EEDATA,ext_flash_address+0 | 880 movff EEDATA,ext_flash_address+0 |
819 read_int_eeprom .5 | 881 read_int_eeprom .5 |
820 movff EEDATA,ext_flash_address+1 | 882 movff EEDATA,ext_flash_address+1 |
821 read_int_eeprom .6 | 883 read_int_eeprom .6 |
822 movff EEDATA,ext_flash_address+2 | 884 movff EEDATA,ext_flash_address+2 |
823 return | 885 return |
824 | 886 |
825 ghostwriter_short_header_init: ; Proceed one page forward | 887 ghostwriter_short_header_init: ; Proceed one page forward |
826 clrf EEDATA | 888 clrf EEDATA |
827 write_int_eeprom .4 ; ext_flash_address+0 = 0 | 889 write_int_eeprom .4 ; ext_flash_address+0 = 0 |
828 movlw .16 | 890 movlw .16 |
829 addwf ext_flash_address+1,F | 891 addwf ext_flash_address+1,F |
830 movlw .0 | 892 movlw .0 |
831 addwfc ext_flash_address+2,F | 893 addwfc ext_flash_address+2,F |
832 movlw 0x20 | 894 movlw 0x20 |
833 cpfseq ext_flash_address+2 ; at address 0x200000? | 895 cpfseq ext_flash_address+2 ; at address 0x200000? |
834 bra ghostwriter_short_header_init2 ; No | 896 bra ghostwriter_short_header_init2 ; No |
835 clrf ext_flash_address+2 ; Yes, rollover to 0x000000 | 897 clrf ext_flash_address+2 ; Yes, rollover to 0x000000 |
836 ghostwriter_short_header_init2: | 898 ghostwriter_short_header_init2: |
837 movlw 0xF0 | 899 movlw 0xF0 |
838 andwf ext_flash_address+1,F ; keep higher nibble, set lower nibble to 0 | 900 andwf ext_flash_address+1,F ; keep higher nibble, set lower nibble to 0 |
839 | 901 |
840 movff ext_flash_address+1,EEDATA | 902 movff ext_flash_address+1,EEDATA |
841 write_int_eeprom .5 ; Write new pointer | 903 write_int_eeprom .5 ; Write new pointer |
842 movff ext_flash_address+2,EEDATA | 904 movff ext_flash_address+2,EEDATA |
843 write_int_eeprom .6 ; Write new pointer | 905 write_int_eeprom .6 ; Write new pointer |
844 bra ghostwriter_short_header2 ; Done. | 906 bra ghostwriter_short_header2 ; Done. |
845 | 907 |
846 global ghostwriter_short_header | 908 global ghostwriter_short_header |
847 ghostwriter_short_header: ; Write short header with divenumber into profile memory | 909 ghostwriter_short_header: ; Write short header with dive number into profile memory |
848 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive) | 910 ; load pointer for profile storing into RAM (Updated in EEPROM after the dive) |
849 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 911 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 |
850 | 912 |
851 ; The following code is used to write a clean new dive after the previous hasn't been | 913 ; The following code is used to write a clean new dive after the previous hasn't been |
852 ; stored correctly. e.g. after a battery fail during the dive | 914 ; stored correctly. e.g. after a battery fail during the dive |
853 call ext_flash_byte_read_plus_0x20 ; Into temp1 | 915 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw |
854 incfsz temp1,F | 916 incfsz ext_flash_rw,F |
855 bra ghostwriter_short_header_init ; Not 0xFF -> init page | 917 bra ghostwriter_short_header_init ; Not 0xFF -> init page |
856 call ext_flash_byte_read_plus_0x20 ; Into temp1 | 918 call ext_flash_byte_read_plus_0x20 ; Into ext_flash_rw |
857 incfsz temp1,F | 919 incfsz ext_flash_rw,F |
858 bra ghostwriter_short_header_init ; Not 0xFF -> init page | 920 bra ghostwriter_short_header_init ; Not 0xFF -> init page |
859 | 921 |
860 ghostwriter_short_header2: | 922 ghostwriter_short_header2: |
861 ; All ok, reload the pointer and start | 923 ; All ok, reload the pointer and start |
862 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 | 924 rcall ghostwriter_load_pointer ; Load ext_flash_address:3 from EEPROM .4-.6 |
863 | 925 |
864 ; Clear dive length counter | 926 ; Clear dive length counter |
865 clrf ext_flash_dive_counter+0 | 927 clrf ext_flash_dive_counter+0 |
866 clrf ext_flash_dive_counter+1 | 928 clrf ext_flash_dive_counter+1 |
867 clrf ext_flash_dive_counter+2 | 929 clrf ext_flash_dive_counter+2 |
868 | 930 |
869 ; Write short header with divenumber into profile memory | 931 ; Write short header with dive number into profile memory |
870 movlw 0xFA | 932 movlw 0xFA |
871 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 933 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
872 movlw 0xFA | 934 movlw 0xFA |
873 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 935 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
874 ; Load total number of dives (low byte only) | 936 ; Load total number of dives (low byte only) |
875 read_int_eeprom .2 | 937 read_int_eeprom .2 |
876 incf EEDATA,W ;+1 | 938 incf EEDATA,W ;+1 |
877 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 939 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
878 read_int_eeprom .3 | 940 read_int_eeprom .3 |
879 movf EEDATA,W | 941 movf EEDATA,W |
880 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 942 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
881 movlw 0xFA | 943 movlw 0xFA |
882 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 944 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
883 movlw 0xFA | 945 movlw 0xFA |
884 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 946 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
885 | 947 |
886 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive) | 948 ; Keep room for dive length ext_flash_dive_counter:3 (Stored at the end of the dive) |
887 ; Writing 0xFF three times here is mandatory | 949 ; Writing 0xFF three times here is mandatory |
888 ; - 0xFF can be overwritten after the dive | 950 ; - 0xFF can be overwritten after the dive |
889 ; - ghostwrite_byte_profile takes care of 4kB Page switching | 951 ; - ghostwrite_byte_profile takes care of 4kB Page switching |
890 ; - fixes an issue when we are at exactly 0xXXX000 here... | 952 ; - fixes an issue when we are at exactly 0xXXX000 here... |
891 | 953 |
892 movlw 0xFF | 954 movlw 0xFF |
893 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 955 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) |
894 movlw 0xFF | 956 movlw 0xFF |
895 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 957 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) |
896 movlw 0xFF | 958 movlw 0xFF |
897 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) | 959 call write_byte_ext_flash_plus_nocnt ; WREG -> Profile in ext. flash (No ext_flash_dive_counter:3 increase) |
898 | 960 |
899 movf samplingrate,W ; Sampling rate | 961 movf samplingrate,W ; Sampling rate |
900 btfsc FLAG_apnoe_mode ; Apnoe mode? | 962 btfsc FLAG_apnoe_mode ; Apnoe mode? |
901 movlw samplingrate_apnoe ; Apnoe sampling rate | 963 movlw samplingrate_apnoe ; Apnoe sampling rate |
902 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 964 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
903 | 965 |
904 movlw .7 ; Number of divisors | 966 movlw .7 ; Number of divisors |
905 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 967 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
906 | 968 |
907 movlw .0 ; Type | 969 movlw .0 ; Type |
908 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 970 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
909 movlw infolength_temperature | 971 movlw infolength_temperature |
910 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 972 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
911 movlw div_temperature ; Divisor temperature | 973 movlw div_temperature ; Divisor temperature |
912 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 974 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
913 | 975 |
914 movlw .1 ; Type | 976 movlw .1 ; Type |
915 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 977 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
916 movlw infolength_deco | 978 movlw infolength_deco |
917 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 979 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
918 movlw div_deco ; Divisor decodata | 980 movlw div_deco ; Divisor deco data |
919 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 981 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
920 | 982 |
921 movlw .2 ; Type | 983 movlw .2 ; Type |
922 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 984 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
923 movlw infolength_gf | 985 movlw infolength_gf |
924 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 986 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
925 movlw div_gf ; Divisor gf | 987 movlw div_gf ; Divisor gf |
926 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 988 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
927 | 989 |
928 movlw .3 ; Type | 990 movlw .3 ; Type |
929 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 991 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
930 movlw infolength_ppo2_sensors | 992 movlw infolength_ppo2_sensors |
931 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 993 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
932 movlw div_ppo2_sensors ; Divisor ppO2 | 994 movlw div_ppo2_sensors ; Divisor ppO2 |
933 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active | 995 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
934 movlw .0 ; No ppO2 data in OC mode | 996 movlw .0 ; No ppO2 data in OC mode |
935 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 997 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
936 | 998 |
937 movlw .4 ; Type | 999 movlw .4 ; Type |
938 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1000 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
939 movlw infolength_decoplan | 1001 movlw infolength_decoplan |
940 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1002 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
941 movlw div_decoplan ; Divisor debug | 1003 movlw div_decoplan ; Divisor debug |
942 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1004 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
943 | 1005 |
944 movlw .5 ; Type | 1006 movlw .5 ; Type |
945 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1007 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
946 movlw infolength_cns | 1008 movlw infolength_cns |
947 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1009 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
948 movlw div_cns ; Divisor CNS | 1010 movlw div_cns ; Divisor CNS |
949 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1011 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
950 | 1012 |
951 movlw .6 ; Type | 1013 movlw .6 ; Type |
952 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1014 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
953 movlw infolength_tank | 1015 movlw infolength_tank |
954 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1016 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
955 movlw div_tank ; Divisor Tank | 1017 movlw div_tank ; Divisor Tank |
956 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash | 1018 rcall ghostwrite_byte_profile ; WREG -> Profile in ext. flash |
957 | 1019 |
958 return | 1020 return |
959 divemode_store_statistics: ; Store/update statistics for this unit | 1021 |
960 rcall vault_decodata_into_eeprom ; update deco data | 1022 divemode_store_statistics: ; Store/update statistics for this unit |
961 rcall do_logoffset_common_read ; Existing logbook offset into lo:hi | 1023 call vault_decodata_into_eeprom ; update deco data |
962 | 1024 call do_logoffset_common_read ; Existing logbook offset into lo:hi |
963 tstfsz lo ; lo=0? | 1025 |
964 bra change_logbook_offset1 ; No, adjust offset | 1026 tstfsz lo ; lo=0? |
965 tstfsz hi ; hi=0? | 1027 bra change_logbook_offset1 ; No, adjust offset |
966 bra change_logbook_offset1 ; No, adjust offset | 1028 tstfsz hi ; hi=0? |
967 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | 1029 bra change_logbook_offset1 ; No, adjust offset |
1030 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | |
1031 | |
968 change_logbook_offset1: | 1032 change_logbook_offset1: |
969 movlw d'1' | 1033 movlw d'1' |
970 addwf lo | 1034 addwf lo |
971 movlw d'0' | 1035 movlw d'0' |
972 addwfc hi | 1036 addwfc hi |
973 rcall do_logoffset_common_write ; lo:hi -> EEPROM | 1037 call do_logoffset_common_write ; lo:hi -> EEPROM |
1038 | |
974 change_logbook_offset2: | 1039 change_logbook_offset2: |
975 ; Clear lastdive:4 | 1040 ; Clear lastdive:4 |
976 banksel lastdive_time+0 | 1041 banksel lastdive_time+0 |
977 clrf lastdive_time+0 | 1042 clrf lastdive_time+0 |
978 clrf lastdive_time+1 | 1043 clrf lastdive_time+1 |
979 clrf lastdive_time+2 | 1044 clrf lastdive_time+2 |
980 clrf lastdive_time+3 | 1045 clrf lastdive_time+3 |
981 movff divemins+0,lastdive_duration+0 | 1046 movff divemins+0,lastdive_duration+0 |
982 movff divemins+1,lastdive_duration+1 | 1047 movff divemins+1,lastdive_duration+1 |
983 movff divesecs,lastdive_duration+2 | 1048 movff divesecs, lastdive_duration+2 |
984 movff max_pressure+0,lastdive_maxdepth+0 | 1049 movff max_pressure+0,lastdive_maxdepth+0 |
985 movff max_pressure+1,lastdive_maxdepth+1 | 1050 movff max_pressure+1,lastdive_maxdepth+1 |
986 banksel common | 1051 banksel common |
987 | 1052 |
988 ; Add more here... | 1053 ; Add more here... |
989 return | |
990 | |
991 global do_logoffset_common_write | |
992 do_logoffset_common_write: | |
993 ; TODO: limit [lo:hi] to 9999 ? may arrive here as >= 10000 because of +10 increment option | |
994 ; SIMPLER WAY: return without writing to eeprom if hi == 0x27 -> 0x2700 = 9984, this is within | |
995 ; the save range for a +10 increment, shall do it... | |
996 ; mH | |
997 | |
998 movff lo,EEDATA | |
999 write_int_eeprom 0x0D | |
1000 movff hi,EEDATA | |
1001 write_int_eeprom 0x0E | |
1002 return | 1054 return |
1003 | 1055 |
1004 global do_logoffset_common_read | 1056 END |
1005 do_logoffset_common_read: | |
1006 clrf EEADRH | |
1007 read_int_eeprom 0x0D | |
1008 movff EEDATA,lo | |
1009 read_int_eeprom 0x0E | |
1010 movff EEDATA,hi ; Existing logbook offset into lo:hi | |
1011 return | |
1012 | |
1013 | |
1014 global update_battery_registers | |
1015 update_battery_registers: | |
1016 ; save battery_gauge:6 into EEPROM 0x07-0x0C | |
1017 clrf EEADRH | |
1018 movff battery_gauge+0,EEDATA | |
1019 write_int_eeprom 0x07 | |
1020 movff battery_gauge+1,EEDATA | |
1021 write_int_eeprom 0x08 | |
1022 movff battery_gauge+2,EEDATA | |
1023 write_int_eeprom 0x09 | |
1024 movff battery_gauge+3,EEDATA | |
1025 write_int_eeprom 0x0A | |
1026 movff battery_gauge+4,EEDATA | |
1027 write_int_eeprom 0x0B | |
1028 movff battery_gauge+5,EEDATA | |
1029 write_int_eeprom 0x0C | |
1030 movff battery_type,EEDATA ; =0:1.5V, =1:3,6V Saft, =2:LiIon 3,7V/0.8Ah, =3:LiIon 3,7V/3.1Ah, =4: LiIon 3,7V/2.3Ah | |
1031 write_int_eeprom 0x0F | |
1032 return | |
1033 | |
1034 | |
1035 global vault_decodata_into_eeprom | |
1036 vault_decodata_into_eeprom: | |
1037 ; Vault in EEPROM 512...1023 | |
1038 ; Write 0xAA at 512 to indicate valid data in vault | |
1039 ; Store last time/date | |
1040 ; Store 0x700 to 0x780 (pres_tissue_N2 and pres_tissue_He) | |
1041 movlw HIGH .512 ; =2 | |
1042 movwf EEADRH | |
1043 movlw 0xAA | |
1044 movwf EEDATA | |
1045 write_int_eeprom .0 | |
1046 ; Store date/time | |
1047 movff year,EEDATA | |
1048 write_int_eeprom .1 | |
1049 movff month,EEDATA | |
1050 write_int_eeprom .2 | |
1051 movff day,EEDATA | |
1052 write_int_eeprom .3 | |
1053 movff hours,EEDATA | |
1054 write_int_eeprom .4 | |
1055 movff mins,EEDATA | |
1056 write_int_eeprom .5 | |
1057 movff secs,EEDATA | |
1058 write_int_eeprom .6 | |
1059 | |
1060 movff int_O_CNS_fraction+0,EEDATA | |
1061 write_int_eeprom .7 | |
1062 movff int_O_CNS_fraction+1,EEDATA | |
1063 write_int_eeprom .8 | |
1064 movff int_O_desaturation_time+0,EEDATA | |
1065 write_int_eeprom .9 | |
1066 movff int_O_desaturation_time+1,EEDATA | |
1067 write_int_eeprom .10 | |
1068 movff surface_interval+0,EEDATA | |
1069 write_int_eeprom .11 | |
1070 movff surface_interval+1,EEDATA | |
1071 write_int_eeprom .12 | |
1072 movff int_O_gradient_factor+0,EEDATA ; value limited to 255, only lower byte in use for value | |
1073 write_int_eeprom .13 | |
1074 movff int_O_nofly_time+0,EEDATA | |
1075 write_int_eeprom .14 | |
1076 movff int_O_nofly_time+1,EEDATA | |
1077 write_int_eeprom .15 | |
1078 | |
1079 ; Tissue data from 16 to 144 | |
1080 movlw .16 | |
1081 movwf EEADR | |
1082 movlw .128 | |
1083 movwf lo | |
1084 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | |
1085 vault_decodata_into_eeprom2: | |
1086 movff POSTINC1,EEDATA | |
1087 call write_eeprom ; EEDATA into EEPROM@EEADR | |
1088 incf EEADR,F | |
1089 decfsz lo,F ; All done? | |
1090 bra vault_decodata_into_eeprom2 ; No | |
1091 clrf EEADRH | |
1092 return | |
1093 | |
1094 global restore_decodata_from_eeprom | |
1095 restore_decodata_from_eeprom: | |
1096 movlw LOW .512 ; =0 | |
1097 movwf EEADR | |
1098 movlw HIGH .512 ; =2 | |
1099 movwf EEADRH | |
1100 | |
1101 ; Restore date/time | |
1102 read_int_eeprom .1 | |
1103 movff EEDATA,year | |
1104 read_int_eeprom .2 | |
1105 movff EEDATA,month | |
1106 read_int_eeprom .3 | |
1107 movff EEDATA,day | |
1108 read_int_eeprom .4 | |
1109 movff EEDATA,hours | |
1110 read_int_eeprom .5 | |
1111 movff EEDATA,mins | |
1112 read_int_eeprom .6 | |
1113 movff EEDATA,secs | |
1114 call rtc_set_rtc | |
1115 | |
1116 read_int_eeprom .7 | |
1117 movff EEDATA,int_O_CNS_fraction+0 | |
1118 read_int_eeprom .8 | |
1119 movff EEDATA,int_O_CNS_fraction+1 | |
1120 read_int_eeprom .9 | |
1121 movff EEDATA,int_O_desaturation_time+0 | |
1122 read_int_eeprom .10 | |
1123 movff EEDATA,int_O_desaturation_time+1 | |
1124 read_int_eeprom .11 | |
1125 movff EEDATA,surface_interval+0 | |
1126 read_int_eeprom .12 | |
1127 movff EEDATA,surface_interval+1 | |
1128 read_int_eeprom .13 | |
1129 movff EEDATA,int_O_gradient_factor+0 | |
1130 read_int_eeprom .14 | |
1131 movff EEDATA,int_O_nofly_time+0 | |
1132 read_int_eeprom .15 | |
1133 movff EEDATA,int_O_nofly_time+1 | |
1134 | |
1135 ; Tissue data from 16 to 144 | |
1136 movlw .16 | |
1137 movwf EEADR | |
1138 movlw .128 | |
1139 movwf lo | |
1140 lfsr FSR1,0x700;pres_tissue_N2+0 ; 32*4Byte Float = 128Bytes | |
1141 restore_decodata_from_eeprom2: | |
1142 call read_eeprom ; EEPROM@EEADR into EEDATA | |
1143 movff EEDATA,POSTINC1 | |
1144 incf EEADR,F | |
1145 decfsz lo,F ; All done? | |
1146 bra restore_decodata_from_eeprom2 ; No | |
1147 clrf EEADRH | |
1148 return | |
1149 | |
1150 | |
1151 END |