Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/interface.asm @ 729:71e88ee8bbf2
battery info updater
author | heinrichsweikamp |
---|---|
date | Sun, 16 Jun 2013 15:50:37 +0200 |
parents | 4452837aff37 |
children | c50296c3059e |
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' | |
703 | 82 movwf EEADRH ; Point to Bank2 |
578 | 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 |
681 | 119 call DISP_ClearScreen |
717 | 120 call DISP_divemask_color |
0 | 121 DISPLAYTEXT .15 ; "Interface" |
717 | 122 call DISP_standard_color |
0 | 123 movlw d'5' |
124 movwf uart1_temp | |
125 menu_interface1: | |
126 movlw 0xAA ; Startbytes | |
127 movwf TXREG | |
128 call rs232_wait_tx ; wait for UART | |
129 decfsz uart1_temp | |
130 bra menu_interface1 | |
131 movlw 0x55 ; finish preamble | |
132 movwf TXREG | |
133 | |
134 DISPLAYTEXT .16 ; "Start" | |
135 | |
136 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
|
137 |
0 | 138 movlw d'1' ; increase |
139 addwf eeprom_address+0,F | |
140 movlw d'0' | |
455
c512a868937c
last work for 2.0: Fixing 32kB boundary read for logbook
heinrichsweikamp
parents:
376
diff
changeset
|
141 addwfc eeprom_address+1,F |
0 | 142 |
376
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
143 ;For debug only |
ed26990716fe
first gas does not reset change depth, display fix with multigas dives in logbook
heinrichsweikamp
parents:
351
diff
changeset
|
144 ;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
|
145 ;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
|
146 |
0 | 147 DISPLAYTEXT .17 ; "Data" |
148 | |
578 | 149 movlw .0 ; Point to Bank0 |
0 | 150 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM |
578 | 151 bsf LED_blue |
0 | 152 |
153 call rs232_wait_tx ; wait for UART | |
154 movff batt_voltage+0,TXREG ; Battery | |
155 | |
156 call rs232_wait_tx ; wait for UART | |
157 movff batt_voltage+1,TXREG ; Battery | |
158 | |
159 call rs232_wait_tx ; wait for UART | |
160 movlw softwareversion_x ; Softwareversion | |
161 movwf TXREG | |
162 | |
163 call rs232_wait_tx ; wait for UART | |
164 movlw softwareversion_y ; Softwareversion | |
165 movwf TXREG | |
166 | |
167 DISPLAYTEXT .18 ; "Header" | |
168 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
169 setf uart1_temp ; low address counter |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
170 setf uart2_temp ; high address counter |
0 | 171 |
172 menu_interface3: | |
173 bsf SSPCON2,SEN ; Start condition | |
174 call WaitMSSP | |
175 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
176 movlw b'10101110' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
177 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
178 movlw b'10100110' ; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1 |
0 | 179 movwf SSPBUF ; control byte |
180 call WaitMSSP | |
181 btfsc SSPCON2,ACKSTAT | |
182 bra menu_interface3 ; No Ack, try again! | |
183 | |
184 movff eeprom_address+1,SSPBUF ; High Address byte | |
185 call WaitMSSP | |
186 call I2C_WaitforACK | |
187 movff eeprom_address+0,SSPBUF ; Low Address byte | |
188 call WaitMSSP | |
189 call I2C_WaitforACK | |
190 bsf SSPCON2,RSEN ; Start condition | |
191 call WaitMSSP | |
192 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
193 movlw b'10101111' ; Bit0=0: WRITE, Bit0=1: READ, BLOCK2 |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
194 btfss eeprom_address+1,7 ; Access Block2? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
195 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
|
196 |
0 | 197 movwf SSPBUF ; control byte |
198 call WaitMSSP | |
199 call I2C_WaitforACK | |
200 | |
201 DISPLAYTEXT .19 ; "Profile" | |
202 | |
203 menu_interface2: | |
204 call rs232_wait_tx ; wait for UART | |
205 | |
206 movlw d'1' | |
207 addwf uart1_temp,F | |
208 movlw d'0' | |
209 addwfc uart2_temp,F | |
210 | |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
211 ; Slow but safe... |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
212 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
|
213 movff SSPBUF, TXREG |
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
214 |
351
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
215 movlw 0xFF |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
216 cpfseq uart2_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
217 bra menu_interface2 ; No, continue |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
218 cpfseq uart1_temp ;=0xFFFF? |
5c186a72cb5d
Debugging the new logbook format, 64kB download routine
heinrichsweikamp
parents:
350
diff
changeset
|
219 bra menu_interface2 ; No, continue |
350
7250ca7c8d24
64kByte logbook (Still incompatible to existing PC software)
heinrichsweikamp
parents:
229
diff
changeset
|
220 |
0 | 221 DISPLAYTEXT .20 ; Done. |
222 | |
223 WAITMS d'250' | |
21 | 224 bcf LED_blue |
0 | 225 bsf PIE1,RCIE ; Interrupt for RS232 |
720 | 226 goto surfloop_no_display_init ; back to surfacemode |
0 | 227 |
228 send_internal_eeprom1: | |
578 | 229 movwf EEADRH ; Point to Bank "WREG" |
230 bcf PIE1,RCIE ; No Interrupt for UART | |
231 bsf LED_blue | |
0 | 232 clrf uart1_temp ; Send the total of 256bytes |
233 clrf EEADR ; Send bytes 0-255 from internal EEPROM | |
234 send_internal_eeprom2: | |
235 call read_eeprom ; read byte | |
236 movff EEDATA,TXREG ; send byte | |
237 incf EEADR,F ; increase pointer | |
238 call rs232_wait_tx ; wait for UART | |
239 decfsz uart1_temp,F ; until limit reached | |
240 bra send_internal_eeprom2 | |
578 | 241 clrf EEADRH ; Point to Bank0 |
242 bcf LED_blue | |
243 bsf PIE1,RCIE ; Interrupt for RS232 | |
0 | 244 return |