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