Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/interface.asm @ 0:96a35aeda5f2
Initial setup
| author | heinrichsweikamp |
|---|---|
| date | Tue, 12 Jan 2010 15:05:59 +0100 |
| parents | |
| children | 73014f788032 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:96a35aeda5f2 |
|---|---|
| 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 | |
| 29 call set_LEDusb | |
| 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 | |
| 34 call clear_LEDusb | |
| 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 | |
| 42 call set_LEDusb | |
| 43 | |
| 44 call deco_main_clear_tissue ; Reset Decodata | |
| 45 movlb b'00000001' ; select ram bank 1 | |
| 46 call deco_main_calc_desaturation_time ; calculate desaturation time | |
| 47 movlb b'00000001' ; select ram bank 1 | |
| 48 call main_clear_CNS_fraction ; clear CNS | |
| 49 movlb b'00000001' ; select ram bank 1 | |
| 50 | |
| 51 movlw d'1' | |
| 52 movwf nofly_time+0 ; Clear nofly time | |
| 53 clrf nofly_time+1 ; Clear nofly time | |
| 54 | |
| 55 movlw 'h' ; send echo | |
| 56 movwf TXREG ; When done | |
| 57 call rs232_wait_tx ; wait for UART | |
| 58 | |
| 59 bsf oneminupdate ; set flag, so display will be updated at once | |
| 60 call clear_LEDusb | |
| 61 bsf PIE1,RCIE ; Interrupt for RS232 | |
| 62 goto surfloop_loop ; return to surface loop | |
| 63 | |
| 64 ; send internal EEPROM BANK 0 via the UART | |
| 65 send_int_eeprom_b0: | |
| 66 bcf uart_send_int_eeprom ; clear flag | |
| 67 bcf PIE1,RCIE ; No Interrupt for UART | |
| 68 call set_LEDusb | |
| 69 | |
| 70 clrf EEADRH ; Point to Bank0 | |
| 71 rcall send_internal_eeprom1 ; sends complete 1st. page of internal EEPROM | |
| 72 | |
| 73 call clear_LEDusb | |
| 74 bsf PIE1,RCIE ; Interrupt for RS232 | |
| 75 goto surfloop_loop ; return to surface loop | |
| 76 | |
| 77 ; send internal EEPROM BANK 1 via the UART | |
| 78 send_int_eeprom_b1: | |
| 79 bcf uart_send_int_eeprom2 ; clear flag | |
| 80 bcf PIE1,RCIE ; No Interrupt for UART | |
| 81 call set_LEDusb | |
| 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 | |
| 88 call clear_LEDusb | |
| 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 | |
| 97 call set_LEDusb | |
| 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 | |
| 115 call clear_LEDusb | |
| 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 | |
| 124 call set_LEDusb | |
| 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' | |
| 226 call clear_LEDusb | |
| 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 |
