Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/interface.asm @ 619:85e8e1501fd8
New CF66: Show GF in NDL (If GF > CF08)
author | heinrichsweikamp |
---|---|
date | Fri, 27 Jul 2012 19:32:18 +0200 |
parents | fbd5e2b75a63 |
children | 6e456a6398e0 |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; Interface, Downloader, MD2 Hash send routine | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 10/30/05 | |
22 ; last updated: 12/27/07 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 uart_store_tissues: | |
27 bcf uart_store_tissue_data ; Clear flag | |
28 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 29 bsf LED_blue |
0 | 30 call simulator_save_tissue_data ; store and set flag for automatic restore |
31 movlw 'k' ; send echo | |
32 movwf TXREG ; When done | |
33 call rs232_wait_tx ; wait for UART | |
21 | 34 bcf LED_blue |
0 | 35 bsf PIE1,RCIE ; Interrupt for RS232 |
36 goto surfloop_loop ; return to surface loop | |
37 | |
38 ; reset Decodata | |
39 reset_decodata: | |
40 bcf uart_reset_decodata ; clear flag | |
41 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 42 bsf LED_blue |
0 | 43 |
116 | 44 call deco_clear_tissue ; Reset Decodata |
0 | 45 movlb b'00000001' ; select ram bank 1 |
116 | 46 call deco_calc_desaturation_time ; calculate desaturation time |
0 | 47 movlb b'00000001' ; select ram bank 1 |
116 | 48 call deco_clear_CNS_fraction ; clear CNS |
0 | 49 movlb b'00000001' ; select ram bank 1 |
50 | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
116
diff
changeset
|
51 clrf nofly_time+0 ; Clear nofly time |
0 | 52 clrf nofly_time+1 ; Clear nofly time |
53 | |
54 movlw 'h' ; send echo | |
55 movwf TXREG ; When done | |
56 call rs232_wait_tx ; wait for UART | |
57 | |
58 bsf oneminupdate ; set flag, so display will be updated at once | |
21 | 59 bcf LED_blue |
0 | 60 bsf PIE1,RCIE ; Interrupt for RS232 |
61 goto surfloop_loop ; return to surface loop | |
62 | |
63 ; send internal EEPROM BANK 0 via the UART | |
64 send_int_eeprom_b0: | |
65 bcf uart_send_int_eeprom ; clear flag | |
578 | 66 movlw .0 ; Point to Bank0 |
67 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM | |
0 | 68 goto surfloop_loop ; return to surface loop |
69 | |
70 ; send internal EEPROM BANK 1 via the UART | |
71 send_int_eeprom_b1: | |
72 bcf uart_send_int_eeprom2 ; clear flag | |
578 | 73 movlw d'1' |
74 movwf EEADRH ; Point to Bank1 | |
75 rcall send_internal_eeprom1 ; sends complete 2nd page of internal EEPROM | |
76 goto surfloop_loop ; return to surface loop | |
0 | 77 |
578 | 78 ; send internal EEPROM BANK 2 via the UART |
79 send_int_eeprom_b2: | |
80 bcf uart_send_int_eeprom3 ; clear flag | |
81 movlw d'2' | |
82 movwf EEADRH ; Point to Bank1 | |
83 rcall send_internal_eeprom1 ; sends complete 2nd page of internal EEPROM | |
0 | 84 goto surfloop_loop ; return to surface loop |
85 | |
86 | |
87 ; Send firmware version and 16bytes MD2 hash via the UART | |
88 send_md2_hash: | |
89 bcf uart_send_hash ; clear flag | |
90 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 91 bsf LED_blue |
0 | 92 |
93 call rs232_wait_tx ; wait for UART | |
94 movlw softwareversion_x ; Softwareversion | |
95 movwf TXREG | |
96 call rs232_wait_tx ; wait for UART | |
97 movlw softwareversion_y ; Softwareversion | |
98 movwf TXREG | |
99 | |
100 lfsr FSR2, char_O_hash | |
101 movlw d'16' | |
102 movwf temp1 | |
103 send_md2_hash2: | |
104 call rs232_wait_tx ; wait for UART | |
105 movff POSTINC2,TXREG ; copy hash byte to TXREG | |
106 decfsz temp1,F | |
107 bra send_md2_hash2 ; loop 16 times | |
108 | |
21 | 109 bcf LED_blue |
0 | 110 bsf PIE1,RCIE ; Interrupt for RS232 |
111 goto surfloop_loop ; return to surface loop | |
112 | |
113 | |
114 ; Sends first 256Byte from internal and first 32KB from external EEPROM using the UART module | |
115 menu_interface: | |
116 bcf dump_external_eeprom ; clear flag | |
117 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 118 bsf LED_blue |
0 | 119 call PLED_ClearScreen |
120 call PLED_topline_box | |
121 WIN_INVERT .1 ; Init new Wordprocessor | |
122 DISPLAYTEXT .15 ; "Interface" | |
123 WIN_INVERT .0 ; Init new Wordprocessor | |
124 | |
125 movlw d'5' | |
126 movwf uart1_temp | |
127 menu_interface1: | |
128 movlw 0xAA ; Startbytes | |
129 movwf TXREG | |
130 call rs232_wait_tx ; wait for UART | |
131 decfsz uart1_temp | |
132 bra menu_interface1 | |
133 movlw 0x55 ; finish preamble | |
134 movwf TXREG | |
135 | |
136 DISPLAYTEXT .16 ; "Start" | |
137 | |
138 call get_free_EEPROM_location ; | |
376
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
139 |
0 | 140 movlw d'1' ; increase |
141 addwf eeprom_address+0,F | |
142 movlw d'0' | |
455
c512a868937c
last work for 2.0: Fixing 32kB boundary read for logbook
heinrichsweikamp
parents:
376
diff
changeset
|
143 addwfc eeprom_address+1,F |
0 | 144 |
376
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
145 ;For debug only |
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
146 ;clrf eeprom_address+0,F |
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
147 ;clrf eeprom_address+1,F |
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
148 |
0 | 149 DISPLAYTEXT .17 ; "Data" |
150 | |
578 | 151 movlw .0 ; Point to Bank0 |
0 | 152 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM |
578 | 153 bsf LED_blue |
0 | 154 |
155 call rs232_wait_tx ; wait for UART | |
156 movff batt_voltage+0,TXREG ; Battery | |
157 | |
158 call rs232_wait_tx ; wait for UART | |
159 movff batt_voltage+1,TXREG ; Battery | |
160 | |
161 call rs232_wait_tx ; wait for UART | |
162 movlw softwareversion_x ; Softwareversion | |
163 movwf TXREG | |
164 | |
165 call rs232_wait_tx ; wait for UART | |
166 movlw softwareversion_y ; Softwareversion | |
167 movwf TXREG | |
168 | |
169 DISPLAYTEXT .18 ; "Header" | |
170 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
171 setf uart1_temp ; low address counter |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
172 setf uart2_temp ; high address counter |
0 | 173 |
174 menu_interface3: | |
175 bsf SSPCON2,SEN ; Start condition | |
176 call WaitMSSP | |
177 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
178 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
179 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
180 movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 |
0 | 181 movwf SSPBUF ; control byte |
182 call WaitMSSP | |
183 btfsc SSPCON2,ACKSTAT | |
184 bra menu_interface3 ; No Ack, try again! | |
185 | |
186 movff eeprom_address+1,SSPBUF ; High Address byte | |
187 call WaitMSSP | |
188 call I2C_WaitforACK | |
189 movff eeprom_address+0,SSPBUF ; Low Address byte | |
190 call WaitMSSP | |
191 call I2C_WaitforACK | |
192 bsf SSPCON2,RSEN ; Start condition | |
193 call WaitMSSP | |
194 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
195 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
196 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
197 movlw b'10100111' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
198 |
0 | 199 movwf SSPBUF ; control byte |
200 call WaitMSSP | |
201 call I2C_WaitforACK | |
202 | |
203 DISPLAYTEXT .19 ; "Profile" | |
204 | |
205 menu_interface2: | |
206 call rs232_wait_tx ; wait for UART | |
207 | |
208 movlw d'1' | |
209 addwf uart1_temp,F | |
210 movlw d'0' | |
211 addwfc uart2_temp,F | |
212 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
213 ; Slow but safe... |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
214 call I2CREAD2 ; same as I2CREAD but with automatic address increase |
350
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
215 movff SSPBUF, TXREG |
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
216 |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
217 movlw 0xFF |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
218 cpfseq uart2_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
219 bra menu_interface2 ; No, continue |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
220 cpfseq uart1_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
221 bra menu_interface2 ; No, continue |
350
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
222 |
0 | 223 DISPLAYTEXT .20 ; Done. |
224 | |
225 WAITMS d'250' | |
21 | 226 bcf LED_blue |
0 | 227 bsf PIE1,RCIE ; Interrupt for RS232 |
228 goto surfloop ; back to surfacemode | |
229 | |
230 send_internal_eeprom1: | |
578 | 231 movwf EEADRH ; Point to Bank "WREG" |
232 bcf PIE1,RCIE ; No Interrupt for UART | |
233 bsf LED_blue | |
0 | 234 clrf uart1_temp ; Send the total of 256bytes |
235 clrf EEADR ; Send bytes 0-255 from internal EEPROM | |
236 send_internal_eeprom2: | |
237 call read_eeprom ; read byte | |
238 movff EEDATA,TXREG ; send byte | |
239 incf EEADR,F ; increase pointer | |
240 call rs232_wait_tx ; wait for UART | |
241 decfsz uart1_temp,F ; until limit reached | |
242 bra send_internal_eeprom2 | |
578 | 243 clrf EEADRH ; Point to Bank0 |
244 bcf LED_blue | |
245 bsf PIE1,RCIE ; Interrupt for RS232 | |
0 | 246 return |