annotate src/ghostwriter.asm @ 632:0347acdf6d8e

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