Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/interface.asm @ 353:b5b030c1ae7e
Avoid spurious switch-depth stops with 3 or more gas.
author | JeanDo |
---|---|
date | Tue, 07 Jun 2011 01:16:55 +0200 |
parents | 85ea09d3b9d8 |
children | 7250ca7c8d24 |
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 ; | |
145 movlw d'1' ; increase | |
146 addwf eeprom_address+0,F | |
147 movlw d'0' | |
148 addwfc eeprom_address+1,F | |
149 | |
150 DISPLAYTEXT .17 ; "Data" | |
151 | |
152 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM | |
153 | |
154 call rs232_wait_tx ; wait for UART | |
155 movff batt_voltage+0,TXREG ; Battery | |
156 | |
157 call rs232_wait_tx ; wait for UART | |
158 movff batt_voltage+1,TXREG ; Battery | |
159 | |
160 call rs232_wait_tx ; wait for UART | |
161 movlw softwareversion_x ; Softwareversion | |
162 movwf TXREG | |
163 | |
164 call rs232_wait_tx ; wait for UART | |
165 movlw softwareversion_y ; Softwareversion | |
166 movwf TXREG | |
167 | |
168 DISPLAYTEXT .18 ; "Header" | |
169 | |
170 clrf uart1_temp ; low address counter | |
171 clrf uart2_temp ; high address counter | |
172 | |
173 menu_interface3: | |
174 bsf SSPCON2,SEN ; Start condition | |
175 call WaitMSSP | |
176 | |
177 movlw b'10100110' ; Bit0=0: WRITE, Bit0=1: READ | |
178 movwf SSPBUF ; control byte | |
179 call WaitMSSP | |
180 btfsc SSPCON2,ACKSTAT | |
181 bra menu_interface3 ; No Ack, try again! | |
182 | |
183 movff eeprom_address+1,SSPBUF ; High Address byte | |
184 call WaitMSSP | |
185 call I2C_WaitforACK | |
186 movff eeprom_address+0,SSPBUF ; Low Address byte | |
187 call WaitMSSP | |
188 call I2C_WaitforACK | |
189 bsf SSPCON2,RSEN ; Start condition | |
190 call WaitMSSP | |
191 | |
192 movlw b'10100111' ; Bit0=0: WRITE, Bit0=1: READ | |
193 movwf SSPBUF ; control byte | |
194 call WaitMSSP | |
195 call I2C_WaitforACK | |
196 | |
197 DISPLAYTEXT .19 ; "Profile" | |
198 | |
199 menu_interface2: | |
200 call rs232_wait_tx ; wait for UART | |
201 | |
202 bsf SSPCON2, RCEN ; Enable recieve mode | |
203 call WaitMSSP | |
204 | |
205 movff SSPBUF, TXREG | |
206 | |
207 movlw d'1' | |
208 addwf uart1_temp,F | |
209 movlw d'0' | |
210 addwfc uart2_temp,F | |
211 | |
212 btfsc uart2_temp,7 ; 32KB done? | |
213 bra menu_interface4 ; Yes | |
214 | |
215 bsf SSPCON2, ACKEN ; Ack | |
216 call WaitMSSP | |
217 bra menu_interface2 ; go on | |
218 | |
219 menu_interface4: | |
220 bsf SSPCON2, PEN ; Stop | |
221 call WaitMSSP | |
222 | |
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: | |
231 clrf uart1_temp ; Send the total of 256bytes | |
232 clrf EEADR ; Send bytes 0-255 from internal EEPROM | |
233 send_internal_eeprom2: | |
234 call read_eeprom ; read byte | |
235 movff EEDATA,TXREG ; send byte | |
236 incf EEADR,F ; increase pointer | |
237 call rs232_wait_tx ; wait for UART | |
238 decfsz uart1_temp,F ; until limit reached | |
239 bra send_internal_eeprom2 | |
240 return |