Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/interface.asm @ 524:6fa776a44768
BUGFIX spurious random NDL>0 during deco dive.
author | JeanDo |
---|---|
date | Fri, 09 Dec 2011 20:43:50 +0100 |
parents | c512a868937c |
children | fbd5e2b75a63 |
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 | |
66 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 67 bsf LED_blue |
68 | |
0 | 69 clrf EEADRH ; Point to Bank0 |
70 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM | |
71 | |
21 | 72 bcf LED_blue |
0 | 73 bsf PIE1,RCIE ; Interrupt for RS232 |
74 goto surfloop_loop ; return to surface loop | |
75 | |
76 ; send internal EEPROM BANK 1 via the UART | |
77 send_int_eeprom_b1: | |
78 bcf uart_send_int_eeprom2 ; clear flag | |
79 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 80 bsf LED_blue |
81 | |
0 | 82 |
83 movlw d'1' | |
84 movwf EEADRH ; Point to Bank1 | |
85 rcall send_internal_eeprom1 ; sends complete 2nd page of internal EEPROM | |
86 clrf EEADRH ; Point to Bank0 | |
87 | |
21 | 88 bcf LED_blue |
0 | 89 bsf PIE1,RCIE ; Interrupt for RS232 |
90 goto surfloop_loop ; return to surface loop | |
91 | |
92 | |
93 ; Send firmware version and 16bytes MD2 hash via the UART | |
94 send_md2_hash: | |
95 bcf uart_send_hash ; clear flag | |
96 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 97 bsf LED_blue |
0 | 98 |
99 call rs232_wait_tx ; wait for UART | |
100 movlw softwareversion_x ; Softwareversion | |
101 movwf TXREG | |
102 call rs232_wait_tx ; wait for UART | |
103 movlw softwareversion_y ; Softwareversion | |
104 movwf TXREG | |
105 | |
106 lfsr FSR2, char_O_hash | |
107 movlw d'16' | |
108 movwf temp1 | |
109 send_md2_hash2: | |
110 call rs232_wait_tx ; wait for UART | |
111 movff POSTINC2,TXREG ; copy hash byte to TXREG | |
112 decfsz temp1,F | |
113 bra send_md2_hash2 ; loop 16 times | |
114 | |
21 | 115 bcf LED_blue |
0 | 116 bsf PIE1,RCIE ; Interrupt for RS232 |
117 goto surfloop_loop ; return to surface loop | |
118 | |
119 | |
120 ; Sends first 256Byte from internal and first 32KB from external EEPROM using the UART module | |
121 menu_interface: | |
122 bcf dump_external_eeprom ; clear flag | |
123 bcf PIE1,RCIE ; No Interrupt for UART | |
21 | 124 bsf LED_blue |
0 | 125 call PLED_ClearScreen |
126 call PLED_topline_box | |
127 WIN_INVERT .1 ; Init new Wordprocessor | |
128 DISPLAYTEXT .15 ; "Interface" | |
129 WIN_INVERT .0 ; Init new Wordprocessor | |
130 | |
131 movlw d'5' | |
132 movwf uart1_temp | |
133 menu_interface1: | |
134 movlw 0xAA ; Startbytes | |
135 movwf TXREG | |
136 call rs232_wait_tx ; wait for UART | |
137 decfsz uart1_temp | |
138 bra menu_interface1 | |
139 movlw 0x55 ; finish preamble | |
140 movwf TXREG | |
141 | |
142 DISPLAYTEXT .16 ; "Start" | |
143 | |
144 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
|
145 |
0 | 146 movlw d'1' ; increase |
147 addwf eeprom_address+0,F | |
148 movlw d'0' | |
455
c512a868937c
last work for 2.0: Fixing 32kB boundary read for logbook
heinrichsweikamp
parents:
376
diff
changeset
|
149 addwfc eeprom_address+1,F |
0 | 150 |
376
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
151 ;For debug only |
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
152 ;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
|
153 ;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
|
154 |
0 | 155 DISPLAYTEXT .17 ; "Data" |
156 | |
157 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM | |
158 | |
159 call rs232_wait_tx ; wait for UART | |
160 movff batt_voltage+0,TXREG ; Battery | |
161 | |
162 call rs232_wait_tx ; wait for UART | |
163 movff batt_voltage+1,TXREG ; Battery | |
164 | |
165 call rs232_wait_tx ; wait for UART | |
166 movlw softwareversion_x ; Softwareversion | |
167 movwf TXREG | |
168 | |
169 call rs232_wait_tx ; wait for UART | |
170 movlw softwareversion_y ; Softwareversion | |
171 movwf TXREG | |
172 | |
173 DISPLAYTEXT .18 ; "Header" | |
174 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
175 setf uart1_temp ; low address counter |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
176 setf uart2_temp ; high address counter |
0 | 177 |
178 menu_interface3: | |
179 bsf SSPCON2,SEN ; Start condition | |
180 call WaitMSSP | |
181 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
182 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
183 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
184 movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 |
0 | 185 movwf SSPBUF ; control byte |
186 call WaitMSSP | |
187 btfsc SSPCON2,ACKSTAT | |
188 bra menu_interface3 ; No Ack, try again! | |
189 | |
190 movff eeprom_address+1,SSPBUF ; High Address byte | |
191 call WaitMSSP | |
192 call I2C_WaitforACK | |
193 movff eeprom_address+0,SSPBUF ; Low Address byte | |
194 call WaitMSSP | |
195 call I2C_WaitforACK | |
196 bsf SSPCON2,RSEN ; Start condition | |
197 call WaitMSSP | |
198 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
199 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
200 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
201 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
|
202 |
0 | 203 movwf SSPBUF ; control byte |
204 call WaitMSSP | |
205 call I2C_WaitforACK | |
206 | |
207 DISPLAYTEXT .19 ; "Profile" | |
208 | |
209 menu_interface2: | |
210 call rs232_wait_tx ; wait for UART | |
211 | |
212 movlw d'1' | |
213 addwf uart1_temp,F | |
214 movlw d'0' | |
215 addwfc uart2_temp,F | |
216 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
217 ; Slow but safe... |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
218 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
|
219 movff SSPBUF, TXREG |
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
220 |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
221 movlw 0xFF |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
222 cpfseq uart2_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
223 bra menu_interface2 ; No, continue |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
224 cpfseq uart1_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
225 bra menu_interface2 ; No, continue |
350
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
226 |
0 | 227 DISPLAYTEXT .20 ; Done. |
228 | |
229 WAITMS d'250' | |
21 | 230 bcf LED_blue |
0 | 231 bsf PIE1,RCIE ; Interrupt for RS232 |
232 goto surfloop ; back to surfacemode | |
233 | |
234 send_internal_eeprom1: | |
235 clrf uart1_temp ; Send the total of 256bytes | |
236 clrf EEADR ; Send bytes 0-255 from internal EEPROM | |
237 send_internal_eeprom2: | |
238 call read_eeprom ; read byte | |
239 movff EEDATA,TXREG ; send byte | |
240 incf EEADR,F ; increase pointer | |
241 call rs232_wait_tx ; wait for UART | |
242 decfsz uart1_temp,F ; until limit reached | |
243 bra send_internal_eeprom2 | |
244 return |