Mercurial > public > hwos_code
annotate src/isr.asm @ 389:9175429bdeba
CHANGE: Logbook now shows end-of-dive date and time for dives made with firmware <1.92 indicated by an icon in the logbook
CHANGE: Logbook shows start-of-dive date and time for dives made with firmware >=1.92
BUGFIX: Text alignment in logbook
author | heinrichsweikamp |
---|---|
date | Tue, 27 Oct 2015 13:45:10 +0100 |
parents | 7faa688db105 |
children | d3087a8ed7e1 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File isr.asm | |
4 ; | |
5 ; INTERUPT subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. | |
11 | |
275 | 12 #include "hwos.inc" |
0 | 13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c |
14 #include "ms5541.inc" | |
15 #include "adc_lightsensor.inc" | |
16 | |
17 ;============================================================================= | |
18 | |
19 extern start | |
20 | |
21 isr_high CODE 0x0008 ;High Priority Interrups | |
22 bra HighInt | |
23 nop | |
24 nop | |
25 nop | |
26 nop | |
27 nop | |
28 nop | |
29 bra HighInt | |
30 | |
31 isr_low CODE 0x00018 ;Low Priority Interrups | |
32 ; *** low priority interrupts not used | |
33 retfie FAST ; Restores BSR, STATUS and WREG | |
34 | |
35 HighInt: | |
36 movff PRODL,isr_prod+0 | |
37 movff PRODH,isr_prod+1 | |
38 | |
39 ; Buttons | |
40 btfsc PIR1,TMR1IF ; Timer1 INT (Button hold-down Timer) | |
41 rcall timer1int | |
42 btfsc INTCON,INT0IF ; Buttons | |
43 rcall isr_switch_right | |
44 btfsc INTCON3,INT1IF ; Buttons | |
45 rcall isr_switch_left | |
46 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
47 ; IR/S8-Link |
113 | 48 btfsc PIR3,RC2IF ; UART2 |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
49 rcall isr_uart2 ; IR/S8-Link |
0 | 50 btfsc PIR2,TMR3IF ; Timer 3 |
51 rcall isr_timer3 ; IR-Link Timeout | |
113 | 52 |
53 ; Pressure sensor and others | |
54 btfsc PIR5,TMR7IF ; Timer 7 | |
55 rcall isr_tmr7 ; Every 62,5ms | |
56 | |
0 | 57 ; RTCC |
58 btfsc PIR3,RTCCIF ; Real-time-clock interrupt | |
59 rcall isr_rtcc ; May return in bank common! | |
60 | |
61 movff isr_prod+1,PRODH | |
62 movff isr_prod+0,PRODL | |
63 retfie FAST ; Restores BSR, STATUS and WREG | |
64 | |
65 ;============================================================================= | |
66 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
67 isr_uart2: ; IR/S8-Link |
0 | 68 banksel RCREG2 |
69 movf RCREG2,W | |
70 bcf RCSTA2,CREN ; Clear receiver status | |
71 bsf RCSTA2,CREN | |
72 banksel isr_backup | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
73 incf ir_s8_counter,F ; Increase counter |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
74 movff ir_s8_counter,isr1_temp ; Copy |
0 | 75 dcfsnz isr1_temp,F |
204 | 76 movwf ir_s8_buffer+.0 |
0 | 77 dcfsnz isr1_temp,F |
204 | 78 movwf ir_s8_buffer+.1 |
0 | 79 dcfsnz isr1_temp,F |
204 | 80 movwf ir_s8_buffer+.2 |
0 | 81 dcfsnz isr1_temp,F |
204 | 82 movwf ir_s8_buffer+.3 |
0 | 83 dcfsnz isr1_temp,F |
204 | 84 movwf ir_s8_buffer+.4 |
0 | 85 dcfsnz isr1_temp,F |
204 | 86 movwf ir_s8_buffer+.5 |
0 | 87 dcfsnz isr1_temp,F |
204 | 88 movwf ir_s8_buffer+.6 |
0 | 89 dcfsnz isr1_temp,F |
204 | 90 movwf ir_s8_buffer+.7 |
0 | 91 dcfsnz isr1_temp,F |
204 | 92 movwf ir_s8_buffer+.8 |
0 | 93 dcfsnz isr1_temp,F |
204 | 94 movwf ir_s8_buffer+.9 |
0 | 95 dcfsnz isr1_temp,F |
204 | 96 movwf ir_s8_buffer+.10 |
0 | 97 dcfsnz isr1_temp,F |
204 | 98 movwf ir_s8_buffer+.11 |
0 | 99 dcfsnz isr1_temp,F |
204 | 100 movwf ir_s8_buffer+.12 |
0 | 101 dcfsnz isr1_temp,F |
204 | 102 movwf ir_s8_buffer+.13 |
0 | 103 dcfsnz isr1_temp,F |
204 | 104 movwf ir_s8_buffer+.14 |
0 | 105 dcfsnz isr1_temp,F |
204 | 106 movwf ir_s8_buffer+.15 |
113 | 107 dcfsnz isr1_temp,F |
204 | 108 movwf ir_s8_buffer+.16 |
113 | 109 dcfsnz isr1_temp,F |
204 | 110 movwf ir_s8_buffer+.17 |
113 | 111 |
0 | 112 clrf TMR3L ; Preload timer |
113 movlw .253 | |
114 movwf TMR3H | |
115 bsf T3CON,TMR3ON ; (Re)Start Timeout counter | |
116 return | |
117 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
118 isr_timer3: ; IR/S8-Link Timeout |
0 | 119 bcf T3CON,TMR3ON ; Stop Timer3 |
120 banksel isr_backup ; Select Bank0 for ISR data. | |
121 movlw .15 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
122 cpfseq ir_s8_counter ; Got exact 15bytes? |
0 | 123 bra isr_timer3_1 ; No, test for 16bytes |
113 | 124 bra isr_timer3_ir ; Got 15 bytes, compute local checksum |
0 | 125 isr_timer3_1: |
126 movlw .16 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
127 cpfseq ir_s8_counter ; Got exact 16bytes? |
113 | 128 bra isr_timer3_2 ; No, test for 17bytes |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
129 tstfsz ir_s8_buffer+.15 ; Last byte=0x00 |
0 | 130 bra isr_timer3_exit ; No, exit |
113 | 131 bra isr_timer3_ir ; Got 16 bytes, compute local checksum |
132 isr_timer3_2: | |
133 movlw .17 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
134 cpfseq ir_s8_counter ; Got exact 17bytes? |
113 | 135 bra isr_timer3_exit ; No, exit |
136 bra isr_timer3_s8 ; S8 data | |
0 | 137 |
113 | 138 isr_timer3_ir: ; IR input |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
139 movff ir_s8_buffer+.0,PRODL |
0 | 140 clrf PRODH |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
141 movf ir_s8_buffer+.1,W |
0 | 142 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
143 movf ir_s8_buffer+.2,W |
0 | 144 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
145 movf ir_s8_buffer+.3,W |
0 | 146 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
147 movf ir_s8_buffer+.4,W |
0 | 148 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
149 movf ir_s8_buffer+.5,W |
0 | 150 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
151 movf ir_s8_buffer+.6,W |
0 | 152 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
153 movf ir_s8_buffer+.7,W |
0 | 154 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
155 movf ir_s8_buffer+.8,W |
0 | 156 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
157 movf ir_s8_buffer+.9,W |
0 | 158 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
159 movf ir_s8_buffer+.10,W |
0 | 160 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
161 movf ir_s8_buffer+.11,W |
0 | 162 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
163 movf ir_s8_buffer+.12,W |
0 | 164 rcall isr_timer3_checksum |
165 | |
166 ; Compare checksum | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
167 movf ir_s8_buffer+.13,W |
0 | 168 cpfseq PRODL ; Checksum ok? |
169 bra isr_timer3_exit ; No, exit | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
170 movf ir_s8_buffer+.14,W |
0 | 171 cpfseq PRODH ; Checksum ok? |
172 bra isr_timer3_exit ; No, exit | |
173 | |
174 ; Checksum OK, copy results | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
175 movff ir_s8_buffer+.1,hud_status_byte |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
176 movff ir_s8_buffer+.2,o2_mv_sensor1+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
177 movff ir_s8_buffer+.3,o2_mv_sensor1+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
178 movff ir_s8_buffer+.4,o2_mv_sensor2+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
179 movff ir_s8_buffer+.5,o2_mv_sensor2+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
180 movff ir_s8_buffer+.6,o2_mv_sensor3+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
181 movff ir_s8_buffer+.7,o2_mv_sensor3+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
182 movff ir_s8_buffer+.8,o2_ppo2_sensor1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
183 movff ir_s8_buffer+.9,o2_ppo2_sensor2 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
184 movff ir_s8_buffer+.10,o2_ppo2_sensor3 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
185 movff ir_s8_buffer+.11,hud_battery_mv+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
186 movff ir_s8_buffer+.12,hud_battery_mv+1 |
0 | 187 |
188 movlw ir_timeout_value ; multiples of 62,5ms | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
189 movwf ir_S8_timeout ; Reload timeout |
227
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
190 |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
191 banksel hud_status_byte |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
192 bsf hud_connection_ok ; Set manually for hwHUD w/o the HUD module... |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
193 banksel isr_backup ; Select Bank0 for ISR data. |
0 | 194 |
195 isr_timer3_exit: | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
196 clrf ir_s8_counter ; Clear pointer |
0 | 197 bcf PIR2,TMR3IF ; Clear flag |
198 return | |
199 | |
200 isr_timer3_checksum: | |
201 addwf PRODL,F | |
202 movlw .0 | |
203 addwfc PRODH,F | |
204 return | |
205 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
206 isr_timer3_s8: ; S8 input |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
207 movff ir_s8_buffer+.0,PRODL |
113 | 208 clrf PRODH |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
209 movf ir_s8_buffer+.1,W |
113 | 210 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
211 movf ir_s8_buffer+.2,W |
113 | 212 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
213 movf ir_s8_buffer+.3,W |
113 | 214 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
215 movf ir_s8_buffer+.4,W |
113 | 216 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
217 movf ir_s8_buffer+.5,W |
113 | 218 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
219 movf ir_s8_buffer+.6,W |
113 | 220 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
221 movf ir_s8_buffer+.7,W |
113 | 222 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
223 movf ir_s8_buffer+.8,W |
113 | 224 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
225 movf ir_s8_buffer+.9,W |
113 | 226 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
227 movf ir_s8_buffer+.10,W |
113 | 228 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
229 movf ir_s8_buffer+.11,W |
113 | 230 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
231 movf ir_s8_buffer+.12,W |
113 | 232 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
233 movf ir_s8_buffer+.13,W |
113 | 234 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
235 movf ir_s8_buffer+.14,W |
113 | 236 rcall isr_timer3_checksum |
237 | |
238 ; Compare checksum | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
239 movf ir_s8_buffer+.15,W |
113 | 240 cpfseq PRODL ; Checksum ok? |
241 bra isr_timer3_exit ; No, exit | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
242 movf ir_s8_buffer+.16,W |
113 | 243 cpfseq PRODH ; Checksum ok? |
244 bra isr_timer3_exit ; No, exit | |
245 | |
246 ; Checksum OK, copy results | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
247 movff ir_s8_buffer+.3,hud_status_byte |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
248 movff ir_s8_buffer+.13,hud_battery_mv+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
249 movff ir_s8_buffer+.14,hud_battery_mv+1 |
113 | 250 |
251 banksel common | |
271 | 252 btfsc new_s8_data_available ; =1: Old data already processed? |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
253 bra isr_timer3_skip ; No, skip copying new results |
113 | 254 |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
255 movff ir_s8_buffer+.6,s8_rawdata_sensor1+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
256 movff ir_s8_buffer+.5,s8_rawdata_sensor1+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
257 movff ir_s8_buffer+.4,s8_rawdata_sensor1+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
258 movff ir_s8_buffer+.9,s8_rawdata_sensor2+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
259 movff ir_s8_buffer+.8,s8_rawdata_sensor2+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
260 movff ir_s8_buffer+.7,s8_rawdata_sensor2+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
261 movff ir_s8_buffer+.12,s8_rawdata_sensor3+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
262 movff ir_s8_buffer+.11,s8_rawdata_sensor3+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
263 movff ir_s8_buffer+.10,s8_rawdata_sensor3+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
264 banksel common |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
265 bsf new_s8_data_available ; set flag |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
266 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
267 isr_timer3_skip: |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
268 banksel ir_S8_timeout |
113 | 269 movlw ir_timeout_value ; multiples of 62,5ms |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
270 movwf ir_S8_timeout ; Reload timeout |
113 | 271 bra isr_timer3_exit ; Exit |
272 | |
273 | |
0 | 274 ;============================================================================= |
275 | |
276 isr_tmr7: ; each 62,5ms | |
277 bcf PIR5,TMR7IF ; clear flag | |
278 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. | |
279 movlw .248 | |
280 movwf TMR7H ; -> Rollover after 2048 cycles -> 62,5ms | |
281 | |
282 banksel isr_backup | |
283 movf max_CCPR1L,W ; Dimm value | |
284 cpfseq CCPR1L ; = current PWM value? | |
285 rcall isr_dimm_tft ; No, adjust until max_CCPR1L=CCPR1L ! | |
286 | |
287 banksel isr_backup | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
288 decfsz ir_S8_timeout,F ; IR Data still valid? |
0 | 289 bra isr_tmr7_2 ; Yes, continue |
290 ; timeout, clear IR-Data | |
291 | |
292 movlw ir_timeout_value ; multiples of 62,5ms | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
293 movwf ir_S8_timeout ; Reload timeout |
0 | 294 |
295 banksel common | |
236 | 296 btfss analog_o2_input |
113 | 297 bra isr_tmr7_1a ; Always with normal ostc3 hardware |
298 btfss s8_digital | |
299 bra isr_tmr7_2 ; only when digital | |
300 isr_tmr7_1a: | |
0 | 301 clrf o2_mv_sensor1+0 |
302 clrf o2_mv_sensor1+1 | |
303 clrf o2_mv_sensor2+0 | |
304 clrf o2_mv_sensor2+1 | |
305 clrf o2_mv_sensor3+0 | |
306 clrf o2_mv_sensor3+1 | |
378 | 307 banksel hud_battery_mv |
0 | 308 clrf hud_battery_mv+0 |
309 clrf hud_battery_mv+1 | |
378 | 310 banksel hud_status_byte |
0 | 311 clrf hud_status_byte |
312 clrf o2_ppo2_sensor1 | |
313 clrf o2_ppo2_sensor2 | |
314 clrf o2_ppo2_sensor3 | |
315 | |
316 isr_tmr7_2: | |
317 banksel common | |
318 btfss no_sensor_int ; No sensor interrupt (because it's addressed during sleep) | |
319 bra isr_sensor_state2 ; No, continue | |
320 banksel isr_backup ; Back to Bank0 ISR data | |
321 return | |
322 | |
323 isr_set_speed_to_normal: | |
324 ; Set Speed to normal | |
325 movlw b'01110010' | |
326 movwf OSCCON ; 16MHz INTOSC | |
327 movlw b'00000000' | |
328 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
329 movlw b'00001101' ; 1:2 Postscaler, 1:4 Prescaler, Timer 2 start -> 1960Hz (no-flicker) | |
330 movwf T2CON | |
331 btfss OSCCON,HFIOFS | |
332 bra $-2 ; Wait until clock is stable | |
333 return | |
334 | |
335 isr_sensor_state2: | |
336 banksel common | |
337 movff sensor_state_counter,WREG | |
338 btfss WREG,0 ; every 1/4 second | |
339 bsf quarter_second_update ; Set flag | |
319 | 340 banksel isr_backup ; Back to Bank0 ISR data |
0 | 341 movlw d'2' |
342 cpfseq speed_setting ; Set to normal in case it's not already in normal speed mode | |
343 rcall isr_set_speed_to_normal | |
319 | 344 |
0 | 345 incf sensor_state_counter,F ; counts to eight for state maschine |
346 | |
347 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us) | |
348 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
349 ; State 3: Get temperature (51us) and start pressure integration (73,5us) | |
350 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
351 ; State 5: Get temperature (51us) and start pressure integration (73,5us) | |
352 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
353 ; State 7: Get temperature (51us) and start pressure integration (73,5us) | |
354 ; State 8: Get pressure (51us), start temperature integration (73,5us), calculate temperature compensated pressure (233us) and build average for half-second update of tempperature and pressure | |
355 | |
356 movff sensor_state_counter,WREG ; WREG used as temp here... | |
357 dcfsnz WREG,F | |
358 bra sensor_int_state1_plus_restart ; Do State 1 | |
359 dcfsnz WREG,F | |
360 bra sensor_int_state2 ; Do State 2 | |
361 dcfsnz WREG,F | |
362 bra sensor_int_state1 ; Do State 3 | |
363 dcfsnz WREG,F | |
364 bra sensor_int_state2 ; Do State 4 | |
365 dcfsnz WREG,F | |
366 bra sensor_int_state1 ; Do State 5 | |
367 dcfsnz WREG,F | |
368 bra sensor_int_state2 ; Do State 6 | |
369 dcfsnz WREG,F | |
370 bra sensor_int_state1 ; Do State 7 | |
371 ; bra sensor_int2_plus_average ; Do State 8 | |
372 ;sensor_int2_plus_average: | |
373 ; First, do state2: | |
374 call get_pressure_value ; State2: Get pressure (51us) | |
375 call get_temperature_start ; and start temperature integration (73,5us) | |
376 call calculate_compensation ; calculate temperature compensated pressure (27us) | |
377 ; Build average | |
378 bcf STATUS,C ; clear carry bit. | |
379 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2 | |
380 rrcf amb_pressure_avg+0 | |
381 bcf STATUS,C ; clear carry bit, twice. | |
382 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4 | |
383 rrcf amb_pressure_avg+0 | |
384 | |
385 movff amb_pressure_avg+1,amb_pressure+1 ; copy into actual register | |
386 movff amb_pressure_avg+0,amb_pressure+0 | |
387 | |
388 bcf STATUS,C | |
389 btfsc temperature_avg+1,7 ; Copy sign bit to carry | |
390 bsf STATUS,C | |
391 rrcf temperature_avg+1 ; Signed temperature /2 | |
392 rrcf temperature_avg+0 | |
393 bcf STATUS,C | |
394 btfsc temperature_avg+1,7 ; Copy sign bit to carry | |
395 bsf STATUS,C | |
396 rrcf temperature_avg+1 ; Signed temperature /4 | |
397 rrcf temperature_avg+0 | |
398 | |
399 movff temperature_avg+1,temperature+1 ; copy into actual register | |
400 movff temperature_avg+0,temperature+0 | |
401 | |
402 banksel common ; flag1 is in Bank1 | |
403 bcf temp_changed ; Clear flag for temperature update | |
404 bcf pressure_refresh ; Clear flag for pressure update | |
405 banksel isr_backup ; Back to Bank0 ISR data | |
406 | |
407 ; Temp changed? | |
408 movf temperature+0,W | |
409 cpfseq last_temperature+0 | |
410 bra isr_sensor_state2_2 ; Yes | |
411 movf temperature+1,W | |
412 cpfseq last_temperature+1 | |
413 bra isr_sensor_state2_2 ; Yes | |
414 | |
415 bra isr_sensor_state2_3 ; no change | |
416 | |
417 isr_sensor_state2_2: | |
418 banksel common ; flag1 is in Bank1 | |
419 bsf temp_changed ; Yes | |
420 banksel isr_backup ; Back to Bank0 ISR data | |
421 isr_sensor_state2_3: | |
422 movff temperature+0,last_temperature+0 ; Copy for compare | |
423 movff temperature+1,last_temperature+1 | |
424 | |
425 movf amb_pressure+0,W | |
426 cpfseq last_pressure+0 | |
427 bra isr_sensor_state2_4 ; Yes | |
428 movf amb_pressure+1,W | |
429 cpfseq last_pressure+1 | |
430 bra isr_sensor_state2_4 ; Yes | |
431 | |
432 bra isr_sensor_state2_5 ; No change | |
433 isr_sensor_state2_4: | |
434 banksel common ; flag1 is in Bank1 | |
435 bsf pressure_refresh ; Yes | |
436 banksel isr_backup ; Back to Bank0 ISR data | |
437 isr_sensor_state2_5: | |
438 movff amb_pressure+0,last_pressure+0 ; Copy for compare | |
439 movff amb_pressure+1,last_pressure+1 | |
440 | |
441 clrf sensor_state_counter ; Then reset State counter | |
176 | 442 banksel common ; flag2 is in Bank1 |
0 | 443 btfss simulatormode_active ; are we in simulator mode? |
444 bra comp_air_pressure ; no | |
176 | 445 ; Always set pressure_refresh flag in simulator mode |
446 bsf pressure_refresh ; Yes | |
447 banksel isr_backup ; Back to Bank0 ISR data | |
0 | 448 movlw LOW d'1000' ; yes, so simulate 1000mbar surface pressure |
449 movwf last_surfpressure+0 | |
450 movlw HIGH d'1000' | |
451 movwf last_surfpressure+1 | |
452 | |
453 comp_air_pressure: | |
176 | 454 banksel isr_backup ; Back to Bank0 ISR data |
0 | 455 movf last_surfpressure+0,W ; compensate airpressure |
456 subwf amb_pressure+0,W | |
457 movwf rel_pressure+0 ; rel_pressure stores depth! | |
458 | |
459 movf last_surfpressure+1,W | |
460 subwfb amb_pressure+1,W | |
461 movwf rel_pressure+1 | |
462 btfss STATUS,N ; result is below zero? | |
463 bra sensor_int_state_exit | |
464 clrf rel_pressure+0 ; Yes, do not display negative depths | |
465 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive | |
466 bra sensor_int_state_exit | |
467 | |
468 sensor_int_state1_plus_restart: | |
469 clrf amb_pressure_avg+0 ; pressure average registers | |
470 clrf amb_pressure_avg+1 | |
471 clrf temperature_avg+0 | |
472 clrf temperature_avg+1 | |
473 | |
474 sensor_int_state1: | |
475 call get_temperature_value ; State 1: Get temperature | |
476 call get_pressure_start ; and start pressure integration. | |
477 bra sensor_int_state_exit | |
478 | |
479 sensor_int_state2: | |
480 call get_pressure_value ; State2: Get pressure (51us) | |
481 call get_temperature_start ; and start temperature integration (73,5us) | |
482 call calculate_compensation ; calculate temperature compensated pressure (233us) | |
483 ; bra sensor_int_state_exit | |
484 sensor_int_state_exit: | |
485 rcall isr_restore_clock ; Restore clock | |
486 return | |
487 ;============================================================================= | |
488 | |
489 isr_dimm_tft: ; Adjust until max_CCPR1L=CCPR1L ! | |
490 banksel common | |
491 btfsc tft_is_dimming ; Ignore while dimming | |
492 return | |
493 banksel isr_backup | |
494 movf max_CCPR1L,W | |
495 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L? | |
496 bra isr_dimm_tft2 ; No, dimm up | |
497 ; dimm down | |
498 decf CCPR1L,F ; -1 | |
499 return | |
500 isr_dimm_tft2: | |
501 movf max_CCPR1L,W | |
31
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
30
diff
changeset
|
502 sublw ambient_light_min_eco |
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
30
diff
changeset
|
503 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L-ambient_light_min_eco? |
0 | 504 bra isr_dimm_tft3 ; No, dimm up slow |
505 ; dimm up faster | |
357
36bd27f42362
BUGFIX: Auto-Brightness clipped to lowest settings in bright sunlight on some devices
heinrichsweikamp
parents:
319
diff
changeset
|
506 movlw .10 |
0 | 507 addwf CCPR1L,F |
508 isr_dimm_tft3: | |
509 incf CCPR1L,F ; +1 | |
510 return | |
511 | |
512 | |
513 isr_rtcc: ; each second | |
514 bcf PIR3,RTCCIF ; clear flag | |
515 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. | |
516 bsf RTCCFG,RTCPTR1 | |
517 bsf RTCCFG,RTCPTR0 ; year | |
518 movff RTCVALL,year ; format is BCD! | |
519 movff RTCVALH,day ; dummy read | |
520 movff RTCVALL,day ; format is BCD! | |
521 movff RTCVALH,month ; format is BCD! | |
522 movff RTCVALL,hours ; format is BCD! | |
523 movff RTCVALH,secs ; format is BCD! | |
524 movff RTCVALL,secs ; format is BCD! | |
525 movff RTCVALH,mins ; format is BCD! | |
526 banksel isr_backup ; Back to Bank0 ISR data | |
527 | |
528 ; Convert BCD to DEC and set registers | |
529 movff mins, isr1_temp | |
530 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
531 movff WREG,mins | |
532 movff secs, isr1_temp | |
533 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
534 movff WREG,secs | |
535 movff hours, isr1_temp | |
536 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
537 movff WREG,hours | |
538 movff month, isr1_temp | |
539 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
540 movff WREG,month | |
541 movff day, isr1_temp | |
542 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
543 movff WREG,day | |
544 movff year, isr1_temp | |
545 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
546 movff WREG,year | |
547 | |
548 ; Place once/second tasks for ISR here (Be sure of the right bank!) | |
549 banksel common ; flag1 is in Bank1 | |
550 btfss sleepmode ; in Sleepmode? | |
551 call get_ambient_level ; No, get ambient light level and set max_CCPR1L | |
552 | |
553 rcall isr_battery_gauge ; Add amount of battery consumption to battery_gauge:6 | |
554 | |
555 banksel common ; flag1 is in Bank1 | |
556 bsf onesecupdate ; A new second has begun | |
557 btfsc divemode ; in divemode? | |
558 rcall isr_divemode_1sec ; Yes, do some divemode stuff in bank common | |
559 | |
560 tstfsz secs ; Secs == 0 ? | |
561 return ; No, Done. | |
562 | |
563 bsf oneminupdate ; A new minute has begun | |
564 | |
565 btfss divemode ; In Divemode? | |
566 rcall check_nofly_desat_time ; No, so reduce NoFly and Desat and increase interval | |
567 | |
568 ; Check if a new hour has just begun | |
569 tstfsz mins ; mins=0? | |
570 bra isr_rtcc2 ; No | |
571 bsf onehourupdate ; Yes, set flag | |
572 | |
573 isr_rtcc2: | |
574 banksel isr_backup ; Back to Bank0 ISR data | |
575 return ; Done. | |
576 | |
577 isr_battery_gauge: | |
578 banksel isr_backup ; Bank0 ISR data | |
579 movlw current_sleepmode ; 100µA/3600 -> nAs (Sleepmode current) | |
580 movwf isr1_temp ; Store value (low byte) | |
581 clrf isr2_temp ; High byte | |
582 | |
583 banksel common ; flag1 is in Bank1 | |
584 btfss sleepmode ; in Sleepmode? | |
585 rcall isr_battery_gauge2 ; No, compute current consumtion value into isr1_temp and isr2_temp | |
586 | |
587 banksel isr_backup ; Bank0 ISR data | |
588 movf isr1_temp,W ; 48Bit add of isr1_temp and isr2_temp into battery_gauge:6 | |
589 addwf battery_gauge+0,F | |
590 movf isr2_temp,W | |
591 addwfc battery_gauge+1,F | |
592 movlw .0 | |
593 addwfc battery_gauge+2,F | |
594 addwfc battery_gauge+3,F | |
595 addwfc battery_gauge+4,F | |
596 addwfc battery_gauge+5,F | |
597 return | |
598 | |
599 isr_battery_gauge2: | |
600 ; set consumtion rate in nAs for an one second interval | |
601 ; Example: | |
602 ; movlw LOW .55556 ; 0,2A/3600*1e9s = nAs | |
603 ; movwf isr1_temp ; Low byte | |
604 ; movlw HIGH .55556 ; 0,2A/3600*1e9s = nAs | |
605 ; movwf isr2_temp ; High byte | |
606 | |
607 ; Current consumption for LED backlight is 47*CCPR1L+272 | |
608 movf CCPR1L,W | |
609 mullw current_backlight_multi | |
610 movlw LOW current_backlight_offset | |
611 addwf PRODL,F | |
612 movlw HIGH current_backlight_offset | |
613 addwfc PRODH,F | |
614 movff PRODL,isr1_temp | |
615 movff PRODH,isr2_temp ; isr1_temp and isr2_temp hold value for backlight | |
616 | |
617 ; Add current for CPU and GPU | |
618 ; speed_setting=1: ECO (3,1mA -> 861nAs), =2: NORMAL (5,50mA -> 1528nAs) or =3: FASTEST (8,04mA -> 2233nAs) | |
319 | 619 banksel isr_backup ; Bank0 ISR data |
0 | 620 movlw .1 |
621 cpfseq speed_setting | |
622 bra isr_battery_gauge3 | |
623 movlw LOW current_speed_eco | |
624 addwf isr1_temp,F | |
625 movlw HIGH current_speed_eco | |
626 addwfc isr2_temp,F | |
627 bra isr_battery_gauge5 | |
628 isr_battery_gauge3: | |
629 movlw .2 | |
630 cpfseq speed_setting | |
631 bra isr_battery_gauge4 | |
632 movlw LOW current_speed_normal | |
633 addwf isr1_temp,F | |
634 movlw HIGH current_speed_normal | |
635 addwfc isr2_temp,F | |
636 bra isr_battery_gauge5 | |
637 isr_battery_gauge4: | |
638 movlw LOW current_speed_fastest | |
639 addwf isr1_temp,F | |
640 movlw HIGH current_speed_fastest | |
641 addwfc isr2_temp,F | |
642 isr_battery_gauge5: | |
643 ; Add current if IR reciever is on | |
644 btfss ir_power ; IR enabled? | |
645 bra isr_battery_gauge6 ; no | |
646 movlw LOW current_ir_reciever | |
647 addwf isr1_temp,F | |
648 movlw HIGH current_ir_reciever | |
649 addwfc isr2_temp,F | |
650 isr_battery_gauge6: | |
651 ; Add current for compass/accelerometer | |
652 btfss compass_enabled ; compass active? | |
653 bra isr_battery_gauge7 ; no | |
654 movlw LOW current_compass | |
655 addwf isr1_temp,F | |
656 movlw HIGH current_compass | |
657 addwfc isr2_temp,F | |
658 isr_battery_gauge7: | |
659 return | |
660 | |
661 isr_divemode_1sec: | |
662 incf samplesecs,F ; "samplingrate" diving seconds done | |
663 decf samplesecs_value,W ; holds "samplingrate" value (minus 1 into WREG) | |
664 cpfsgt samplesecs ; Done? | |
665 bra isr_divemode_1sec2 ; no | |
666 | |
667 clrf samplesecs ; clear counter... | |
668 bsf store_sample ; ...and set bit for profile storage | |
669 isr_divemode_1sec2: | |
670 ; Increase re-setable average depth divetime counter | |
176 | 671 infsnz average_divesecs+0,F ; increase stopwatch registers |
0 | 672 incf average_divesecs+1,F ; increase stopwatch registers |
673 ; Increase total divetime (Regardless of start_dive_threshold) | |
148 | 674 infsnz total_divetime_seconds+0,F |
675 incf total_divetime_seconds+1,F ; Total dive time (Regardless of start_dive_threshold) | |
0 | 676 |
677 btfss divemode2 ; displayed divetime is running? | |
678 return ; No (e.g. too shallow) | |
679 | |
680 ; increase divetime registers (Displayed dive time) | |
681 incf divesecs,F | |
682 movlw d'59' | |
683 cpfsgt divesecs | |
684 bra isr_divemode_1sec2a | |
685 | |
686 clrf divesecs | |
687 bsf realdive ; this bit is always set (again) if the dive is longer then one minute | |
148 | 688 infsnz divemins+0,F |
689 incf divemins+1,F ; increase divemins | |
0 | 690 |
691 isr_divemode_1sec2a: | |
692 btfss FLAG_apnoe_mode ; Are we in Apnoe mode? | |
693 return ; No | |
694 | |
695 incf apnoe_secs,F ; increase descent registers | |
696 movlw d'59' | |
697 cpfsgt apnoe_secs ; full minute? | |
698 return ; No | |
699 clrf apnoe_secs | |
700 incf apnoe_mins,F ; increase descent mins | |
701 return | |
702 | |
703 ;============================================================================= | |
704 ; BCD to Binary convertion. | |
705 ; Input: isr1_temp = Value in BCD | |
706 ; Output WREG = value in binary. | |
707 isr_rtcc_convert: | |
708 swapf isr1_temp, W | |
709 andlw 0x0F ; W= tens | |
710 rlncf WREG, W ; W= 2*tens | |
711 subwf isr1_temp, F ; 16*tens + ones - 2*tens | |
712 subwf isr1_temp, F ; 14*tens + ones - 2*tens | |
713 subwf isr1_temp, W ; 12*tens + ones - 2*tens | |
714 return | |
715 | |
716 ;============================================================================= | |
717 | |
718 isr_switch_right: ; | |
719 bcf INTCON,INT0IE ; Disable INT0 | |
720 banksel common ; flag1 is in Bank1 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
721 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
722 bsf switch_right ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
723 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
724 bsf switch_left ; Set flag |
0 | 725 bra isr_switch_common ; Continue... |
726 | |
727 isr_switch_left: ; | |
728 bcf INTCON3,INT1IE ; Disable INT1 | |
729 banksel common ; flag1 is in Bank1 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
730 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
731 bsf switch_left ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
732 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
733 bsf switch_right ; Set flag |
0 | 734 isr_switch_common: |
735 ; load timer1 for first press | |
736 clrf TMR1L | |
737 movlw TMR1H_VALUE_FIRST ; in steps of 7,8125ms | |
738 movwf TMR1H | |
739 bsf T1CON,TMR1ON ; Start Timer 1 | |
740 banksel isr_backup ; Select Bank0 for ISR data. | |
741 bcf INTCON3,INT1IF ; Clear flag | |
742 bcf INTCON,INT0IF ; Clear flag | |
743 return | |
744 | |
745 timer1int: | |
746 bcf PIR1,TMR1IF ; Clear flag | |
747 banksel common ; flag1 is in Bank1 | |
204 | 748 bcf INTCON,INT0IF ; Clear flag |
749 bcf INTCON3,INT1IF ; Clear flag | |
0 | 750 btfss switch_left1 ; Left button hold-down? |
751 bra timer1int_left ; Yes | |
752 btfss switch_right2 ; Right button hold-down? | |
753 bra timer1int_right ; Yes | |
754 | |
755 ; No button hold-down, stop Timer 1 | |
756 bcf T1CON,TMR1ON ; Stop Timer 1 | |
757 bsf INTCON,INT0IE ; Enable INT0 | |
758 bsf INTCON3,INT1IE ; Enable INT1 | |
759 return | |
760 | |
761 timer1int_left: | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
762 btfss flip_screen ; 180° flipped? |
0 | 763 bsf switch_left ; (Re-)Set flag |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
764 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
765 bsf switch_right ; (Re-)Set flag |
0 | 766 bra timer1int_common ; Continue |
767 timer1int_right: | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
768 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
769 bsf switch_right ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
770 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
771 bsf switch_left ; Set flag |
0 | 772 timer1int_common: |
773 ; load timer1 for next press | |
774 clrf TMR1L | |
775 movlw TMR1H_VALUE_CONT ; Surface mode | |
776 btfsc divemode | |
777 movlw TMR1H_VALUE_CONT_DIVE ; Dive mode | |
778 movwf TMR1H | |
779 return ; Return from timer1int with timer1 kept running | |
780 | |
781 ;============================================================================= | |
782 | |
783 check_nofly_desat_time: | |
784 movf nofly_time+0,W ; Is nofly null ? | |
785 iorwf nofly_time+1,W | |
786 bz check_nofly_desat_time2 ; yes... | |
787 | |
788 movlw d'1' | |
789 subwf nofly_time+0,F | |
790 movlw d'0' | |
791 subwfb nofly_time+1,F ; reduce by one | |
792 | |
793 check_nofly_desat_time2: | |
794 movf desaturation_time+0,W ; Is Desat null ? | |
795 iorwf desaturation_time+1,W | |
796 bz check_nofly_desat_time3 ; yes... | |
797 | |
798 movlw d'1' | |
799 subwf desaturation_time+0,F | |
800 movlw d'0' | |
801 subwfb desaturation_time+1,F ; reduce by one... | |
802 | |
147 | 803 ; Increase surface interval timer |
804 infsnz surface_interval+0,F | |
805 incf surface_interval+1,F | |
0 | 806 return ; Done |
807 | |
808 check_nofly_desat_time3: | |
809 clrf surface_interval+0 | |
810 clrf surface_interval+1 ; Clear surface interval timer | |
811 return ; Done. | |
812 | |
813 ;============================================================================= | |
814 | |
815 isr_restore_clock: | |
816 banksel isr_backup | |
817 movlw d'1' | |
319 | 818 cpfseq speed_setting |
0 | 819 bra isr_restore_speed2 |
820 ; Reset to eco | |
821 movlw b'00000000' | |
822 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
823 movlw b'00110010' | |
824 movwf OSCCON ; 1MHz INTOSC | |
825 movlw T2CON_ECO | |
826 movwf T2CON | |
827 bra isr_restore_exit | |
828 isr_restore_speed2: | |
829 movlw d'2' | |
319 | 830 cpfseq speed_setting |
0 | 831 bra isr_restore_speed3 |
832 ; Reset to normal | |
833 movlw b'01110010' | |
834 movwf OSCCON ; 16MHz INTOSC | |
835 movlw b'00000000' | |
836 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
837 movlw T2CON_NORMAL | |
838 movwf T2CON | |
839 bra isr_restore_exit | |
840 | |
841 isr_restore_speed3: | |
842 ; Reset to fastest | |
843 movlw b'01110010' ; 16MHz INTOSC | |
844 movwf OSCCON | |
845 movlw b'01000000' | |
846 movwf OSCTUNE ; 4x PLL Enable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
847 movlw T2CON_FASTEST | |
848 movwf T2CON | |
849 ; bra isr_restore_exit | |
850 isr_restore_exit: | |
851 btfss OSCCON,HFIOFS | |
852 bra isr_restore_exit ; loop until PLL is stable | |
853 return | |
854 | |
855 END |