Mercurial > public > hwos_code
comparison src/comm.asm @ 560:b7eb98dbd800
bump to 2.96beta (REFACTORED VERSION)
author | heinrichsweikamp |
---|---|
date | Wed, 31 Jan 2018 19:39:37 +0100 |
parents | f9cc49750736 |
children | 8b7ea27ea1fa |
comparison
equal
deleted
inserted
replaced
559:9cb967d844f0 | 560:b7eb98dbd800 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File comm.asm | 3 ; File comm.asm REFACTORED VERSION 2.94 |
4 ; | 4 ; |
5 ; RS232 via USB | 5 ; RS232 via USB |
6 ; | 6 ; |
7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
105 rcall comm_write_get_byte | 105 rcall comm_write_get_byte |
106 | 106 |
107 movlw 0xAA ; start byte=0xAA? | 107 movlw 0xAA ; start byte=0xAA? |
108 cpfseq RCREG1 | 108 cpfseq RCREG1 |
109 bra comm_mode2a | 109 bra comm_mode2a |
110 bra comm_mode2b ; Startbyte for service mode found | 110 bra comm_mode2b ; Startbyte for service mode found |
111 comm_mode2a: | 111 comm_mode2a: |
112 movlw 0xBB ; start byte=0xBB? | 112 movlw 0xBB ; start byte=0xBB? |
113 cpfseq RCREG1 | 113 cpfseq RCREG1 |
114 bra comm_mode2c | 114 bra comm_mode2c |
115 bra comm_download_mode ; Startbyte for download mode found | 115 bra comm_download_mode ; Startbyte for download mode found |
116 | 116 |
117 comm_mode2c: | 117 comm_mode2c: |
118 btfss vusb_in ; USB plugged in? | 118 btfss vusb_in ; USB plugged in? |
119 bra comm_service_exit_nousb_delay ; Disconnected -> Exit | 119 bra comm_service_exit_nousb_delay ; Disconnected -> Exit |
120 comm_mode4a: | 120 comm_mode4a: |
122 bra comm_service_exit | 122 bra comm_service_exit |
123 | 123 |
124 btfsc onesecupdate | 124 btfsc onesecupdate |
125 bra comm_mode1 | 125 bra comm_mode1 |
126 | 126 |
127 bra comm_mode2 ; Cycle | 127 bra comm_mode2 ; Cycle |
128 | 128 |
129 comm_mode2b: | 129 comm_mode2b: |
130 ; Startbyte found | 130 ; Startbyte found |
131 rcall comm_rs232_wait_tx ; Wait for UART | 131 rcall comm_rs232_wait_tx ; Wait for UART |
132 movlw 0x4B | 132 movlw 0x4B |
133 movwf TXREG1 ; Send Answer | 133 movwf TXREG1 ; Send Answer |
134 ; Now, check comm command | 134 ; Now, check comm command |
135 | 135 |
136 rcall comm_write_get_byte ; first byte | 136 rcall comm_write_get_byte ; first byte |
137 rcall comm_rs232_wait_tx ; Wait for UART | 137 rcall comm_rs232_wait_tx ; Wait for UART |
138 movff RCREG1,TXREG1 ; Echo | 138 movff RCREG1,TXREG1 ; Echo |
139 movlw UPPER comm_service_key | 139 movlw UPPER comm_service_key |
140 cpfseq RCREG1 | 140 cpfseq RCREG1 |
141 bra comm_mode1 ; Wrong -> Restart | 141 bra comm_mode1 ; Wrong -> Restart |
142 rcall comm_write_get_byte ; second byte | 142 rcall comm_write_get_byte ; second byte |
143 rcall comm_rs232_wait_tx ; Wait for UART | 143 rcall comm_rs232_wait_tx ; Wait for UART |
144 movff RCREG1,TXREG1 ; Echo | 144 movff RCREG1,TXREG1 ; Echo |
145 movlw HIGH (comm_service_key & 0xFFFF) | 145 movlw HIGH (comm_service_key & 0xFFFF) |
146 cpfseq RCREG1 | 146 cpfseq RCREG1 |
147 bra comm_mode1 ; Wrong -> Restart | 147 bra comm_mode1 ; Wrong -> Restart |
148 rcall comm_write_get_byte ; third byte | 148 rcall comm_write_get_byte ; third byte |
149 rcall comm_rs232_wait_tx ; Wait for UART | 149 rcall comm_rs232_wait_tx ; Wait for UART |
150 movff RCREG1,TXREG1 ; Echo | 150 movff RCREG1,TXREG1 ; Echo |
151 movlw LOW comm_service_key | 151 movlw LOW comm_service_key |
152 cpfseq RCREG1 | 152 cpfseq RCREG1 |
153 bra comm_mode1 ; Wrong -> Restart | 153 bra comm_mode1 ; Wrong -> Restart |
154 | 154 |
155 ; Enable comm service mode | 155 ; Enable comm service mode |
156 WIN_SMALL comm_status2_column, comm_status2_row | 156 WIN_SMALL comm_status2_column, comm_status2_row |
157 STRCPY_TEXT_PRINT tUsbServiceMode ; Service mode enabled | 157 STRCPY_TEXT_PRINT tUsbServiceMode ; Service mode enabled |
158 bsf comm_service_enabled ; Set flag... | 158 bsf comm_service_enabled ; Set flag... |
169 | 169 |
170 comm_service_exit: | 170 comm_service_exit: |
171 WIN_SMALL comm_status3_column, comm_status3_row | 171 WIN_SMALL comm_status3_column, comm_status3_row |
172 STRCPY_TEXT_PRINT tUsbExit ; Exited | 172 STRCPY_TEXT_PRINT tUsbExit ; Exited |
173 comm_service_exit_common: | 173 comm_service_exit_common: |
174 rcall comm_rs232_wait_tx ; Wait for UART | 174 rcall comm_rs232_wait_tx ; Wait for UART |
175 movlw 0xFF ; Reply FF | 175 movlw 0xFF ; Reply FF |
176 movwf TXREG1 ; Send Answer | 176 movwf TXREG1 ; Send Answer |
177 | 177 |
178 ; Wait 1 second | 178 ; Wait 1 second |
179 bcf onesecupdate | 179 bcf onesecupdate |
200 | 200 |
201 ;----------------------------------------------------------------------------- | 201 ;----------------------------------------------------------------------------- |
202 ; send firmware to bootloader | 202 ; send firmware to bootloader |
203 ; | 203 ; |
204 comm_send_firmware: | 204 comm_send_firmware: |
205 movlw 0x50 ; send echo | 205 movlw 0x50 ; send echo |
206 movwf TXREG1 | 206 movwf TXREG1 |
207 rcall comm_rs232_wait_tx ; Wait for UART | 207 rcall comm_rs232_wait_tx ; Wait for UART |
208 | 208 |
209 ; Read 5 bytes into buffer. | 209 ; Read 5 bytes into buffer. |
210 lfsr FSR2,buffer | 210 lfsr FSR2,buffer |
211 movlw .5 ; counter | 211 movlw .5 ; counter |
212 movwf lo | 212 movwf lo |
213 movlw 0x55 ; 5'ft byte checksum. | 213 movlw 0x55 ; 5'ft byte checksum. |
214 movwf hi | 214 movwf hi |
215 | 215 |
216 comm_send_firmware_loop: | 216 comm_send_firmware_loop: |
217 rcall comm_write_get_byte | 217 rcall comm_write_get_byte |
218 btfsc rs232_recieve_overflow ; Got byte? | 218 btfsc rs232_recieve_overflow ; Got byte? |
219 bra comm_send_firmware_abort ; No, abort! | 219 bra comm_send_firmware_abort ; No, abort! |
220 movf RCREG1,W | 220 movf RCREG1,W |
221 movwf POSTINC2 ; Store checksum byte. | 221 movwf POSTINC2 ; Store checksum byte. |
222 xorwf hi,F ; Also xor into checksum | 222 xorwf hi,F ; Also xor into checksum |
223 rlncf hi,F ; And rotate it. | 223 rlncf hi,F ; And rotate it. |
224 decfsz lo,F | 224 decfsz lo,F |
225 bra comm_send_firmware_loop | 225 bra comm_send_firmware_loop |
226 | 226 |
227 ; Check that 5ft byte checksum's checksum | 227 ; Check that 5ft byte checksum's checksum |
228 movf hi,W | 228 movf hi,W |
229 bnz comm_send_firmware_failed | 229 bnz comm_send_firmware_failed |
230 | 230 |
231 movlw 0x4C ; send OK | 231 movlw 0x4C ; send OK |
232 movwf TXREG1 | 232 movwf TXREG1 |
233 rcall comm_rs232_wait_tx ; Wait for UART | 233 rcall comm_rs232_wait_tx ; Wait for UART |
234 | 234 |
235 ; Passed: goto second stage verification. | 235 ; Passed: goto second stage verification. |
236 ; NOTE: Bootloader is Bank0. With buffer at address 0x200. | 236 ; NOTE: Bootloader is Bank0. With buffer at address 0x200. |
237 call vault_decodata_into_eeprom ; Store last deco data (And Time/Date) into EEPROM | 237 call vault_decodata_into_eeprom ; Store last deco data (And Time/Date) into EEPROM |
238 goto 0x1FDF0 ; And pray... | 238 goto 0x1FDF0 ; And pray... |
239 | 239 |
240 comm_send_firmware_failed: | 240 comm_send_firmware_failed: |
241 WIN_SMALL comm_string_column, comm_string_row | 241 WIN_SMALL comm_string_column, comm_string_row |
242 call TFT_warnings_color | 242 call TFT_warnings_color |
243 STRCPY_PRINT "Checksum failed" | 243 STRCPY_PRINT "Checksum failed" |
244 | 244 |
245 comm_send_firmware_abort: | 245 comm_send_firmware_abort: |
246 | 246 |
247 movlw 0xFF ; send ABORTED byte. | 247 movlw 0xFF ; send ABORTED byte. |
248 movwf TXREG1 | 248 movwf TXREG1 |
249 bra comm_download_mode0 ; Done. | 249 bra comm_download_mode0 ; Done. |
250 | 250 |
251 ;----------------------------------------------------------------------------- | 251 ;----------------------------------------------------------------------------- |
252 ; Reset to Dive 1 in logbook | 252 ; Reset to Dive 1 in logbook |
271 | 271 |
272 ;----------------------------------------------------------------------------- | 272 ;----------------------------------------------------------------------------- |
273 ; erases range in 4kB steps | 273 ; erases range in 4kB steps |
274 | 274 |
275 comm_erase_range4kb: | 275 comm_erase_range4kb: |
276 movlw 0x42 ; send echo | 276 movlw 0x42 ; send echo |
277 movwf TXREG1 | 277 movwf TXREG1 |
278 rcall comm_rs232_wait_tx ; Wait for UART | 278 rcall comm_rs232_wait_tx ; Wait for UART |
279 | 279 |
280 bcf INTCON,GIE ; All interrups off! | 280 bcf INTCON,GIE ; All interrups off! |
281 | 281 |
282 rcall comm_get_flash_address ; Get three bytes address or return | 282 rcall comm_get_flash_address ; Get three bytes address or return |
283 btfsc rs232_recieve_overflow ; Got Data? | 283 btfsc rs232_recieve_overflow ; Got Data? |
314 call ext_flash_erase4kB ; Erase one block | 314 call ext_flash_erase4kB ; Erase one block |
315 bra comm_download_mode0 ; Done. | 315 bra comm_download_mode0 ; Done. |
316 | 316 |
317 ;----------------------------------------------------------------------------- | 317 ;----------------------------------------------------------------------------- |
318 | 318 |
319 comm_write_range: ; Get 3 bytes start address | 319 comm_write_range: ; Get 3 bytes start address |
320 movlw 0x30 ; send echo | 320 movlw 0x30 ; send echo |
321 movwf TXREG1 | 321 movwf TXREG1 |
322 rcall comm_rs232_wait_tx ; Wait for UART | 322 rcall comm_rs232_wait_tx ; Wait for UART |
323 | 323 |
324 bcf INTCON,GIE ; All interrups off! | 324 bcf INTCON,GIE ; All interrups off! |
325 | 325 |
326 rcall comm_get_flash_address ; Get three bytes address or return | 326 rcall comm_get_flash_address ; Get three bytes address or return |
327 btfsc rs232_recieve_overflow ; Got Data? | 327 btfsc rs232_recieve_overflow ; Got Data? |
328 bra comm_download_mode0 ; No, Done. | 328 bra comm_download_mode0 ; No, Done. |
329 | 329 |
330 comm_write_range_loop: | 330 comm_write_range_loop: |
331 rcall comm_write_get_byte | 331 rcall comm_write_get_byte |
332 btfsc rs232_recieve_overflow ; Got byte? | 332 btfsc rs232_recieve_overflow ; Got byte? |
333 bra comm_download_mode0 ; No, Done (and send OK byte too). | 333 bra comm_download_mode0 ; No, Done (and send OK byte too). |
334 movf RCREG1,W | 334 movf RCREG1,W |
335 ; bsf NCTS ; Hold Bluetooth Chip (Requires PC/Android/iOS side to use flow control...) | 335 ; bsf NCTS ; Hold Bluetooth Chip (Requires PC/Android/iOS side to use flow control...) |
336 call ext_flash_byte_write_comms ; write one byte | 336 call ext_flash_byte_write_comms ; write one byte |
337 ; bcf NCTS ; Release Bluetooth Chip (Requires PC/Android/iOS side to use flow control...) | 337 ; bcf NCTS ; Release Bluetooth Chip (Requires PC/Android/iOS side to use flow control...) |
338 call incf_ext_flash_address_p1 ; increase address+1 | 338 call incf_ext_flash_address_p1 ; increase address+1 |
339 bra comm_write_range_loop | 339 bra comm_write_range_loop |
340 | 340 |
341 ;----------------------------------------------------------------------------- | 341 ;----------------------------------------------------------------------------- |
342 | 342 |
343 comm_send_range: ; Get 3 bytes start address and 3 bytes amount | 343 comm_send_range: ; Get 3 bytes start address and 3 bytes amount |
344 movlw 0x20 ; send echo | 344 movlw 0x20 ; send echo |
345 movwf TXREG1 | 345 movwf TXREG1 |
346 rcall comm_rs232_wait_tx ; Wait for UART | 346 rcall comm_rs232_wait_tx ; Wait for UART |
347 | 347 |
348 bcf INTCON,GIE ; All interrups off! | 348 bcf INTCON,GIE ; All interrups off! |
349 | 349 |
350 rcall comm_get_flash_address ; Get three bytes address or return | 350 rcall comm_get_flash_address ; Get three bytes address or return |
351 btfsc rs232_recieve_overflow ; Got Data? | 351 btfsc rs232_recieve_overflow ; Got Data? |
352 bra comm_download_mode0 ; No, Done. | 352 bra comm_download_mode0 ; No, Done. |
353 | 353 |
354 rcall comm_write_get_byte | 354 rcall comm_write_get_byte |
355 btfsc rs232_recieve_overflow ; Got byte? | 355 btfsc rs232_recieve_overflow ; Got byte? |
356 bra comm_download_mode0 ; No, Done. | 356 bra comm_download_mode0 ; No, Done. |
357 movff RCREG1,up | 357 movff RCREG1,up |
358 rcall comm_write_get_byte | 358 rcall comm_write_get_byte |
359 btfsc rs232_recieve_overflow ; Got byte? | 359 btfsc rs232_recieve_overflow ; Got byte? |
360 bra comm_download_mode0 ; No, Done. | 360 bra comm_download_mode0 ; No, Done. |
361 movff RCREG1,hi | 361 movff RCREG1,hi |
362 rcall comm_write_get_byte | 362 rcall comm_write_get_byte |
363 btfsc rs232_recieve_overflow ; Got byte? | 363 btfsc rs232_recieve_overflow ; Got byte? |
364 bra comm_download_mode0 ; No, Done. | 364 bra comm_download_mode0 ; No, Done. |
365 movff RCREG1,lo | 365 movff RCREG1,lo |
366 | 366 |
367 ; If lo==0, we must precondition hi because there is to many bytes send ! | 367 ; If lo==0, we must precondition hi because there are to many bytes send ! |
368 movf lo,W | 368 movf lo,W |
369 bnz $+4 | 369 bnz $+4 |
370 decf hi,F | 370 decf hi,F |
371 | 371 |
372 movlw 0x40 | 372 movlw 0x40 |
377 ; needs ext_flash_address:3 start address and up:hi:lo amount | 377 ; needs ext_flash_address:3 start address and up:hi:lo amount |
378 | 378 |
379 call ext_flash_read_block_start | 379 call ext_flash_read_block_start |
380 movwf TXREG1 | 380 movwf TXREG1 |
381 | 381 |
382 bra comm_send_range24 ; counter 24bit | 382 bra comm_send_range24 ; counter 24bit |
383 comm_send_range24_loop: | 383 comm_send_range24_loop: |
384 call ext_flash_read_block ; Read one byte | 384 call ext_flash_read_block ; Read one byte |
385 movwf TXREG1 ; Start new transmit | 385 movwf TXREG1 ; Start new transmit |
386 comm_send_range24: | 386 comm_send_range24: |
387 rcall comm_rs232_wait_tx ; Wait for UART | 387 rcall comm_rs232_wait_tx ; Wait for UART |
388 decfsz lo,F | 388 decfsz lo,F |
389 bra comm_send_range24_loop | 389 bra comm_send_range24_loop |
390 decf hi,F | 390 decf hi,F |
391 movlw 0xFF | 391 movlw 0xFF |
392 cpfseq hi | 392 cpfseq hi |
421 comm_download_mode: | 421 comm_download_mode: |
422 ; Enable comm download mode | 422 ; Enable comm download mode |
423 WIN_SMALL comm_status2_column, comm_status2_row | 423 WIN_SMALL comm_status2_column, comm_status2_row |
424 STRCPY_TEXT_PRINT tUsbDownloadMode; Download mode enabled | 424 STRCPY_TEXT_PRINT tUsbDownloadMode; Download mode enabled |
425 bsf INTCON,GIE ; All interrups on | 425 bsf INTCON,GIE ; All interrups on |
426 rcall comm_rs232_wait_tx ; Wait for UART | 426 rcall comm_rs232_wait_tx ; Wait for UART |
427 movlw 0xBB ; Command Echo | 427 movlw 0xBB ; Command Echo |
428 movwf TXREG1 ; Send Answer | 428 movwf TXREG1 ; Send Answer |
429 comm_download_mode0: | 429 comm_download_mode0: |
430 bsf INTCON,GIE ; All interrups on | 430 bsf INTCON,GIE ; All interrups on |
431 rcall comm_rs232_wait_tx ; Wait for UART | 431 rcall comm_rs232_wait_tx ; Wait for UART |
432 movlw 0x4C ; 4C in service mode | 432 movlw 0x4C ; 4C in service mode |
433 btfss comm_service_enabled | 433 btfss comm_service_enabled |
434 movlw 0x4D ; 4D in download mode | 434 movlw 0x4D ; 4D in download mode |
435 movwf TXREG1 ; Send Answer | 435 movwf TXREG1 ; Send Answer |
436 movlw timeout_service_mode | 436 movlw timeout_service_mode |
439 comm_download_mode1: | 439 comm_download_mode1: |
440 bcf onesecupdate | 440 bcf onesecupdate |
441 dcfsnz timeout_counter,F | 441 dcfsnz timeout_counter,F |
442 bra comm_service_exit ; Timeout -> Exit | 442 bra comm_service_exit ; Timeout -> Exit |
443 comm_download_mode2: | 443 comm_download_mode2: |
444 rcall comm_write_get_byte ; Check for a byte | 444 rcall comm_write_get_byte ; Check for a byte |
445 btfsc comm_service_enabled | 445 btfsc comm_service_enabled |
446 btg LEDr ; Blink in Service mode | 446 btg LEDr ; Blink in Service mode |
447 btfss vusb_in ; USB plugged in? | 447 btfss vusb_in ; USB plugged in? |
448 bra comm_service_exit_nousb ; Disconnected -> Exit | 448 bra comm_service_exit_nousb ; Disconnected -> Exit |
449 btfsc switch_right ; Abort with right | 449 btfsc switch_right ; Abort with right |
450 bra comm_service_exit | 450 bra comm_service_exit |
451 btfsc onesecupdate | 451 btfsc onesecupdate |
452 bra comm_download_mode1 | 452 bra comm_download_mode1 |
453 btfsc rs232_recieve_overflow | 453 btfsc rs232_recieve_overflow |
454 bra comm_download_mode2 ; Wait for command byte | 454 bra comm_download_mode2 ; Wait for command byte |
455 | 455 |
456 ; command received! | 456 ; command received! |
457 bcf LEDr | 457 bcf LEDr |
458 movlw 0xFF | 458 movlw 0xFF |
459 cpfseq RCREG1 | 459 cpfseq RCREG1 |
545 bra $+4 | 545 bra $+4 |
546 bra comm_send_firmware ; send firmware to bootloader | 546 bra comm_send_firmware ; send firmware to bootloader |
547 ; movlw "t" | 547 ; movlw "t" |
548 ; cpfseq RCREG1 | 548 ; cpfseq RCREG1 |
549 ; bra $+4 | 549 ; bra $+4 |
550 ; goto testloop ; Start raw-data testloop | 550 ; goto testloop ; Start raw-data testloop |
551 movlw 0xC1 | 551 movlw 0xC1 |
552 cpfseq RCREG1 | 552 cpfseq RCREG1 |
553 bra $+4 | 553 bra $+4 |
554 bra comm_service_ll_bootloader ; Start low-level bootloader | 554 bra comm_service_ll_bootloader ; Start low-level bootloader |
555 bra comm_download_mode0 ; Loop with timeout reset | 555 bra comm_download_mode0 ; Loop with timeout reset |
556 | 556 |
557 ;----------------------------------------------------------------------------- | 557 ;----------------------------------------------------------------------------- |
558 | 558 |
559 comm_send_compact_headers: | 559 comm_send_compact_headers: |
560 movlw "m" ; send echo | 560 movlw "m" ; send echo |
561 movwf TXREG1 | 561 movwf TXREG1 |
562 ; Send 13 bytes/dive (Compact Header) | 562 ; Send 13 bytes/dive (Compact Header) |
563 ; 1st: 200009h-200016h | 563 ; 1st: 200009h-200016h |
564 ; 2nd: 201009h-201016h | 564 ; 2nd: 201009h-201016h |
565 ; 3rd: 202009h-202016h | 565 ; 3rd: 202009h-202016h |
578 addwf ext_flash_address+1 | 578 addwf ext_flash_address+1 |
579 movlw 0x00 | 579 movlw 0x00 |
580 addwfc ext_flash_address+2 | 580 addwfc ext_flash_address+2 |
581 | 581 |
582 movlw 0x30 | 582 movlw 0x30 |
583 cpfseq ext_flash_address+2 ; All 256 dive send? | 583 cpfseq ext_flash_address+2 ; All 256 dive send? |
584 bra comm_send_compact_headers4 ; No, continue | 584 bra comm_send_compact_headers4 ; No, continue |
585 bra comm_download_mode0 ; Done. Loop with timeout reset | 585 bra comm_download_mode0 ; Done. Loop with timeout reset |
586 | 586 |
587 comm_send_compact_headers4: | 587 comm_send_compact_headers4: |
588 movlw .13 | 588 movlw .13 |
589 movwf lo ; Counter | 589 movwf lo ; Counter |
590 rcall comm_rs232_wait_tx ; Wait for UART | 590 rcall comm_rs232_wait_tx ; Wait for UART |
591 call ext_flash_read_block_start ; 1st byte | 591 call ext_flash_read_block_start ; 1st byte |
592 movwf TXREG1 | 592 movwf TXREG1 |
593 bra comm_send_compact_headers3 ; counter 24bit | 593 bra comm_send_compact_headers3 ; counter 24bit |
594 comm_send_compact_headers_loop: | 594 comm_send_compact_headers_loop: |
595 call ext_flash_read_block ; Read one byte | 595 call ext_flash_read_block ; Read one byte |
596 movwf TXREG1 ; Start new transmit | 596 movwf TXREG1 ; Start new transmit |
597 comm_send_compact_headers3: | 597 comm_send_compact_headers3: |
598 rcall comm_rs232_wait_tx ; Wait for UART | 598 rcall comm_rs232_wait_tx ; Wait for UART |
599 decfsz lo,F | 599 decfsz lo,F |
600 bra comm_send_compact_headers_loop | 600 bra comm_send_compact_headers_loop |
601 call ext_flash_read_block_stop | 601 call ext_flash_read_block_stop |
602 | 602 |
603 ; Offset to total dive counter | 603 ; Offset to total dive counter |
607 movwf TXREG1 | 607 movwf TXREG1 |
608 rcall comm_rs232_wait_tx ; Wait for UART | 608 rcall comm_rs232_wait_tx ; Wait for UART |
609 call ext_flash_read_block ; 2nd byte | 609 call ext_flash_read_block ; 2nd byte |
610 movwf TXREG1 | 610 movwf TXREG1 |
611 call ext_flash_read_block_stop | 611 call ext_flash_read_block_stop |
612 rcall comm_rs232_wait_tx ; Wait for UART | 612 rcall comm_rs232_wait_tx ; Wait for UART |
613 | 613 |
614 ; Offset to Logbook-Profile version | 614 ; Offset to Logbook-Profile version |
615 movlw .8 | 615 movlw .8 |
616 movwf ext_flash_address+0 | 616 movwf ext_flash_address+0 |
617 call ext_flash_byte_read ; Get byte | 617 call ext_flash_byte_read ; Get byte |
618 movwf TXREG1 | 618 movwf TXREG1 |
619 rcall comm_rs232_wait_tx ; Wait for UART | 619 rcall comm_rs232_wait_tx ; Wait for UART |
620 bra comm_send_compact_headers2 ; continue | 620 bra comm_send_compact_headers2 ; continue |
621 | 621 |
622 | 622 |
623 ;----------------------------------------------------------------------------- | 623 ;----------------------------------------------------------------------------- |
624 | 624 |
625 comm_send_headers: | 625 comm_send_headers: |
626 movlw "a" ; send echo | 626 movlw "a" ; send echo |
627 movwf TXREG1 | 627 movwf TXREG1 |
628 ; Send 256 bytes/dive (Header) | 628 ; Send 256 bytes/dive (Header) |
629 ; 1st: 200000h-2000FFh | 629 ; 1st: 200000h-2000FFh |
630 ; 2nd: 201000h-2010FFh | 630 ; 2nd: 201000h-2010FFh |
631 ; 3rd: 202000h-2020FFh | 631 ; 3rd: 202000h-2020FFh |
635 movwf ext_flash_address+2 | 635 movwf ext_flash_address+2 |
636 movlw 0xF0 | 636 movlw 0xF0 |
637 movwf ext_flash_address+1 | 637 movwf ext_flash_address+1 |
638 | 638 |
639 comm_send_headers2: | 639 comm_send_headers2: |
640 movlw 0x00 | 640 clrf ext_flash_address+0 |
641 movwf ext_flash_address+0 | |
642 ; Adjust address for next dive | 641 ; Adjust address for next dive |
643 movlw 0x10 | 642 movlw 0x10 |
644 addwf ext_flash_address+1 | 643 addwf ext_flash_address+1 |
645 movlw 0x00 | 644 movlw 0x00 |
646 addwfc ext_flash_address+2 | 645 addwfc ext_flash_address+2 |
647 | 646 |
648 movlw 0x30 | 647 movlw 0x30 |
649 cpfseq ext_flash_address+2 ; All 256 dive send? | 648 cpfseq ext_flash_address+2 ; All 256 dive send? |
650 bra comm_send_headers4 ; No, continue | 649 bra comm_send_headers4 ; No, continue |
651 bra comm_download_mode0 ; Done. Loop with timeout reset | 650 bra comm_download_mode0 ; Done. Loop with timeout reset |
652 | 651 |
653 comm_send_headers4: | 652 comm_send_headers4: |
654 clrf lo ; Counter | 653 clrf lo ; Counter |
655 rcall comm_rs232_wait_tx ; Wait for UART | 654 rcall comm_rs232_wait_tx ; Wait for UART |
656 call ext_flash_read_block_start ; 1st byte | 655 call ext_flash_read_block_start ; 1st byte |
657 movwf TXREG1 | 656 movwf TXREG1 |
658 bra comm_send_headers3 ; counter 24bit | 657 bra comm_send_headers3 ; counter 24bit |
659 comm_send_headers_loop: | 658 comm_send_headers_loop: |
660 call ext_flash_read_block ; Read one byte | 659 call ext_flash_read_block ; Read one byte |
661 movwf TXREG1 ; Start new transmit | 660 movwf TXREG1 ; Start new transmit |
662 comm_send_headers3: | 661 comm_send_headers3: |
663 rcall comm_rs232_wait_tx ; Wait for UART | 662 rcall comm_rs232_wait_tx ; Wait for UART |
664 decfsz lo,F | 663 decfsz lo,F |
665 bra comm_send_headers_loop | 664 bra comm_send_headers_loop |
666 call ext_flash_read_block_stop | 665 call ext_flash_read_block_stop |
667 bra comm_send_headers2 ; continue | 666 bra comm_send_headers2 ; continue |
668 | 667 |
669 ;----------------------------------------------------------------------------- | 668 ;----------------------------------------------------------------------------- |
670 | 669 |
671 comm_option_reset_all: ; Reset all options to factory default. | 670 comm_option_reset_all: ; Reset all options to factory default. |
672 movlw "x" ; send echo | 671 movlw "x" ; send echo |
673 movwf TXREG1 | 672 movwf TXREG1 |
674 call option_reset_all | 673 call option_reset_all |
675 bra comm_download_mode0 ; Done. back to loop with timeout reset | 674 bra comm_download_mode0 ; Done. back to loop with timeout reset |
676 | 675 |
677 ;----------------------------------------------------------------------------- | 676 ;----------------------------------------------------------------------------- |
678 | 677 |
679 comm_write_get_byte: | 678 comm_write_get_byte: |
680 goto rs232_get_byte ; returns... | 679 goto rs232_get_byte ; returns... |
684 | 683 |
685 comm_set_time: | 684 comm_set_time: |
686 movlw "b" ; send echo | 685 movlw "b" ; send echo |
687 movwf TXREG1 | 686 movwf TXREG1 |
688 | 687 |
689 rcall comm_rs232_wait_tx ; wait for UART | 688 rcall comm_rs232_wait_tx ; wait for UART |
690 rcall comm_write_get_byte | 689 rcall comm_write_get_byte |
691 btfsc rs232_recieve_overflow ; Got byte? | 690 btfsc rs232_recieve_overflow ; Got byte? |
692 bra comm_download_mode0 ; No, abort | 691 bra comm_download_mode0 ; No, abort |
693 movff RCREG1, hours | 692 movff RCREG1, hours |
694 movlw d'24' | 693 movlw d'24' |
735 ; | 734 ; |
736 | 735 |
737 comm_set_custom_text: | 736 comm_set_custom_text: |
738 movlw "c" ; send echo | 737 movlw "c" ; send echo |
739 movwf TXREG1 | 738 movwf TXREG1 |
740 rcall comm_rs232_wait_tx ; wait for UART | 739 rcall comm_rs232_wait_tx ; wait for UART |
741 lfsr FSR2,opt_name | 740 lfsr FSR2,opt_name |
742 movlw opt_name_length | 741 movlw opt_name_length |
743 movwf lo ; counter | 742 movwf lo ; counter |
744 comm_set_ctext_loop: | 743 comm_set_ctext_loop: |
745 rcall comm_write_get_byte | 744 rcall comm_write_get_byte |
763 ; | 762 ; |
764 | 763 |
765 comm_identify: | 764 comm_identify: |
766 movlw "i" ; send echo | 765 movlw "i" ; send echo |
767 movwf TXREG1 | 766 movwf TXREG1 |
768 rcall comm_rs232_wait_tx ; wait for UART | 767 rcall comm_rs232_wait_tx ; wait for UART |
769 | 768 |
770 ;---- Read serial from internal EEPROM address 0000 | 769 ;---- Read serial from internal EEPROM address 0000 |
771 clrf EEADRH | 770 clrf EEADRH |
772 clrf EEADR ; Get Serial number LOW | 771 clrf EEADR ; Get Serial number LOW |
773 call read_eeprom ; read byte | 772 call read_eeprom ; read byte |
808 ; | 807 ; |
809 | 808 |
810 comm_hardware_descriptor: | 809 comm_hardware_descriptor: |
811 movlw "j" ; send echo | 810 movlw "j" ; send echo |
812 movwf TXREG1 | 811 movwf TXREG1 |
813 rcall comm_rs232_wait_tx ; wait for UART | 812 rcall comm_rs232_wait_tx ; wait for UART |
814 movff hardware_flag,TXREG1 | 813 movff hardware_flag,TXREG1 |
815 bra comm_download_mode0 ; Done. | 814 bra comm_download_mode0 ; Done. |
816 | 815 |
817 comm_feature_and_hardware: | 816 comm_feature_and_hardware: |
818 movlw 0x60 ; send echo | 817 movlw 0x60 ; send echo |
819 movwf TXREG1 | 818 movwf TXREG1 |
820 rcall comm_rs232_wait_tx ; wait for UART | 819 rcall comm_rs232_wait_tx ; wait for UART |
821 movlw 0x00 ; Hardware high byte | 820 movlw 0x00 ; Hardware high byte |
822 movwf TXREG1 | 821 movwf TXREG1 |
823 rcall comm_rs232_wait_tx ; wait for UART | 822 rcall comm_rs232_wait_tx ; wait for UART |
824 movff hardware_flag,TXREG1 | 823 movff hardware_flag,TXREG1 |
825 rcall comm_rs232_wait_tx ; wait for UART | 824 rcall comm_rs232_wait_tx ; wait for UART |
826 movlw 0x00 ; Feature high Byte | 825 movlw 0x00 ; Feature high Byte |
827 movwf TXREG1 | 826 movwf TXREG1 |
828 rcall comm_rs232_wait_tx ; wait for UART | 827 rcall comm_rs232_wait_tx ; wait for UART |
829 movlw 0x00 ; Feature low Byte | 828 movlw 0x00 ; Feature low Byte |
830 movwf TXREG1 | 829 movwf TXREG1 |
831 rcall comm_rs232_wait_tx ; wait for UART | 830 rcall comm_rs232_wait_tx ; wait for UART |
832 movlw 0x00 ; Model descriptor byte | 831 movlw 0x00 ; Model descriptor byte |
833 movwf TXREG1 | 832 movwf TXREG1 |
834 bra comm_download_mode0 ; Done. | 833 bra comm_download_mode0 ; Done. |
835 | 834 |
836 ;----------------------------------------------------------------------------- | 835 ;----------------------------------------------------------------------------- |
839 movlw "f"; 0x66 ; send echo | 838 movlw "f"; 0x66 ; send echo |
840 movwf TXREG1 | 839 movwf TXREG1 |
841 | 840 |
842 rcall comm_write_get_byte | 841 rcall comm_write_get_byte |
843 btfsc rs232_recieve_overflow ; Got byte? | 842 btfsc rs232_recieve_overflow ; Got byte? |
844 bra comm_download_mode0 ; No, abort! | 843 bra comm_download_mode0 ; No, abort! |
845 movff RCREG1,lo ; Store dive number (0-255) | 844 movff RCREG1,lo ; Store dive number (0-255) |
846 ; First, send the header (again) | 845 ; First, send the header (again) |
847 ; Set ext_flash_address:3 to TOC entry of this dive | 846 ; Set ext_flash_address:3 to TOC entry of this dive |
848 ; 1st: 200000h-200FFFh -> lo=0 | 847 ; 1st: 200000h-200FFFh -> lo=0 |
849 ; 2nd: 201000h-201FFFh -> lo=1 | 848 ; 2nd: 201000h-201FFFh -> lo=1 |
852 clrf ext_flash_address+0 | 851 clrf ext_flash_address+0 |
853 clrf ext_flash_address+1 | 852 clrf ext_flash_address+1 |
854 movlw 0x20 | 853 movlw 0x20 |
855 movwf ext_flash_address+2 | 854 movwf ext_flash_address+2 |
856 movlw .16 | 855 movlw .16 |
857 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) | 856 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) |
858 movf PRODL,W | 857 movf PRODL,W |
859 addwf ext_flash_address+1,F | 858 addwf ext_flash_address+1,F |
860 movf PRODH,W | 859 movf PRODH,W |
861 addwfc ext_flash_address+2,F | 860 addwfc ext_flash_address+2,F |
862 | 861 |
890 ; Start=End -> Not good, abort | 889 ; Start=End -> Not good, abort |
891 bra comm_download_mode0 ; Done. Loop with timeout reset | 890 bra comm_download_mode0 ; Done. Loop with timeout reset |
892 | 891 |
893 comm_send_dive1: | 892 comm_send_dive1: |
894 ; Send header | 893 ; Send header |
895 clrf hi ; Counter | 894 clrf hi ; Counter |
896 rcall comm_rs232_wait_tx ; Wait for UART | 895 rcall comm_rs232_wait_tx ; Wait for UART |
897 call ext_flash_read_block_start ; 1st byte | 896 call ext_flash_read_block_start ; 1st byte |
898 movwf TXREG1 | 897 movwf TXREG1 |
899 bra comm_send_dive_header | 898 bra comm_send_dive_header |
900 comm_send_dive_header2: | 899 comm_send_dive_header2: |
901 call ext_flash_read_block ; Read one byte | 900 call ext_flash_read_block ; Read one byte |
902 movwf TXREG1 ; Start new transmit | 901 movwf TXREG1 ; Start new transmit |
903 comm_send_dive_header: | 902 comm_send_dive_header: |
904 rcall comm_rs232_wait_tx ; Wait for UART | 903 rcall comm_rs232_wait_tx ; Wait for UART |
905 decfsz hi,F | 904 decfsz hi,F |
906 bra comm_send_dive_header2 | 905 bra comm_send_dive_header2 |
907 call ext_flash_read_block_stop | 906 call ext_flash_read_block_stop |
908 | 907 |
909 ; Set address for profile | 908 ; Set address for profile |
910 movff ext_flash_log_pointer+0,ext_flash_address+0 | 909 movff ext_flash_log_pointer+0,ext_flash_address+0 |
911 movff ext_flash_log_pointer+1,ext_flash_address+1 | 910 movff ext_flash_log_pointer+1,ext_flash_address+1 |
912 movff ext_flash_log_pointer+2,ext_flash_address+2 | 911 movff ext_flash_log_pointer+2,ext_flash_address+2 |
913 | 912 |
914 movlw .6 ; Skip 6byte short header in profile - only for internal use | 913 movlw .6 ; Skip 6byte short header in profile - only for internal use |
915 call incf_ext_flash_address0_0x20 ; increases bytes in ext_flash_address:3 with 0x200000 bank switching | 914 call incf_ext_flash_address0_0x20 ; increases bytes in ext_flash_address:3 with 0x200000 bank switching |
916 | 915 |
917 ; Set address for short header/compact header, Byte 0 | 916 ; Set address for short header/compact header, Byte 0 |
918 | 917 |
919 comm_send_dive_profile: | 918 comm_send_dive_profile: |
920 call ext_flash_byte_read_plus_0x20 ; Read one byte into temp1, takes care of banking at 0x200000 | 919 call ext_flash_byte_read_plus_0x20 ; Read one byte into temp1, takes care of banking at 0x200000 |
921 rcall comm_rs232_wait_tx ; Wait for UART | 920 rcall comm_rs232_wait_tx ; Wait for UART |
922 movff temp1,TXREG1 ; Send a byte | 921 movff temp1,TXREG1 ; Send a byte |
923 | 922 |
924 ; 24bit compare with end address | 923 ; 24bit compare with end address |
925 movff convert_value_temp+0,WREG | 924 movff convert_value_temp+0,WREG |
926 cpfseq ext_flash_address+0 | 925 cpfseq ext_flash_address+0 |
927 bra comm_send_dive_profile | 926 bra comm_send_dive_profile |
930 bra comm_send_dive_profile | 929 bra comm_send_dive_profile |
931 movff convert_value_temp+2,WREG | 930 movff convert_value_temp+2,WREG |
932 cpfseq ext_flash_address+2 | 931 cpfseq ext_flash_address+2 |
933 bra comm_send_dive_profile | 932 bra comm_send_dive_profile |
934 | 933 |
935 rcall comm_read_setting_wait ; Wait for UART | 934 rcall comm_read_setting_wait ; Wait for UART |
936 bra comm_download_mode0 ; Done. Loop with timeout reset | 935 bra comm_download_mode0 ; Done. Loop with timeout reset |
937 | 936 |
938 ;----------------------------------------------------------------------------- | 937 ;----------------------------------------------------------------------------- |
939 | 938 |
940 comm_read_setting: | 939 comm_read_setting: |
941 movlw "r" | 940 movlw "r" |
983 dcfsnz WREG | 982 dcfsnz WREG |
984 movff opt_dive_mode, TXREG1 ; RCREG1=0x20 | 983 movff opt_dive_mode, TXREG1 ; RCREG1=0x20 |
985 dcfsnz WREG | 984 dcfsnz WREG |
986 movff char_I_deco_model, TXREG1 ; RCREG1=0x21 | 985 movff char_I_deco_model, TXREG1 ; RCREG1=0x21 |
987 dcfsnz WREG | 986 dcfsnz WREG |
988 movff opt_ppO2_max, TXREG1 ; RCREG1=0x22 | 987 movff char_I_ppO2_max, TXREG1 ; RCREG1=0x22 MODIFIED ## V2.94 |
989 dcfsnz WREG | 988 dcfsnz WREG |
990 movff opt_ppO2_min, TXREG1 ; RCREG1=0x23 | 989 movff char_I_ppO2_min, TXREG1 ; RCREG1=0x23 MODIFIED ## V2.94 |
991 dcfsnz WREG | 990 dcfsnz WREG |
992 movff char_I_extra_time, TXREG1 ; RCREG1=0x24 | 991 movff char_I_extra_time, TXREG1 ; RCREG1=0x24 |
993 dcfsnz WREG | 992 dcfsnz WREG |
994 movff opt_GF_low, TXREG1 ; RCREG1=0x25 | 993 movff opt_GF_low, TXREG1 ; RCREG1=0x25 |
995 dcfsnz WREG | 994 dcfsnz WREG |
1015 dcfsnz WREG | 1014 dcfsnz WREG |
1016 movff opt_salinity, TXREG1 ; RCREG1=0x30 | 1015 movff opt_salinity, TXREG1 ; RCREG1=0x30 |
1017 dcfsnz WREG | 1016 dcfsnz WREG |
1018 movff opt_dive_color_scheme, TXREG1 ; RCREG1=0x31 | 1017 movff opt_dive_color_scheme, TXREG1 ; RCREG1=0x31 |
1019 dcfsnz WREG | 1018 dcfsnz WREG |
1020 movff opt_language, TXREG1 ; RCREG1=0x32 | 1019 movff opt_language, TXREG1 ; RCREG1=0x32 |
1021 dcfsnz WREG | 1020 dcfsnz WREG |
1022 movff opt_dateformat, TXREG1 ; RCREG1=0x33 | 1021 movff opt_dateformat, TXREG1 ; RCREG1=0x33 |
1023 dcfsnz WREG | 1022 dcfsnz WREG |
1024 movff opt_compass_gain, TXREG1 ; RCREG1=0x34 | 1023 movff opt_compass_gain, TXREG1 ; RCREG1=0x34 |
1025 dcfsnz WREG | 1024 dcfsnz WREG |
1027 dcfsnz WREG | 1026 dcfsnz WREG |
1028 movff opt_enable_safetystop, TXREG1 ; RCREG1=0x36 | 1027 movff opt_enable_safetystop, TXREG1 ; RCREG1=0x36 |
1029 dcfsnz WREG | 1028 dcfsnz WREG |
1030 movff opt_calibration_O2_ratio, TXREG1; RCREG1=0x37 | 1029 movff opt_calibration_O2_ratio, TXREG1; RCREG1=0x37 |
1031 dcfsnz WREG | 1030 dcfsnz WREG |
1032 movff opt_sensor_fallback, TXREG1 ; RCREG1=0x38 | 1031 clrf TXREG1 ; RCREG1=0x38 NOT USED ANYMORE (opt_sensor_fallback) ## voting logic |
1033 dcfsnz WREG | 1032 dcfsnz WREG |
1034 movff opt_flip_screen, TXREG1 ; RCREG1=0x39 | 1033 movff opt_flip_screen, TXREG1 ; RCREG1=0x39 |
1035 dcfsnz WREG | 1034 dcfsnz WREG |
1036 movff opt_cR_button_left, TXREG1 ; RCREG1=0x3A | 1035 movff opt_cR_button_left, TXREG1 ; RCREG1=0x3A |
1037 dcfsnz WREG | 1036 dcfsnz WREG |
1057 dcfsnz WREG | 1056 dcfsnz WREG |
1058 movff opt_safety_stop_end, TXREG1 ; RCREG1=0x45 | 1057 movff opt_safety_stop_end, TXREG1 ; RCREG1=0x45 |
1059 dcfsnz WREG | 1058 dcfsnz WREG |
1060 movff opt_safety_stop_reset, TXREG1 ; RCREG1=0x46 | 1059 movff opt_safety_stop_reset, TXREG1 ; RCREG1=0x46 |
1061 dcfsnz WREG | 1060 dcfsnz WREG |
1062 clrf TXREG1 ; RCREG1=0x47, ignore conservatism for standard hwOS | 1061 clrf TXREG1 ; RCREG1=0x47, ignore conservatism for standard hwOS |
1063 dcfsnz WREG | 1062 dcfsnz WREG |
1064 movff opt_diveTimeout, TXREG1 ; RCREG1=0x48 | 1063 movff opt_diveTimeout, TXREG1 ; RCREG1=0x48 |
1065 dcfsnz WREG | 1064 dcfsnz WREG |
1066 movff button_polarity, TXREG1 ; RCREG1=0x49 | 1065 movff button_polarity, TXREG1 ; RCREG1=0x49 |
1067 dcfsnz WREG | 1066 dcfsnz WREG |
1068 movff opt_PSCR_drop, TXREG1 ; RCREG1=0x4A | 1067 movff char_I_PSCR_drop, TXREG1 ; RCREG1=0x4A |
1069 dcfsnz WREG | 1068 dcfsnz WREG |
1070 movff opt_PSCR_lungratio, TXREG1 ; RCREG1=0x4B | 1069 movff char_I_PSCR_lungratio, TXREG1 ; RCREG1=0x4B |
1071 dcfsnz WREG | 1070 dcfsnz WREG |
1072 movff opt_ppO2_max_deco, TXREG1 ; RCREG1=0x4C | 1071 movff char_I_ppO2_max_deco, TXREG1 ; RCREG1=0x4C MODIFIED ## V2.94 |
1073 | 1072 |
1074 | 1073 ; NEW |
1074 dcfsnz WREG | |
1075 movff char_I_ppO2_min_loop, TXREG1 ; RCREG1=0x4D ## CCR/pSCR min ppO2 MODIFIED ## V2.94 | |
1076 dcfsnz WREG | |
1077 movff char_I_tank_size+0, TXREG1 ; RCREG1=0x4E ## bailout gas needs | |
1078 dcfsnz WREG | |
1079 movff char_I_tank_size+1, TXREG1 ; RCREG1=0x4F ## bailout gas needs | |
1080 dcfsnz WREG | |
1081 movff char_I_tank_size+2, TXREG1 ; RCREG1=0x50 ## bailout gas needs | |
1082 dcfsnz WREG | |
1083 movff char_I_tank_size+3, TXREG1 ; RCREG1=0x51 ## bailout gas needs | |
1084 dcfsnz WREG | |
1085 movff char_I_tank_size+4, TXREG1 ; RCREG1=0x52 ## bailout gas needs | |
1086 dcfsnz WREG | |
1087 movff char_I_tank_pres_fill+0, TXREG1 ; RCREG1=0x53 ## bailout gas needs | |
1088 dcfsnz WREG | |
1089 movff char_I_tank_pres_fill+1, TXREG1 ; RCREG1=0x54 ## bailout gas needs | |
1090 dcfsnz WREG | |
1091 movff char_I_tank_pres_fill+2, TXREG1 ; RCREG1=0x55 ## bailout gas needs | |
1092 dcfsnz WREG | |
1093 movff char_I_tank_pres_fill+3, TXREG1 ; RCREG1=0x56 ## bailout gas needs | |
1094 dcfsnz WREG | |
1095 movff char_I_tank_pres_fill+4, TXREG1 ; RCREG1=0x57 ## bailout gas needs | |
1096 dcfsnz WREG | |
1097 movff char_I_cc_max_frac_o2, TXREG1 ; RCREG1=0x58 ## CCR max ppO2 limiter | |
1098 dcfsnz WREG | |
1099 movff opt_sim_setpoint_number, TXREG1 ; RCREG1=0x59 ## deco calculator enhancement | |
1100 dcfsnz WREG | |
1101 movff opt_calc_asc_gasvolume, TXREG1 ; RCREG1=0x5A ## bailout gas needs | |
1102 dcfsnz WREG | |
1103 movff opt_sim_use_aGF, TXREG1 ; RCREG1=0x5B ## deco calculator enhancement | |
1104 dcfsnz WREG | |
1105 movff char_I_altitude_wait, TXREG1 ; RCREG1=0x5C ## no fly altitude | |
1106 dcfsnz WREG | |
1107 movff opt_enable_IBCD, TXREG1 ; RCREG1=0x5D ## IBCD | |
1108 | |
1075 | 1109 |
1076 comm_read_abort: | 1110 comm_read_abort: |
1077 comm_read_done: | 1111 comm_read_done: |
1078 bra comm_download_mode0 ; Done. Loop with timeout reset | 1112 bra comm_download_mode0 ; Done. Loop with timeout reset |
1079 | 1113 |
1080 comm_read_setting_wait: | 1114 comm_read_setting_wait: |
1081 bra comm_rs232_wait_tx ; Wait for UART (and return!) | 1115 bra comm_rs232_wait_tx ; Wait for UART (and return!) |
1082 | 1116 |
1083 comm_read_gas1: | 1117 comm_read_gas1: |
1084 movff opt_gas_O2_ratio+0, TXREG1 | 1118 movff opt_gas_O2_ratio+0, TXREG1 |
1085 rcall comm_read_setting_wait ; Wait for UART | 1119 rcall comm_read_setting_wait ; Wait for UART |
1086 movff opt_gas_He_ratio+0, TXREG1 | 1120 movff opt_gas_He_ratio+0, TXREG1 |
1295 dcfsnz WREG | 1329 dcfsnz WREG |
1296 movff RCREG1, opt_dive_mode ; RCREG1=0x20 | 1330 movff RCREG1, opt_dive_mode ; RCREG1=0x20 |
1297 dcfsnz WREG | 1331 dcfsnz WREG |
1298 movff RCREG1, char_I_deco_model ; RCREG1=0x21 | 1332 movff RCREG1, char_I_deco_model ; RCREG1=0x21 |
1299 dcfsnz WREG | 1333 dcfsnz WREG |
1300 movff RCREG1, opt_ppO2_max ; RCREG1=0x22 | 1334 movff RCREG1, char_I_ppO2_max ; RCREG1=0x22 MODIFIED ## V2.94 |
1301 dcfsnz WREG | 1335 dcfsnz WREG |
1302 movff RCREG1, opt_ppO2_min ; RCREG1=0x23 | 1336 movff RCREG1, char_I_ppO2_min ; RCREG1=0x23 MODIFIED ## V2.94 |
1303 dcfsnz WREG | 1337 dcfsnz WREG |
1304 movff RCREG1, char_I_extra_time ; RCREG1=0x24 | 1338 movff RCREG1, char_I_extra_time ; RCREG1=0x24 |
1305 dcfsnz WREG | 1339 dcfsnz WREG |
1306 movff RCREG1, opt_GF_low ; RCREG1=0x25 | 1340 movff RCREG1, opt_GF_low ; RCREG1=0x25 |
1307 dcfsnz WREG | 1341 dcfsnz WREG |
1327 dcfsnz WREG | 1361 dcfsnz WREG |
1328 movff RCREG1, opt_salinity ; RCREG1=0x30 | 1362 movff RCREG1, opt_salinity ; RCREG1=0x30 |
1329 dcfsnz WREG | 1363 dcfsnz WREG |
1330 movff RCREG1, opt_dive_color_scheme ; RCREG1=0x31 | 1364 movff RCREG1, opt_dive_color_scheme ; RCREG1=0x31 |
1331 dcfsnz WREG | 1365 dcfsnz WREG |
1332 movff RCREG1, opt_language ; RCREG1=0x32 | 1366 movff RCREG1, opt_language ; RCREG1=0x32 |
1333 dcfsnz WREG | 1367 dcfsnz WREG |
1334 movff RCREG1, opt_dateformat ; RCREG1=0x33 | 1368 movff RCREG1, opt_dateformat ; RCREG1=0x33 |
1335 dcfsnz WREG | 1369 dcfsnz WREG |
1336 movff RCREG1, opt_compass_gain ; RCREG1=0x34 | 1370 movff RCREG1, opt_compass_gain ; RCREG1=0x34 |
1337 dcfsnz WREG | 1371 dcfsnz WREG |
1339 dcfsnz WREG | 1373 dcfsnz WREG |
1340 movff RCREG1, opt_enable_safetystop ; RCREG1=0x36 | 1374 movff RCREG1, opt_enable_safetystop ; RCREG1=0x36 |
1341 dcfsnz WREG | 1375 dcfsnz WREG |
1342 movff RCREG1, opt_calibration_O2_ratio; RCREG1=0x37 | 1376 movff RCREG1, opt_calibration_O2_ratio; RCREG1=0x37 |
1343 dcfsnz WREG | 1377 dcfsnz WREG |
1344 movff RCREG1, opt_sensor_fallback ; RCREG1=0x38 | 1378 nop ; RCREG1=0x38 NOT USED ANYMORE (opt_sensor_fallback) ## voting logic |
1345 dcfsnz WREG | 1379 dcfsnz WREG |
1346 movff RCREG1, opt_flip_screen ; RCREG1=0x39 | 1380 movff RCREG1, opt_flip_screen ; RCREG1=0x39 |
1347 dcfsnz WREG | 1381 dcfsnz WREG |
1348 movff RCREG1, opt_cR_button_left ; RCREG1=0x3A | 1382 movff RCREG1, opt_cR_button_left ; RCREG1=0x3A |
1349 dcfsnz WREG | 1383 dcfsnz WREG |
1369 dcfsnz WREG | 1403 dcfsnz WREG |
1370 movff RCREG1, opt_safety_stop_end ; RCREG1=0x45 | 1404 movff RCREG1, opt_safety_stop_end ; RCREG1=0x45 |
1371 dcfsnz WREG | 1405 dcfsnz WREG |
1372 movff RCREG1, opt_safety_stop_reset ; RCREG1=0x46 | 1406 movff RCREG1, opt_safety_stop_reset ; RCREG1=0x46 |
1373 dcfsnz WREG | 1407 dcfsnz WREG |
1374 nop ; RCREG1=0x47, ignore conservatism for standard hwOS | 1408 nop ; RCREG1=0x47, ignore conservatism for standard hwOS |
1375 dcfsnz WREG | 1409 dcfsnz WREG |
1376 movff RCREG1, opt_diveTimeout ; RCREG1=0x48 | 1410 movff RCREG1, opt_diveTimeout ; RCREG1=0x48 |
1377 dcfsnz WREG | 1411 dcfsnz WREG |
1378 bra comm_write_button_polarity ; RCREG1=0x49 | 1412 bra comm_write_button_polarity ; RCREG1=0x49 |
1379 dcfsnz WREG | 1413 dcfsnz WREG |
1380 movff RCREG1, opt_PSCR_drop ; RCREG1=0x4A | 1414 movff RCREG1, char_I_PSCR_drop ; RCREG1=0x4A |
1381 dcfsnz WREG | 1415 dcfsnz WREG |
1382 movff RCREG1, opt_PSCR_lungratio ; RCREG1=0x4B | 1416 movff RCREG1, char_I_PSCR_lungratio ; RCREG1=0x4B |
1383 dcfsnz WREG | 1417 dcfsnz WREG |
1384 movff RCREG1, opt_ppO2_max_deco ; RCREG1=0x4C | 1418 movff RCREG1, char_I_ppO2_max_deco ; RCREG1=0x4C MODIFIED V2.94 |
1385 | 1419 |
1386 | 1420 ; NEW |
1421 dcfsnz WREG | |
1422 movff RCREG1, char_I_ppO2_min_loop ; RCREG1=0x4D ## CCR/pSCR min ppO2 limiter MODIFIED ## V2.94 | |
1423 dcfsnz WREG | |
1424 movff RCREG1, char_I_tank_size+0 ; RCREG1=0x4E ## bailout gas needs | |
1425 dcfsnz WREG | |
1426 movff RCREG1, char_I_tank_size+1 ; RCREG1=0x4F ## bailout gas needs | |
1427 dcfsnz WREG | |
1428 movff RCREG1, char_I_tank_size+2 ; RCREG1=0x50 ## bailout gas needs | |
1429 dcfsnz WREG | |
1430 movff RCREG1, char_I_tank_size+3 ; RCREG1=0x51 ## bailout gas needs | |
1431 dcfsnz WREG | |
1432 movff RCREG1, char_I_tank_size+4 ; RCREG1=0x52 ## bailout gas needs | |
1433 dcfsnz WREG | |
1434 movff RCREG1, char_I_tank_pres_fill+0 ; RCREG1=0x53 ## bailout gas needs | |
1435 dcfsnz WREG | |
1436 movff RCREG1, char_I_tank_pres_fill+1 ; RCREG1=0x54 ## bailout gas needs | |
1437 dcfsnz WREG | |
1438 movff RCREG1, char_I_tank_pres_fill+2 ; RCREG1=0x55 ## bailout gas needs | |
1439 dcfsnz WREG | |
1440 movff RCREG1, char_I_tank_pres_fill+3 ; RCREG1=0x56 ## bailout gas needs | |
1441 dcfsnz WREG | |
1442 movff RCREG1, char_I_tank_pres_fill+4 ; RCREG1=0x57 ## bailout gas needs | |
1443 dcfsnz WREG | |
1444 movff RCREG1, char_I_cc_max_frac_o2 ; RCREG1=0x58 ## CCR max ppO2 limiter | |
1445 dcfsnz WREG | |
1446 movff RCREG1, opt_sim_setpoint_number ; RCREG1=0x59 ## deco calculator enhancement | |
1447 dcfsnz WREG | |
1448 movff RCREG1, opt_calc_asc_gasvolume ; RCREG1=0x5A ## bailout gas needs | |
1449 dcfsnz WREG | |
1450 movff RCREG1, opt_sim_use_aGF ; RCREG1=0x5B ## deco calculator enhancement | |
1451 dcfsnz WREG | |
1452 movff RCREG1, char_I_altitude_wait ; RCREG1=0x5C ## no fly altitude | |
1453 dcfsnz WREG | |
1454 movff RCREG1, opt_enable_IBCD ; RCREG1=0x5D ## TBCD | |
1455 | |
1456 | |
1387 comm_write_abort: | 1457 comm_write_abort: |
1388 ; Check Options, gases and diluents | 1458 ; Check Options, gases and diluents |
1389 call option_check_all ; Check all options (and reset if not within their min/max boundaries) | 1459 call option_check_all ; Check all options (and reset if not within their min/max boundaries) |
1390 bsf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | 1460 bsf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
1391 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | 1461 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth |
1392 bcf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") | 1462 bcf ccr_diluent_setup ; =1: Setting up Diluents ("Gas6-10") |
1393 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth | 1463 call gaslist_cleanup_list ; Takes care that only one gas can be first and first has 0m change depth |
1394 call get_first_gas_to_WREG ; Makes sure at least one Gas is "First" | 1464 call get_first_gas_to_WREG ; Makes sure at least one Gas is "First" |
1395 call get_first_dil_to_WREG ; Makes sure at least one Diluent is "First" | 1465 call get_first_dil_to_WREG ; Makes sure at least one Diluent is "First" |
1396 bra comm_download_mode0 ; Done. Loop with timeout reset | 1466 goto comm_download_mode0 ; Done. Loop with timeout reset |
1397 | 1467 |
1398 comm_write_dil1: | 1468 comm_write_dil1: |
1399 movff RCREG1,opt_dil_O2_ratio+0 | 1469 movff RCREG1,opt_dil_O2_ratio+0 |
1400 rcall comm_write_get_byte | 1470 rcall comm_write_get_byte |
1401 movff RCREG1,opt_dil_He_ratio+0 | 1471 movff RCREG1,opt_dil_He_ratio+0 |
1402 rcall comm_write_get_byte | 1472 rcall comm_write_get_byte |
1403 movff RCREG1,opt_dil_type+0 | 1473 movff RCREG1,opt_dil_type+0 |
1404 rcall comm_write_get_byte | 1474 rcall comm_write_get_byte |
1405 movff RCREG1,char_I_dil_change+0 | 1475 movff RCREG1,char_I_dil_change+0 |
1406 bra comm_write_abort ; Done. Loop with timeout reset | 1476 bra comm_write_abort ; Done. Loop with timeout reset |
1407 comm_write_dil2: | 1477 comm_write_dil2: |
1408 movff RCREG1,opt_dil_O2_ratio+1 | 1478 movff RCREG1,opt_dil_O2_ratio+1 |
1409 rcall comm_write_get_byte | 1479 rcall comm_write_get_byte |
1410 movff RCREG1,opt_dil_He_ratio+1 | 1480 movff RCREG1,opt_dil_He_ratio+1 |
1411 rcall comm_write_get_byte | 1481 rcall comm_write_get_byte |
1412 movff RCREG1,opt_dil_type+1 | 1482 movff RCREG1,opt_dil_type+1 |
1413 rcall comm_write_get_byte | 1483 rcall comm_write_get_byte |
1414 movff RCREG1,char_I_dil_change+1 | 1484 movff RCREG1,char_I_dil_change+1 |
1415 bra comm_write_abort ; Done. Loop with timeout reset | 1485 bra comm_write_abort ; Done. Loop with timeout reset |
1416 comm_write_dil3: | 1486 comm_write_dil3: |
1417 movff RCREG1,opt_dil_O2_ratio+2 | 1487 movff RCREG1,opt_dil_O2_ratio+2 |
1418 rcall comm_write_get_byte | 1488 rcall comm_write_get_byte |
1419 movff RCREG1,opt_dil_He_ratio+2 | 1489 movff RCREG1,opt_dil_He_ratio+2 |
1420 rcall comm_write_get_byte | 1490 rcall comm_write_get_byte |
1421 movff RCREG1,opt_dil_type+2 | 1491 movff RCREG1,opt_dil_type+2 |
1422 rcall comm_write_get_byte | 1492 rcall comm_write_get_byte |
1423 movff RCREG1,char_I_dil_change+2 | 1493 movff RCREG1,char_I_dil_change+2 |
1424 bra comm_write_abort ; Done. Loop with timeout reset | 1494 bra comm_write_abort ; Done. Loop with timeout reset |
1425 comm_write_dil4: | 1495 comm_write_dil4: |
1426 movff RCREG1,opt_dil_O2_ratio+3 | 1496 movff RCREG1,opt_dil_O2_ratio+3 |
1427 rcall comm_write_get_byte | 1497 rcall comm_write_get_byte |
1428 movff RCREG1,opt_dil_He_ratio+3 | 1498 movff RCREG1,opt_dil_He_ratio+3 |
1429 rcall comm_write_get_byte | 1499 rcall comm_write_get_byte |
1430 movff RCREG1,opt_dil_type+3 | 1500 movff RCREG1,opt_dil_type+3 |
1431 rcall comm_write_get_byte | 1501 rcall comm_write_get_byte |
1432 movff RCREG1,char_I_dil_change+3 | 1502 movff RCREG1,char_I_dil_change+3 |
1433 bra comm_write_abort ; Done. Loop with timeout reset | 1503 bra comm_write_abort ; Done. Loop with timeout reset |
1434 comm_write_dil5: | 1504 comm_write_dil5: |
1435 movff RCREG1,opt_dil_O2_ratio+4 | 1505 movff RCREG1,opt_dil_O2_ratio+4 |
1436 rcall comm_write_get_byte | 1506 rcall comm_write_get_byte |
1437 movff RCREG1,opt_dil_He_ratio+4 | 1507 movff RCREG1,opt_dil_He_ratio+4 |
1438 rcall comm_write_get_byte | 1508 rcall comm_write_get_byte |
1439 movff RCREG1,opt_dil_type+4 | 1509 movff RCREG1,opt_dil_type+4 |
1440 rcall comm_write_get_byte | 1510 rcall comm_write_get_byte |
1441 movff RCREG1,char_I_dil_change+4 | 1511 movff RCREG1,char_I_dil_change+4 |
1442 bra comm_write_abort ; Done. Loop with timeout reset | 1512 bra comm_write_abort ; Done. Loop with timeout reset |
1443 | 1513 |
1444 comm_write_sp1: | 1514 comm_write_sp1: |
1445 movff RCREG1,char_I_setpoint_cbar+0 | 1515 movff RCREG1,char_I_setpoint_cbar+0 |
1446 rcall comm_write_get_byte | 1516 rcall comm_write_get_byte |
1447 movff RCREG1,char_I_setpoint_change+0 | 1517 movff RCREG1,char_I_setpoint_change+0 |
1448 bra comm_write_abort ; Done. Loop with timeout reset | 1518 bra comm_write_abort ; Done. Loop with timeout reset |
1449 comm_write_sp2: | 1519 comm_write_sp2: |
1450 movff RCREG1,char_I_setpoint_cbar+1 | 1520 movff RCREG1,char_I_setpoint_cbar+1 |
1451 rcall comm_write_get_byte | 1521 rcall comm_write_get_byte |
1452 movff RCREG1,char_I_setpoint_change+1 | 1522 movff RCREG1,char_I_setpoint_change+1 |
1453 bra comm_write_abort ; Done. Loop with timeout reset | 1523 bra comm_write_abort ; Done. Loop with timeout reset |
1454 comm_write_sp3: | 1524 comm_write_sp3: |
1455 movff RCREG1,char_I_setpoint_cbar+2 | 1525 movff RCREG1,char_I_setpoint_cbar+2 |
1456 rcall comm_write_get_byte | 1526 rcall comm_write_get_byte |
1457 movff RCREG1,char_I_setpoint_change+2 | 1527 movff RCREG1,char_I_setpoint_change+2 |
1458 bra comm_write_abort ; Done. Loop with timeout reset | 1528 bra comm_write_abort ; Done. Loop with timeout reset |
1459 comm_write_sp4: | 1529 comm_write_sp4: |
1460 movff RCREG1,char_I_setpoint_cbar+3 | 1530 movff RCREG1,char_I_setpoint_cbar+3 |
1461 rcall comm_write_get_byte | 1531 rcall comm_write_get_byte |
1462 movff RCREG1,char_I_setpoint_change+3 | 1532 movff RCREG1,char_I_setpoint_change+3 |
1463 bra comm_write_abort ; Done. Loop with timeout reset | 1533 bra comm_write_abort ; Done. Loop with timeout reset |
1464 comm_write_sp5: | 1534 comm_write_sp5: |
1465 movff RCREG1,char_I_setpoint_cbar+4 | 1535 movff RCREG1,char_I_setpoint_cbar+4 |
1466 rcall comm_write_get_byte | 1536 rcall comm_write_get_byte |
1467 movff RCREG1,char_I_setpoint_change+4 | 1537 movff RCREG1,char_I_setpoint_change+4 |
1468 bra comm_write_abort ; Done. Loop with timeout reset | 1538 bra comm_write_abort ; Done. Loop with timeout reset |
1469 | 1539 |
1470 ;----------------------------------------------------------------------------- | 1540 ;----------------------------------------------------------------------------- |
1471 | 1541 |
1472 comm_send_string: | 1542 comm_send_string: |
1473 movlw "n" ; send echo | 1543 movlw "n" ; send echo |
1474 movwf TXREG1 | 1544 movwf TXREG1 |
1475 rcall comm_rs232_wait_tx ; Wait for UART | 1545 rcall comm_rs232_wait_tx ; Wait for UART |
1476 WIN_SMALL comm_string_column, comm_string_row | 1546 WIN_SMALL comm_string_column, comm_string_row |
1477 movlw .16 | 1547 movlw .16 |
1478 movwf lo ; counter | 1548 movwf lo ; counter |
1479 comm_send_string_loop: | 1549 comm_send_string_loop: |
1480 rcall comm_write_get_byte | 1550 rcall comm_write_get_byte |
1514 movlw .31 | 1584 movlw .31 |
1515 dcfsnz lo,F | 1585 dcfsnz lo,F |
1516 movlw .30 | 1586 movlw .30 |
1517 dcfsnz lo,F | 1587 dcfsnz lo,F |
1518 movlw .31 | 1588 movlw .31 |
1519 cpfsgt day ; day ok? | 1589 cpfsgt day ; day ok? |
1520 return ; OK | 1590 return ; OK |
1521 movlw .1 ; not OK, set to 1st | 1591 movlw .1 ; not OK, set to 1st |
1522 movwf day | 1592 movwf day |
1523 return | 1593 return |
1524 | 1594 |
1525 comm_write_button_polarity: | 1595 comm_write_button_polarity: |
1526 ; Store RCREG1 into EEPROM .897 | 1596 ; Store RCREG1 into EEPROM .897 |
1529 movlw HIGH .897 | 1599 movlw HIGH .897 |
1530 movwf EEADRH | 1600 movwf EEADRH |
1531 movff RCREG1,EEDATA | 1601 movff RCREG1,EEDATA |
1532 movff EEDATA,button_polarity ; 0xFF (Both normal), 0x00 (Both inverted), 0x01 (Left inverted only), 0x02 (Right inverted only) | 1602 movff EEDATA,button_polarity ; 0xFF (Both normal), 0x00 (Both inverted), 0x01 (Left inverted only), 0x02 (Right inverted only) |
1533 call write_eeprom ; EEDATA into EEPROM@EEADR | 1603 call write_eeprom ; EEDATA into EEPROM@EEADR |
1534 clrf EEADRH ; Reset EEADRH | 1604 clrf EEADRH ; Reset EEADRH |
1535 goto comm_download_mode0 ; Done. Loop with timeout reset | 1605 goto comm_download_mode0 ; Done. Loop with timeout reset |
1536 | 1606 |
1537 ;---------------------------------------------------------------------------- | 1607 ;---------------------------------------------------------------------------- |
1538 END | 1608 END |