Mercurial > public > hwos_code
annotate src/comm.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
author | heinrichsweikamp |
---|---|
date | Thu, 22 Nov 2018 19:47:26 +0100 |
parents | c31e0292bc92 |
children | c40025d8e750 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
604 | 3 ; File comm.asm REFACTORED VERSION V2.99d |
0 | 4 ; |
5 ; RS232 via USB | |
6 ; | |
7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-22 : [mH] Creation | |
604 | 11 ; 2012-02-11 : [jDG] Added "c" set custom text, and "i" identify |
0 | 12 |
275 | 13 #include "hwos.inc" |
0 | 14 #include "eeprom_rs232.inc" |
15 #include "tft.inc" | |
16 #include "wait.inc" | |
17 #include "strings.inc" | |
18 #include "convert.inc" | |
19 #include "external_flash.inc" | |
20 #include "tft_outputs.inc" | |
21 #include "surfmode.inc" | |
22 #include "rtc.inc" | |
23 #include "adc_lightsensor.inc" | |
299
6c4800af27ac
Make char_I_bottom_usage and char_I_deco_usage configurable from PC
heinrichsweikamp
parents:
275
diff
changeset
|
24 #include "shared_definitions.h" |
604 | 25 #include "math.inc" |
0 | 26 |
582 | 27 extern restart |
28 extern option_reset_all | |
29 extern option_check_all | |
30 extern gaslist_cleanup_list | |
31 extern get_first_gas_to_WREG | |
32 extern get_first_dil_to_WREG | |
604 | 33 extern option_save_all |
582 | 34 extern vault_decodata_into_eeprom |
604 | 35 extern menu_processor_bottom_line_comm |
36 | |
37 IFDEF _rx_functions | |
38 extern I2C_update_OSTC_rx | |
39 ENDIF | |
0 | 40 |
41 | |
604 | 42 #DEFINE timeout_comm_pre_mode .240 ; pre-loop |
43 #DEFINE timeout_comm_mode .120 ; download mode | |
44 #DEFINE timeout_service_mode .120 ; service mode | |
582 | 45 |
46 #DEFINE comm_title_row .0 | |
47 #DEFINE comm_title_column_usb .50 | |
48 #DEFINE comm_title_column_ble .25 | |
0 | 49 |
582 | 50 #DEFINE comm_string_row .30 |
51 #DEFINE comm_string_column .40 | |
52 | |
53 #DEFINE comm_status1_row .70 | |
54 #DEFINE comm_status1_column .10 | |
55 #DEFINE comm_status2_row .100 | |
56 #DEFINE comm_status2_column comm_status1_column | |
57 #DEFINE comm_status3_row .130 | |
58 #DEFINE comm_status3_column comm_status1_column | |
604 | 59 #DEFINE comm_status4_row .160 |
60 #DEFINE comm_status4_column comm_status1_column | |
61 | |
582 | 62 |
63 #DEFINE comm_warning_row .160 | |
64 #DEFINE comm_warning_column .65 | |
0 | 65 |
604 | 66 comm CODE |
67 | |
68 ;============================================================================= | |
0 | 69 |
70 ; test for comm | |
218 | 71 global comm_mode, comm_mode0 |
0 | 72 comm_mode: |
582 | 73 WAITMS d'1' |
74 btfss vusb_in ; USB plugged in? | |
604 | 75 return ; NO - it was only a glitch |
582 | 76 WAITMS d'1' |
77 btfss vusb_in ; USB plugged in? | |
604 | 78 return ; NO - it was only a glitch |
218 | 79 comm_mode0: |
582 | 80 call TFT_ClearScreen |
81 WIN_COLOR color_greenish | |
604 | 82 btfsc ble_available ; BLE available |
582 | 83 bra comm_mode0_ble |
84 WIN_SMALL comm_title_column_usb, comm_title_row | |
604 | 85 STRCPY_TEXT_PRINT tUsbTitle ; USB mode |
582 | 86 bra comm_mode0_common |
269
1207cf9a9408
adjust menu for different hardware versions
heinrichsweikamp
parents:
255
diff
changeset
|
87 comm_mode0_ble: |
582 | 88 WIN_SMALL comm_title_column_ble, comm_title_row |
604 | 89 STRCPY_TEXT_PRINT tBleTitle ; BLE mode |
269
1207cf9a9408
adjust menu for different hardware versions
heinrichsweikamp
parents:
255
diff
changeset
|
90 comm_mode0_common: |
582 | 91 call TFT_standard_color |
92 WIN_TOP .10 | |
93 WIN_LEFT .1 | |
604 | 94 TFT_WRITE_PROM_IMAGE_BY_ADDR usb_ble_logo_block |
582 | 95 WIN_SMALL comm_status1_column,comm_status1_row |
604 | 96 STRCPY_TEXT_PRINT tUsbStarting ; starting... |
97 call menu_processor_bottom_line_comm ; serial and fw version | |
98 call option_save_all ; save all settings into EEPROM (comm mode may be entered after settings have been changed without leaving the menu in between) | |
99 | |
100 IFDEF _screendump | |
101 bcf enable_screen_dumps ; =1: ignore vin_usb, wait for "l" command (screen dump) | |
102 ENDIF | |
103 | |
0 | 104 bcf switch_right |
582 | 105 bcf comm_service_enabled |
106 bsf menubit | |
604 | 107 bcf battery_removed_in_usb ; =1: the battery has been removed in USB (properly not used for anything useful) |
582 | 108 movlw timeout_comm_pre_mode |
109 movwf comm_timeout | |
110 WIN_SMALL comm_status1_column+.80,comm_status1_row | |
604 | 111 STRCPY_TEXT_PRINT tUsbStartDone ; done... |
112 call enable_rs232 ; also sets to speed_normal ... | |
0 | 113 comm_mode1: |
114 bcf onesecupdate | |
115 bcf LEDr | |
582 | 116 dcfsnz comm_timeout,F |
604 | 117 bra comm_service_exit ; timeout -> exit |
0 | 118 comm_mode2: |
604 | 119 rcall comm_get_byte |
0 | 120 |
121 movlw 0xAA ; start byte=0xAA? | |
122 cpfseq RCREG1 | |
123 bra comm_mode2a | |
604 | 124 bra comm_mode2b ; start byte for service mode found |
0 | 125 comm_mode2a: |
126 movlw 0xBB ; start byte=0xBB? | |
127 cpfseq RCREG1 | |
393 | 128 bra comm_mode2c |
604 | 129 bra comm_download_mode ; start byte for download mode found |
0 | 130 |
393 | 131 comm_mode2c: |
582 | 132 btfss vusb_in ; USB plugged in? |
604 | 133 bra comm_service_exit_nousb_delay ; disconnected -> exit |
393 | 134 comm_mode4a: |
604 | 135 btfsc switch_right ; abort with right |
393 | 136 bra comm_service_exit |
137 | |
138 btfsc onesecupdate | |
139 bra comm_mode1 | |
140 | |
604 | 141 bra comm_mode2 ; cycle |
393 | 142 |
0 | 143 comm_mode2b: |
144 ; Startbyte found | |
604 | 145 rcall comm_write_byte ; wait for UART |
0 | 146 movlw 0x4B |
604 | 147 movwf TXREG1 ; send answer |
0 | 148 ; Now, check comm command |
149 | |
604 | 150 rcall comm_get_byte ; first byte |
151 rcall comm_write_byte ; wait for UART | |
582 | 152 movff RCREG1,TXREG1 ; Echo |
0 | 153 movlw UPPER comm_service_key |
154 cpfseq RCREG1 | |
604 | 155 bra comm_mode1 ; wrong -> restart |
156 rcall comm_get_byte ; second byte | |
157 rcall comm_write_byte ; wait for UART | |
158 movff RCREG1,TXREG1 ; echo | |
0 | 159 movlw HIGH (comm_service_key & 0xFFFF) |
160 cpfseq RCREG1 | |
604 | 161 bra comm_mode1 ; wrong -> restart |
162 rcall comm_get_byte ; third byte | |
163 rcall comm_write_byte ; wait for UART | |
164 movff RCREG1,TXREG1 ; echo | |
0 | 165 movlw LOW comm_service_key |
166 cpfseq RCREG1 | |
604 | 167 bra comm_mode1 ; wrong -> restart |
0 | 168 |
169 ; Enable comm service mode | |
582 | 170 WIN_SMALL comm_status2_column, comm_status2_row |
604 | 171 STRCPY_TEXT_PRINT tUsbServiceMode ; service mode enabled |
172 bsf comm_service_enabled ; set flag... | |
582 | 173 bra comm_download_mode0 ; ... but use common routine |
69 | 174 |
175 comm_service_exit_nousb_delay: | |
582 | 176 WAITMS d'200' |
177 btfsc vusb_in ; USB plugged in? | |
604 | 178 bra comm_mode4a ; YES - (still) connected, return |
179 comm_service_exit_nousb: ; NO - disconnected -> exit | |
582 | 180 WIN_SMALL comm_status3_column, comm_status3_row |
604 | 181 STRCPY_TEXT_PRINT tUsbClosed ; port closed |
582 | 182 bra comm_service_exit_common |
0 | 183 |
184 comm_service_exit: | |
185 WIN_SMALL comm_status3_column, comm_status3_row | |
604 | 186 STRCPY_TEXT_PRINT tUsbExit ; exited |
0 | 187 comm_service_exit_common: |
604 | 188 rcall comm_write_byte ; wait for UART |
189 movlw 0xFF ; reply FF | |
190 movwf TXREG1 ; send answer | |
0 | 191 |
604 | 192 call wait_1s ; wait 1 second |
193 call wait_1s ; wait 1 second | |
0 | 194 |
195 call disable_rs232 | |
582 | 196 goto restart |
0 | 197 |
198 ;----------------------------------------------------------------------------- | |
199 | |
200 comm_service_ll_bootloader: | |
582 | 201 bsf LEDr |
202 WIN_SMALL comm_status3_column, comm_status3_row | |
604 | 203 STRCPY_TEXT_PRINT tUsbLlBld ; low level bootloader started |
582 | 204 WIN_TOP comm_warning_row |
205 WIN_LEFT comm_warning_column | |
604 | 206 TFT_WRITE_PROM_IMAGE_BY_LABEL dive_warning2_block ; show warning icon |
582 | 207 goto 0x1FF0C |
0 | 208 |
209 ;----------------------------------------------------------------------------- | |
273
12ee30cbced9
CHANGE: Automatically abort connection fail after 2mins (Bluetooth only)
heinrichsweikamp
parents:
269
diff
changeset
|
210 ; send firmware to bootloader |
0 | 211 ; |
212 comm_send_firmware: | |
604 | 213 movlw 0x50 ; send echo |
582 | 214 movwf TXREG1 |
604 | 215 rcall comm_write_byte ; wait for UART |
0 | 216 |
582 | 217 ; Read 5 bytes into buffer. |
0 | 218 lfsr FSR2,buffer |
604 | 219 movlw .5 ; counter |
0 | 220 movwf lo |
604 | 221 movlw 0x55 ; 5'ft byte checksum |
582 | 222 movwf hi |
0 | 223 |
224 comm_send_firmware_loop: | |
604 | 225 rcall comm_get_byte |
226 btfsc rs232_receive_overflow ; got byte? | |
227 bra comm_send_firmware_abort ; NO - abort | |
0 | 228 movf RCREG1,W |
604 | 229 movwf POSTINC2 ; store checksum byte |
230 xorwf hi,F ; also xor into checksum | |
231 rlncf hi,F ; and rotate it | |
0 | 232 decfsz lo,F |
233 bra comm_send_firmware_loop | |
582 | 234 |
604 | 235 ; check that 5ft byte checksum's checksum |
582 | 236 movf hi,W |
237 bnz comm_send_firmware_failed | |
0 | 238 |
604 | 239 movlw 0x4C ; send OK |
582 | 240 movwf TXREG1 |
604 | 241 rcall comm_write_byte ; wait for UART |
0 | 242 |
243 ; Passed: goto second stage verification. | |
244 ; NOTE: Bootloader is Bank0. With buffer at address 0x200. | |
604 | 245 call vault_decodata_into_eeprom ; store last deco data (and time/date) into EEPROM |
246 goto 0x1FDF0 ; and pray... | |
0 | 247 |
248 comm_send_firmware_failed: | |
582 | 249 WIN_SMALL comm_string_column, comm_string_row |
250 call TFT_warnings_color | |
251 STRCPY_PRINT "Checksum failed" | |
0 | 252 |
253 comm_send_firmware_abort: | |
254 | |
604 | 255 movlw 0xFF ; send ABORTED byte |
0 | 256 movwf TXREG1 |
604 | 257 bra comm_download_mode0 ; done |
0 | 258 |
259 ;----------------------------------------------------------------------------- | |
260 ; Reset to Dive 1 in logbook | |
261 | |
262 comm_reset_logbook_pointers: | |
582 | 263 call eeprom_reset_logbook_pointers ; clear logbook pointers in EEPROM... |
264 call ext_flash_erase_logbook ; ... and complete logbook (!) | |
265 bra comm_download_mode0 ; done | |
0 | 266 |
267 ;----------------------------------------------------------------------------- | |
604 | 268 comm_reset_battery_gauge: ; resets battery gauge registers |
269 call reset_battery_pointer ; resets battery pointer 0x07-0x0C and battery_gauge:5 | |
270 bra comm_download_mode0 ; done | |
0 | 271 |
272 ;----------------------------------------------------------------------------- | |
604 | 273 ; erases range in 4 kB steps |
0 | 274 |
275 comm_erase_range4kb: | |
604 | 276 movlw 0x42 ; send echo |
582 | 277 movwf TXREG1 |
604 | 278 rcall comm_write_byte ; wait for UART |
279 bcf INTCON,GIE ; all interrupts off! | |
280 rcall comm_get_flash_address ; get three bytes address or return | |
281 btfsc rs232_receive_overflow ; got data? | |
282 bra comm_download_mode0 ; NO - done | |
283 rcall comm_get_byte | |
284 btfsc rs232_receive_overflow ; got byte? | |
285 bra comm_download_mode0 ; NO - done | |
582 | 286 movff RCREG1,lo |
287 ; Got 4 bytes: 3 bytes address and 1 byte (lo) amount of 4kB blocks | |
288 comm_erase_range4kb_loop: | |
604 | 289 call ext_flash_erase4kB ; erase block |
582 | 290 movlw 0x10 |
291 addwf ext_flash_address+1,F | |
292 movlw .0 | |
604 | 293 addwfc ext_flash_address+2,F ; increase address by .4096, or 0x1000 |
582 | 294 decfsz lo,F |
604 | 295 bra comm_erase_range4kb_loop ; loop until lo=zero |
296 bra comm_download_mode0 ; done (sends the 4C OK too) | |
0 | 297 |
298 ;----------------------------------------------------------------------------- | |
299 | |
604 | 300 comm_erase_4kb: ; get 3 bytes start address |
301 bcf INTCON,GIE ; all interrupts off | |
0 | 302 |
604 | 303 rcall comm_get_flash_address ; get three bytes address or return |
304 btfsc rs232_receive_overflow ; got data? | |
305 bra comm_download_mode0 ; NO - done | |
0 | 306 |
604 | 307 call ext_flash_erase4kB ; erase one block |
308 bra comm_download_mode0 ; done | |
0 | 309 |
310 ;----------------------------------------------------------------------------- | |
311 | |
604 | 312 comm_write_range: ; get 3 bytes start address |
313 movlw 0x30 ; send echo | |
0 | 314 movwf TXREG1 |
604 | 315 rcall comm_write_byte ; wait for UART |
0 | 316 |
604 | 317 bcf INTCON,GIE ; all interrupts off |
0 | 318 |
604 | 319 rcall comm_get_flash_address ; get three bytes address or return |
320 btfsc rs232_receive_overflow ; got data? | |
321 bra comm_download_mode0 ; NO - done | |
0 | 322 |
323 comm_write_range_loop: | |
604 | 324 rcall comm_get_byte |
325 btfsc rs232_receive_overflow ; got byte? | |
326 bra comm_download_mode0 ; NO - done (and send OK byte too) | |
0 | 327 movf RCREG1,W |
604 | 328 ; bsf NCTS ; hold Bluetooth chip (requires PC/Android/iOS side to use flow control...) |
329 call ext_flash_byte_write_comms ; write one byte | |
330 ; bcf NCTS ; release Bluetooth chip (requires PC/Android/iOS side to use flow control...) | |
331 call incf_ext_flash_address_p1 ; increase address+1 | |
420 | 332 bra comm_write_range_loop |
0 | 333 |
334 ;----------------------------------------------------------------------------- | |
335 | |
604 | 336 comm_send_range: ; get 3 bytes start address and 3 bytes amount |
337 movlw 0x20 ; send echo | |
582 | 338 movwf TXREG1 |
604 | 339 rcall comm_write_byte ; wait for UART |
340 bcf INTCON,GIE ; all interrupts off | |
341 rcall comm_get_flash_address ; get three bytes address or return | |
342 btfsc rs232_receive_overflow ; got data? | |
343 bra comm_download_mode0 ; NO - done | |
344 rcall comm_get_byte | |
345 btfsc rs232_receive_overflow ; got byte? | |
346 bra comm_download_mode0 ; NO - done | |
582 | 347 movff RCREG1,up |
604 | 348 rcall comm_get_byte |
349 btfsc rs232_receive_overflow ; got byte? | |
350 bra comm_download_mode0 ; NO - done | |
0 | 351 movff RCREG1,hi |
604 | 352 rcall comm_get_byte |
353 btfsc rs232_receive_overflow ; got byte? | |
354 bra comm_download_mode0 ; NO - done | |
0 | 355 movff RCREG1,lo |
604 | 356 ; if lo==0, we must precondition hi because there are too many bytes sent |
582 | 357 movf lo,W |
358 bnz $+4 | |
359 decf hi,F | |
360 movlw 0x40 | |
604 | 361 cpfslt up ; up > 0x3F? |
362 bra comm_download_mode0 ; YES - abort | |
582 | 363 ; 6 bytes received, send data |
364 ; needs ext_flash_address:3 start address and up:hi:lo amount | |
0 | 365 call ext_flash_read_block_start |
366 movwf TXREG1 | |
604 | 367 bra comm_send_range24 ; counter 24 bit |
0 | 368 comm_send_range24_loop: |
604 | 369 call ext_flash_read_block ; read one byte |
370 movwf TXREG1 ; start new transmit | |
0 | 371 comm_send_range24: |
604 | 372 rcall comm_write_byte ; wait for UART |
0 | 373 decfsz lo,F |
374 bra comm_send_range24_loop | |
375 decf hi,F | |
376 movlw 0xFF | |
377 cpfseq hi | |
378 bra comm_send_range24_loop | |
379 decf up,F | |
380 movlw 0xFF | |
381 cpfseq up | |
382 bra comm_send_range24_loop | |
383 call ext_flash_read_block_stop | |
604 | 384 bra comm_download_mode0 ; done |
0 | 385 |
386 ;----------------------------------------------------------------------------- | |
387 | |
388 comm_get_flash_address: | |
604 | 389 rcall comm_get_byte |
390 btfsc rs232_receive_overflow ; got byte? | |
391 return ; NO - return | |
0 | 392 movff RCREG1,ext_flash_address+2 |
604 | 393 rcall comm_get_byte |
394 btfsc rs232_receive_overflow ; got byte? | |
395 return ; NO - return | |
0 | 396 movff RCREG1,ext_flash_address+1 |
604 | 397 rcall comm_get_byte |
398 btfsc rs232_receive_overflow ; got byte? | |
399 return ; NO - return | |
0 | 400 movff RCREG1,ext_flash_address+0 |
401 return | |
402 | |
403 ;----------------------------------------------------------------------------- | |
404 | |
405 comm_download_mode: | |
406 ; Enable comm download mode | |
582 | 407 WIN_SMALL comm_status2_column, comm_status2_row |
604 | 408 STRCPY_TEXT_PRINT tUsbDownloadMode ; download mode enabled |
409 bsf INTCON,GIE ; all interrupts on | |
410 rcall comm_write_byte ; wait for UART | |
411 movlw 0xBB ; command echo | |
412 movwf TXREG1 ; send answer | |
0 | 413 comm_download_mode0: |
604 | 414 bsf INTCON,GIE ; all interrupts on |
415 rcall comm_write_byte ; wait for UART | |
582 | 416 movlw 0x4C ; 4C in service mode |
417 btfss comm_service_enabled | |
418 movlw 0x4D ; 4D in download mode | |
604 | 419 movwf TXREG1 ; send answer |
0 | 420 movlw timeout_service_mode |
604 | 421 movwf comm_timeout ; timeout |
0 | 422 bcf switch_right |
423 comm_download_mode1: | |
424 bcf onesecupdate | |
582 | 425 dcfsnz comm_timeout,F |
604 | 426 bra comm_service_exit ; timeout -> exit |
0 | 427 comm_download_mode2: |
604 | 428 rcall comm_get_byte ; check for a byte |
582 | 429 btfsc comm_service_enabled |
604 | 430 btg LEDr ; blink in service mode |
582 | 431 btfss vusb_in ; USB plugged in? |
604 | 432 bra comm_service_exit_nousb ; NO - disconnected -> exit |
433 btfsc switch_right ; abort with right button | |
0 | 434 bra comm_service_exit |
435 btfsc onesecupdate | |
436 bra comm_download_mode1 | |
582 | 437 btfsc rs232_receive_overflow |
604 | 438 bra comm_download_mode2 ; wait for command byte |
0 | 439 |
604 | 440 ; command received |
0 | 441 bcf LEDr |
442 movlw 0xFF | |
443 cpfseq RCREG1 | |
444 bra $+4 | |
445 bra comm_service_exit ; exit | |
446 movlw "a" | |
447 cpfseq RCREG1 | |
448 bra $+4 | |
604 | 449 bra comm_send_headers ; send all 256 dive headers |
0 | 450 movlw "b" |
451 cpfseq RCREG1 | |
452 bra $+4 | |
604 | 453 bra comm_set_time ; read time and date from the PC and set clock |
0 | 454 movlw "c" |
455 cpfseq RCREG1 | |
456 bra $+4 | |
604 | 457 bra comm_set_custom_text ; send a opt_name_length byte string of custom text |
582 | 458 movlw "f" ; 0x66 |
0 | 459 cpfseq RCREG1 |
460 bra $+4 | |
604 | 461 bra comm_send_dive ; send header and profile for one dive |
0 | 462 movlw "i" |
463 cpfseq RCREG1 | |
464 bra $+4 | |
604 | 465 bra comm_identify ; send firmware, serial, etc. |
235
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
466 movlw "j" |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
467 cpfseq RCREG1 |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
468 bra $+4 |
604 | 469 bra comm_hardware_descriptor ; send hardware descriptor byte |
441
360acdcda0d7
+BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents:
426
diff
changeset
|
470 movlw 0x60 |
360acdcda0d7
+BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents:
426
diff
changeset
|
471 cpfseq RCREG1 |
360acdcda0d7
+BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents:
426
diff
changeset
|
472 bra $+4 |
604 | 473 bra comm_feature_and_hardware ; send more detailed information |
0 | 474 movlw "n" |
475 cpfseq RCREG1 | |
476 bra $+4 | |
604 | 477 goto comm_send_string ; send a 15 byte string to the screen |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
478 movlw "m" |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
479 cpfseq RCREG1 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
480 bra $+4 |
604 | 481 goto comm_send_compact_headers ; send all 256 compact headers |
482 | |
483 IFDEF _screendump | |
0 | 484 movlw "l" |
485 cpfseq RCREG1 | |
604 | 486 bra $+4 |
487 call TFT_dump_screen ; dump the screen contents | |
488 ENDIF | |
489 | |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
490 movlw "r" |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
491 cpfseq RCREG1 |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
492 bra $+4 |
604 | 493 bra comm_read_setting ; read a setting (and send via USB) |
80 | 494 movlw "w" |
495 cpfseq RCREG1 | |
496 bra $+4 | |
604 | 497 bra comm_write_setting ; write a setting (into RAM) |
80 | 498 movlw "x" |
499 cpfseq RCREG1 | |
500 bra $+4 | |
604 | 501 bra comm_option_reset_all ; reset all options to factory default |
0 | 502 |
604 | 503 btfss comm_service_enabled ; done for download mode |
504 bra comm_download_mode0 ; loop with timeout reset | |
0 | 505 |
506 movlw 0x20 | |
507 cpfseq RCREG1 | |
508 bra $+4 | |
582 | 509 bra comm_send_range ; send hi:lo:ext_flash_rw bytes starting from ext_flash_address:3 |
0 | 510 movlw 0x22 |
511 cpfseq RCREG1 | |
512 bra $+4 | |
604 | 513 bra comm_reset_logbook_pointers ; reset all logbook pointers and the logbook |
0 | 514 movlw 0x23 |
515 cpfseq RCREG1 | |
516 bra $+4 | |
604 | 517 bra comm_reset_battery_gauge ; reset battery gauge registers |
0 | 518 movlw 0x30 |
519 cpfseq RCREG1 | |
520 bra $+4 | |
604 | 521 bra comm_write_range ; write bytes starting from ext_flash_address:3 (stop when timeout) |
0 | 522 movlw 0x40 |
523 cpfseq RCREG1 | |
524 bra $+4 | |
604 | 525 bra comm_erase_4kb ; erase 4 kB block from ext_flash_address:3 (Warning: no confirmation or built-in security here...) |
0 | 526 movlw 0x42 |
527 cpfseq RCREG1 | |
528 bra $+4 | |
604 | 529 bra comm_erase_range4kb ; erase range in 4 kB steps (get 3 bytes address and 1 byte amount of 4 kB blocks) |
0 | 530 movlw 0x50 |
531 cpfseq RCREG1 | |
532 bra $+4 | |
582 | 533 bra comm_send_firmware ; send firmware to bootloader |
147 | 534 ; movlw "t" |
535 ; cpfseq RCREG1 | |
536 ; bra $+4 | |
604 | 537 ; goto testloop ; start raw-data test loop |
538 IFDEF _rx_function | |
539 movlw 0x70 | |
540 cpfseq RCREG1 | |
541 bra $+4 | |
542 bra comm_update_ostc_rx ; send firmware from external memory 3D0800h -> 3DFFFFh to OSTC RX circuity | |
543 ENDIF | |
0 | 544 movlw 0xC1 |
545 cpfseq RCREG1 | |
546 bra $+4 | |
604 | 547 bra comm_service_ll_bootloader ; start low-level bootloader |
548 bra comm_download_mode0 ; loop with timeout reset | |
0 | 549 |
550 ;----------------------------------------------------------------------------- | |
551 | |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
552 comm_send_compact_headers: |
560 | 553 movlw "m" ; send echo |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
554 movwf TXREG1 |
604 | 555 ; send 13 bytes/dive (compact header) |
347
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
556 ; 1st: 200009h-200016h |
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
557 ; 2nd: 201009h-201016h |
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
558 ; 3rd: 202009h-202016h |
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
559 ; 100: 264009h-264016h |
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
560 ; 256: 2FF009h-2FF016h |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
561 movlw 0x1F |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
562 movwf ext_flash_address+2 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
563 movlw 0xF0 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
564 movwf ext_flash_address+1 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
565 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
566 comm_send_compact_headers2: |
347
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
567 movlw 0x09 |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
568 movwf ext_flash_address+0 |
604 | 569 ; adjust address for next dive |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
570 movlw 0x10 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
571 addwf ext_flash_address+1 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
572 movlw 0x00 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
573 addwfc ext_flash_address+2 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
574 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
575 movlw 0x30 |
604 | 576 cpfseq ext_flash_address+2 ; all 256 dive send? |
577 bra comm_send_compact_headers4 ; NO - continue | |
578 bra comm_download_mode0 ; done, loop with timeout reset | |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
579 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
580 comm_send_compact_headers4: |
582 | 581 movlw .13 |
604 | 582 movwf lo ; counter |
583 rcall comm_write_byte ; wait for UART | |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
584 call ext_flash_read_block_start ; 1st byte |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
585 movwf TXREG1 |
604 | 586 bra comm_send_compact_headers3 ; counter 24 bit |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
587 comm_send_compact_headers_loop: |
604 | 588 call ext_flash_read_block ; read one byte |
589 movwf TXREG1 ; start new transmit | |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
590 comm_send_compact_headers3: |
604 | 591 rcall comm_write_byte ; wait for UART |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
592 decfsz lo,F |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
593 bra comm_send_compact_headers_loop |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
594 call ext_flash_read_block_stop |
347
7e5772df60cd
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
346
diff
changeset
|
595 |
582 | 596 ; Offset to total dive counter |
356
fcf3ae0fee6a
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
354
diff
changeset
|
597 movlw .80 |
fcf3ae0fee6a
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
354
diff
changeset
|
598 movwf ext_flash_address+0 |
582 | 599 call ext_flash_read_block_start ; 1st byte |
600 movwf TXREG1 | |
604 | 601 rcall comm_write_byte ; wait for UART |
356
fcf3ae0fee6a
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
354
diff
changeset
|
602 call ext_flash_read_block ; 2nd byte |
fcf3ae0fee6a
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
354
diff
changeset
|
603 movwf TXREG1 |
582 | 604 call ext_flash_read_block_stop |
604 | 605 rcall comm_write_byte ; wait for UART |
356
fcf3ae0fee6a
Changed content for new 0x6F command (Get compact headers)
heinrichsweikamp
parents:
354
diff
changeset
|
606 |
582 | 607 ; Offset to Logbook-Profile version |
391 | 608 movlw .8 |
609 movwf ext_flash_address+0 | |
604 | 610 call ext_flash_byte_read ; get byte |
582 | 611 movwf TXREG1 |
604 | 612 rcall comm_write_byte ; wait for UART |
560 | 613 bra comm_send_compact_headers2 ; continue |
346
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
614 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
615 |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
616 ;----------------------------------------------------------------------------- |
cf9ce6053dee
New option to download "Compact Headers". Improved BLE support (OSTC 2 and OSTC 3+), updated OSTC interface documentation
heinrichsweikamp
parents:
337
diff
changeset
|
617 |
0 | 618 comm_send_headers: |
560 | 619 movlw "a" ; send echo |
0 | 620 movwf TXREG1 |
621 ; Send 256 bytes/dive (Header) | |
622 ; 1st: 200000h-2000FFh | |
623 ; 2nd: 201000h-2010FFh | |
624 ; 3rd: 202000h-2020FFh | |
625 ; 100: 264000h-2640FFh | |
626 ; 256: 2FF000h-2FF0FFh | |
627 movlw 0x1F | |
628 movwf ext_flash_address+2 | |
629 movlw 0xF0 | |
630 movwf ext_flash_address+1 | |
631 comm_send_headers2: | |
560 | 632 clrf ext_flash_address+0 |
0 | 633 ; Adjust address for next dive |
634 movlw 0x10 | |
635 addwf ext_flash_address+1 | |
636 movlw 0x00 | |
637 addwfc ext_flash_address+2 | |
638 movlw 0x30 | |
604 | 639 cpfseq ext_flash_address+2 ; all 256 dive send? |
640 bra comm_send_headers4 ; NO - continue | |
641 bra comm_download_mode0 ; done, loop with timeout reset | |
0 | 642 comm_send_headers4: |
604 | 643 clrf lo ; counter |
644 rcall comm_write_byte ; wait for UART | |
0 | 645 call ext_flash_read_block_start ; 1st byte |
646 movwf TXREG1 | |
604 | 647 bra comm_send_headers3 ; counter 24 bit |
0 | 648 comm_send_headers_loop: |
604 | 649 call ext_flash_read_block ; read one byte |
650 movwf TXREG1 ; start new transmit | |
0 | 651 comm_send_headers3: |
604 | 652 rcall comm_write_byte ; wait for UART |
0 | 653 decfsz lo,F |
654 bra comm_send_headers_loop | |
655 call ext_flash_read_block_stop | |
560 | 656 bra comm_send_headers2 ; continue |
0 | 657 |
658 ;----------------------------------------------------------------------------- | |
80 | 659 |
604 | 660 comm_option_reset_all: ; reset all options to factory default |
560 | 661 movlw "x" ; send echo |
80 | 662 movwf TXREG1 |
582 | 663 call option_reset_all |
604 | 664 bra comm_download_mode0 ; done, back to loop with timeout reset |
80 | 665 |
666 ;----------------------------------------------------------------------------- | |
0 | 667 |
668 comm_set_time: | |
582 | 669 movlw "b" ; send echo |
0 | 670 movwf TXREG1 |
671 | |
604 | 672 rcall comm_write_byte ; wait for UART |
673 rcall comm_get_byte | |
674 btfsc rs232_receive_overflow ; got byte? | |
675 bra comm_download_mode0 ; NO - abort | |
0 | 676 movff RCREG1, hours |
677 movlw d'24' | |
678 cpfslt hours | |
679 clrf hours | |
604 | 680 rcall comm_get_byte |
681 btfsc rs232_receive_overflow ; got byte? | |
682 bra comm_download_mode0 ; NO - abort | |
0 | 683 movff RCREG1, mins |
684 movlw d'60' | |
685 cpfslt mins | |
686 clrf mins | |
604 | 687 rcall comm_get_byte |
688 btfsc rs232_receive_overflow ; got byte? | |
689 bra comm_download_mode0 ; NO - abort | |
0 | 690 movff RCREG1, secs |
691 movlw d'60' | |
692 cpfslt secs | |
693 clrf secs | |
604 | 694 rcall comm_get_byte |
695 btfsc rs232_receive_overflow ; got byte? | |
696 bra comm_download_mode0 ; NO - abort | |
0 | 697 movff RCREG1, month |
698 movlw d'13' | |
699 cpfslt month | |
700 movwf month | |
604 | 701 rcall comm_get_byte |
702 btfsc rs232_receive_overflow ; got byte? | |
703 bra comm_download_mode0 ; NO - abort | |
704 call comm_check_day ; check day | |
705 rcall comm_get_byte | |
706 btfsc rs232_receive_overflow ; got byte? | |
707 bra comm_download_mode0 ; NO - abort | |
0 | 708 movff RCREG1, year |
709 movlw d'100' | |
710 cpfslt year | |
711 clrf year | |
604 | 712 ; all ok, set RTCC |
582 | 713 call rtc_set_rtc ; writes mins,sec,hours,day,month and year to RTC module |
604 | 714 bra comm_download_mode0 ; done, back to loop with timeout reset |
0 | 715 |
716 ;----------------------------------------------------------------------------- | |
604 | 717 ; Set custom text string (opt_name_length ASCII chars) |
0 | 718 ; |
719 | |
720 comm_set_custom_text: | |
582 | 721 movlw "c" ; send echo |
722 movwf TXREG1 | |
604 | 723 rcall comm_write_byte ; wait for UART |
582 | 724 lfsr FSR2,opt_name |
725 movlw opt_name_length | |
726 movwf lo ; counter | |
0 | 727 comm_set_ctext_loop: |
604 | 728 rcall comm_get_byte |
729 btfsc rs232_receive_overflow ; got byte? | |
730 bra comm_set_ctext_loop_done ; NO - abort | |
731 movff RCREG1,POSTINC2 ; store character | |
582 | 732 decfsz lo,F |
733 bra comm_set_ctext_loop | |
136 | 734 comm_set_ctext_loop_done: |
604 | 735 tstfsz lo ; got opt_name_length bytes? |
736 bra comm_set_ctext_loop_done2 ; NO - clear remaining chars | |
737 bra comm_download_mode0 ; done, loop with timeout reset | |
136 | 738 comm_set_ctext_loop_done2: |
582 | 739 clrf POSTINC2 |
740 decfsz lo,F | |
741 bra comm_set_ctext_loop_done2 | |
604 | 742 bra comm_download_mode0 ; done, loop with timeout reset |
0 | 743 |
744 ;----------------------------------------------------------------------------- | |
604 | 745 ; Reply Serial (2 bytes low:high), firmware (major.minor) and custom text |
0 | 746 ; |
582 | 747 |
0 | 748 comm_identify: |
582 | 749 movlw "i" ; send echo |
750 movwf TXREG1 | |
604 | 751 rcall comm_write_byte ; wait for UART |
0 | 752 |
582 | 753 ;---- Read serial from internal EEPROM address 0000 |
0 | 754 clrf EEADRH |
604 | 755 clrf EEADR ; get serial number LOW |
582 | 756 call read_eeprom ; read byte |
0 | 757 movff EEDATA,lo |
604 | 758 incf EEADR,F ; get serial number HIGH |
582 | 759 call read_eeprom ; read byte |
0 | 760 movff EEDATA,hi |
761 | |
582 | 762 ;---- Emit serial number |
763 movff lo,TXREG1 | |
604 | 764 rcall comm_write_byte |
582 | 765 movff hi,TXREG1 |
604 | 766 rcall comm_write_byte |
0 | 767 |
582 | 768 ;---- Emit firmware hi.lo |
769 movlw softwareversion_x | |
770 movwf TXREG1 | |
604 | 771 rcall comm_write_byte |
582 | 772 movlw softwareversion_y |
773 movwf TXREG1 | |
604 | 774 rcall comm_write_byte |
0 | 775 |
776 ;---- Emit custom text | |
582 | 777 movlw opt_name_length |
778 movwf hi | |
779 lfsr FSR2,opt_name | |
0 | 780 |
781 common_identify_loop: | |
582 | 782 movff POSTINC2,TXREG1 |
604 | 783 rcall comm_write_byte |
0 | 784 decfsz hi,F |
785 bra common_identify_loop | |
786 | |
604 | 787 bra comm_download_mode0 ; done |
788 | |
789 ;----------------------------------------------------------------------------- | |
790 | |
791 comm_get_byte: | |
792 goto rs232_get_byte ; ... and return | |
793 | |
794 comm_write_byte: | |
795 goto rs232_wait_tx ; ... and return | |
0 | 796 |
235
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
797 ;----------------------------------------------------------------------------- |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
798 ; Reply hardware descriptor byte |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
799 ; |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
800 |
23311219dacc
under construction: new hardware_flag to configure different hardware versions
heinrichsweikamp
parents:
223
diff
changeset
|
801 comm_hardware_descriptor: |
582 | 802 movlw "j" ; send echo |
803 movwf TXREG1 | |
604 | 804 rcall comm_write_byte ; wait for UART |
805 movff hardware_flag1,TXREG1 | |
806 bra comm_download_mode0 ; done | |
0 | 807 |
441
360acdcda0d7
+BUGFIX: Compatibility with "hwOS Config" fixed
heinrichsweikamp
parents:
426
diff
changeset
|
808 comm_feature_and_hardware: |
582 | 809 movlw 0x60 ; send echo |
810 movwf TXREG1 | |
604 | 811 rcall comm_write_byte ; wait for UART |
812 movlw 0x00 ; hardware high byte | |
813 movwf TXREG1 | |
814 rcall comm_write_byte ; wait for UART | |
815 movff hardware_flag1,TXREG1 | |
816 rcall comm_write_byte ; wait for UART | |
817 movlw 0x00 ; feature high Byte | |
818 movwf TXREG1 | |
819 rcall comm_write_byte ; wait for UART | |
820 movlw 0x00 ; feature low Byte | |
582 | 821 movwf TXREG1 |
604 | 822 rcall comm_write_byte ; wait for UART |
823 movlw 0x00 ; model descriptor byte | |
824 movwf TXREG1 | |
825 bra comm_download_mode0 ; done | |
826 | |
827 ;----------------------------------------------------------------------------- | |
828 | |
829 IFDEF _rx_function | |
830 | |
831 comm_update_ostc_rx: | |
832 movlw 0x70 ; send echo | |
582 | 833 movwf TXREG1 |
604 | 834 rcall comm_write_byte ; wait for UART |
835 ; btfss ostc_rx_present ; rx model? | |
836 ; bra comm_download_mode0 ; NO - abort | |
837 | |
838 ; Setup ext_flash_address:3 | |
839 movlw LOW 0x3D0800 | |
840 movwf ext_flash_address+0 | |
841 movlw HIGH (0x3D0800 & 0xFFFF) ; <- & 0xFFFF to suppress warning message... | |
842 movwf ext_flash_address+1 | |
843 movlw UPPER 0x3D0800 | |
844 movwf ext_flash_address+2 | |
845 | |
846 bsf active_reset_ostc_rx | |
847 WAITMS .5 | |
848 bcf active_reset_ostc_rx | |
849 WAITMS .100 | |
850 bcf INTCON,GIE ; halt all interrupts | |
851 | |
852 movlw LOW .992 | |
853 movwf uart1_temp | |
854 movlw HIGH .992 | |
855 movwf uart2_temp | |
856 incf uart2_temp,F ; ++1 | |
857 WAITMS .1 | |
858 | |
859 call ext_flash_read_block_start | |
860 movwf up ; first byte to write | |
861 | |
862 comm_update_ostc_rx_loop: ; (run 992 times) | |
863 WIN_SMALL comm_status4_column, comm_status4_row | |
864 movff uart1_temp,xA+0 | |
865 movf uart2_temp,W | |
866 tstfsz uart2_temp | |
867 decf uart2_temp,W ; --1 for display | |
868 movwf xA+1 | |
869 movlw .64 | |
870 movwf xB+0 | |
871 clrf xB+1 | |
872 call mult16x16 ; xA * xB = xC | |
873 movff xC+0,lo | |
874 movff xC+1,hi | |
875 bsf leftbind | |
876 output_16 | |
877 bcf leftbind | |
878 STRCAT_PRINT " Bytes left " | |
879 | |
880 call I2C_update_OSTC_rx ; send firmware from external memory 3D0800h -> 3DFFFFh to OSTC RX circuity | |
881 | |
882 tstfsz WREG ; returns with WREG=0 if everything was ok | |
883 bra comm_update_ostc_rx_loop_error ; error -> abort | |
884 | |
885 decfsz uart1_temp,F | |
886 bra comm_update_ostc_rx_loop | |
887 decfsz uart2_temp,F | |
888 bra comm_update_ostc_rx_loop | |
889 | |
890 comm_update_ostc_rx_loop_done: | |
891 call ext_flash_read_block_stop | |
892 bsf INTCON,GIE | |
893 WIN_SMALL comm_status4_column, comm_status4_row | |
894 STRCPY_PRINT " " | |
895 bra comm_download_mode0 ; done | |
896 | |
897 comm_update_ostc_rx_loop_error: | |
898 bsf INTCON,GIE | |
899 WIN_SMALL comm_status4_column, comm_status4_row | |
900 STRCPY_PRINT "ERROR. Retry! " | |
901 call wait_1s ; do not use for time critical routines, can be between 0 and 1 sec! | |
902 call wait_1s ; do not use for time critical routines, can be between 0 and 1 sec! | |
903 call wait_1s ; do not use for time critical routines, can be between 0 and 1 sec! | |
904 bra comm_update_ostc_rx_loop_done | |
905 | |
906 ENDIF | |
582 | 907 |
0 | 908 ;----------------------------------------------------------------------------- |
909 | |
910 comm_send_dive: | |
582 | 911 movlw "f"; 0x66 ; send echo |
0 | 912 movwf TXREG1 |
582 | 913 |
604 | 914 rcall comm_get_byte |
915 btfsc rs232_receive_overflow ; got byte? | |
916 bra comm_download_mode0 ; NO - abort! | |
917 movff RCREG1,lo ; store dive number (0-255) | |
0 | 918 ; First, send the header (again) |
604 | 919 ; set ext_flash_address:3 to TOC entry of this dive |
0 | 920 ; 1st: 200000h-200FFFh -> lo=0 |
921 ; 2nd: 201000h-201FFFh -> lo=1 | |
922 ; 3rd: 202000h-202FFFh -> lo=2 | |
923 ; 256: 2FF000h-2FFFFFh -> lo=255 | |
924 clrf ext_flash_address+0 | |
925 clrf ext_flash_address+1 | |
926 movlw 0x20 | |
927 movwf ext_flash_address+2 | |
928 movlw .16 | |
582 | 929 mulwf lo ; lo*16 = offset to 0x2000 (up:hi) |
0 | 930 movf PRODL,W |
931 addwf ext_flash_address+1,F | |
932 movf PRODH,W | |
933 addwfc ext_flash_address+2,F | |
934 | |
604 | 935 incf_ext_flash_address d'2' ; skip 0xFA, 0xFA |
936 call ext_flash_byte_read_plus ; read start address of profile | |
582 | 937 movff ext_flash_rw,ext_flash_log_pointer+0 |
604 | 938 call ext_flash_byte_read_plus ; read start address of profile |
582 | 939 movff ext_flash_rw,ext_flash_log_pointer+1 |
604 | 940 call ext_flash_byte_read_plus ; read start address of profile |
582 | 941 movff ext_flash_rw,ext_flash_log_pointer+2 |
604 | 942 call ext_flash_byte_read_plus ; read end address of profile |
582 | 943 movff ext_flash_rw,ext_flash_end_pointer+0 |
604 | 944 call ext_flash_byte_read_plus ; read end address of profile |
582 | 945 movff ext_flash_rw,ext_flash_end_pointer+1 |
604 | 946 call ext_flash_byte_read_plus ; read end address of profile |
582 | 947 movff ext_flash_rw,ext_flash_end_pointer+2 |
604 | 948 decf_ext_flash_address d'8' ; back again to first 0xFA in header |
0 | 949 |
582 | 950 movf ext_flash_log_pointer+0,W |
604 | 951 cpfseq ext_flash_end_pointer+0 ; equal? |
952 bra comm_send_dive1 ; NO - send header | |
0 | 953 |
582 | 954 movf ext_flash_log_pointer+1,W |
604 | 955 cpfseq ext_flash_end_pointer+1 ; equal? |
956 bra comm_send_dive1 ; NO - send header | |
0 | 957 |
582 | 958 movf ext_flash_log_pointer+2,W |
604 | 959 cpfseq ext_flash_end_pointer+2 ; equal? |
960 bra comm_send_dive1 ; NO - send header | |
0 | 961 |
582 | 962 ; Start=End -> Not good, abort |
604 | 963 bra comm_download_mode0 ; done, loop with timeout reset |
0 | 964 |
965 comm_send_dive1: | |
966 ; Send header | |
604 | 967 clrf hi ; counter |
968 rcall comm_write_byte ; wait for UART | |
582 | 969 call ext_flash_read_block_start ; 1st byte |
0 | 970 movwf TXREG1 |
582 | 971 bra comm_send_dive_header |
0 | 972 comm_send_dive_header2: |
604 | 973 call ext_flash_read_block ; read one byte |
974 movwf TXREG1 ; start new transmit | |
0 | 975 comm_send_dive_header: |
604 | 976 rcall comm_write_byte ; wait for UART |
0 | 977 decfsz hi,F |
582 | 978 bra comm_send_dive_header2 |
0 | 979 call ext_flash_read_block_stop |
980 | |
981 ; Set address for profile | |
982 movff ext_flash_log_pointer+0,ext_flash_address+0 | |
983 movff ext_flash_log_pointer+1,ext_flash_address+1 | |
984 movff ext_flash_log_pointer+2,ext_flash_address+2 | |
985 | |
604 | 986 movlw .6 ; skip 6 byte short header in profile - only for internal use |
582 | 987 call incf_ext_flash_address0_0x20 ; increases bytes in ext_flash_address:3 with 0x200000 bank switching |
0 | 988 |
512 | 989 ; Set address for short header/compact header, Byte 0 |
582 | 990 |
0 | 991 comm_send_dive_profile: |
604 | 992 call ext_flash_byte_read_plus_0x20 ; read one byte into ext_flash_rw, takes care of banking at 0x200000 |
993 rcall comm_write_byte ; wait for UART | |
994 movff ext_flash_rw,TXREG1 ; send a byte | |
582 | 995 |
0 | 996 ; 24bit compare with end address |
582 | 997 movff ext_flash_end_pointer+0,WREG |
0 | 998 cpfseq ext_flash_address+0 |
582 | 999 bra comm_send_dive_profile |
1000 movff ext_flash_end_pointer+1,WREG | |
0 | 1001 cpfseq ext_flash_address+1 |
582 | 1002 bra comm_send_dive_profile |
1003 movff ext_flash_end_pointer+2,WREG | |
0 | 1004 cpfseq ext_flash_address+2 |
582 | 1005 bra comm_send_dive_profile |
1006 | |
604 | 1007 rcall comm_write_byte ; wait for UART |
1008 bra comm_download_mode0 ; done, loop with timeout reset | |
0 | 1009 |
1010 ;----------------------------------------------------------------------------- | |
1011 | |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1012 comm_read_setting: |
582 | 1013 movlw "r" |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1014 movwf TXREG1 |
604 | 1015 rcall comm_get_byte |
1016 btfsc rs232_receive_overflow ; got byte? | |
1017 bra comm_read_abort ; NO - abort! | |
1018 rcall comm_write_byte ; wait for UART | |
582 | 1019 movlw 0x0F |
1020 cpfsgt RCREG1 ; 0x00-0x0F: unused | |
1021 bra comm_read_abort ; abort! | |
604 | 1022 subwf RCREG1,W ; subtract unused commands |
1023 | |
1024 clrf up ; set gas/dil index to 0 (0 = gas 1) | |
582 | 1025 dcfsnz WREG |
604 | 1026 bra comm_read_gas_dil ; RCREG1=0x10 |
1027 incf up ; increment gas/dil index (1 = gas 2) | |
582 | 1028 dcfsnz WREG |
604 | 1029 bra comm_read_gas_dil ; RCREG1=0x11 |
1030 incf up ; increment gas/dil index (2 = gas 3) | |
582 | 1031 dcfsnz WREG |
604 | 1032 bra comm_read_gas_dil ; RCREG1=0x12 |
1033 incf up ; increment gas/dil index (3 = gas 4) | |
582 | 1034 dcfsnz WREG |
604 | 1035 bra comm_read_gas_dil ; RCREG1=0x13 |
1036 incf up ; increment gas/dil index (4 = gas 5) | |
582 | 1037 dcfsnz WREG |
604 | 1038 bra comm_read_gas_dil ; RCREG1=0x14 |
1039 incf up ; increment gas/dil index (5 = dil 1) | |
1040 dcfsnz WREG | |
1041 bra comm_read_gas_dil ; RCREG1=0x15 | |
1042 incf up ; increment gas/dil index (6 = dil 2) | |
582 | 1043 dcfsnz WREG |
604 | 1044 bra comm_read_gas_dil ; RCREG1=0x16 |
1045 incf up ; increment gas/dil index (7 = dil 3) | |
582 | 1046 dcfsnz WREG |
604 | 1047 bra comm_read_gas_dil ; RCREG1=0x17 |
1048 incf up ; increment gas/dil index (8 = dil 4) | |
582 | 1049 dcfsnz WREG |
604 | 1050 bra comm_read_gas_dil ; RCREG1=0x18 |
1051 incf up ; increment gas/dil index (9 = dil 5) | |
582 | 1052 dcfsnz WREG |
604 | 1053 bra comm_read_gas_dil ; RCREG1=0x19 |
1054 | |
1055 clrf up ; set setpoint index to 0 (0 = SP 1) | |
582 | 1056 dcfsnz WREG |
604 | 1057 bra comm_read_sp ; RCREG1=0x1A |
1058 incf up ; increment setpoint index (1 = SP2) | |
582 | 1059 dcfsnz WREG |
604 | 1060 bra comm_read_sp ; RCREG1=0x1B |
1061 incf up ; increment setpoint index (2 = SP3) | |
582 | 1062 dcfsnz WREG |
604 | 1063 bra comm_read_sp ; RCREG1=0x1C |
1064 incf up ; increment setpoint index (3 = SP4) | |
582 | 1065 dcfsnz WREG |
604 | 1066 bra comm_read_sp ; RCREG1=0x1D |
1067 incf up ; increment setpoint index (4 = SP5) | |
582 | 1068 dcfsnz WREG |
604 | 1069 bra comm_read_sp ; RCREG1=0x1E |
1070 | |
582 | 1071 dcfsnz WREG |
604 | 1072 movff opt_ccr_mode, TXREG1 ; RCREG1=0x1F |
1073 dcfsnz WREG | |
1074 movff opt_dive_mode, TXREG1 ; RCREG1=0x20 | |
582 | 1075 dcfsnz WREG |
604 | 1076 movff char_I_deco_model, TXREG1 ; RCREG1=0x21 |
1077 dcfsnz WREG | |
1078 movff char_I_ppO2_max, TXREG1 ; RCREG1=0x22 | |
582 | 1079 dcfsnz WREG |
604 | 1080 movff char_I_ppO2_min, TXREG1 ; RCREG1=0x23 |
582 | 1081 dcfsnz WREG |
604 | 1082 movff char_I_extra_time, TXREG1 ; RCREG1=0x24 |
1083 dcfsnz WREG | |
1084 movff opt_GF_low, TXREG1 ; RCREG1=0x25 | |
582 | 1085 dcfsnz WREG |
604 | 1086 movff opt_GF_high, TXREG1 ; RCREG1=0x26 |
1087 dcfsnz WREG | |
1088 movff opt_aGF_low, TXREG1 ; RCREG1=0x27 | |
582 | 1089 dcfsnz WREG |
604 | 1090 movff opt_aGF_high, TXREG1 ; RCREG1=0x28 |
1091 dcfsnz WREG | |
1092 movff opt_enable_aGF, TXREG1 ; RCREG1=0x29 | |
582 | 1093 dcfsnz WREG |
604 | 1094 movff opt_sat_multiplier_non_gf, TXREG1 ; RCREG1=0x2A |
1095 dcfsnz WREG | |
1096 movff opt_desat_multiplier_non_gf,TXREG1 ; RCREG1=0x2B | |
582 | 1097 dcfsnz WREG |
604 | 1098 movff opt_last_stop, TXREG1 ; RCREG1=0x2C |
582 | 1099 dcfsnz WREG |
604 | 1100 movff opt_brightness, TXREG1 ; RCREG1=0x2D |
582 | 1101 dcfsnz WREG |
604 | 1102 movff opt_units, TXREG1 ; RCREG1=0x2E |
1103 dcfsnz WREG | |
1104 movff opt_sampling_rate, TXREG1 ; RCREG1=0x2F | |
582 | 1105 dcfsnz WREG |
604 | 1106 movff opt_salinity, TXREG1 ; RCREG1=0x30 |
1107 dcfsnz WREG | |
1108 movff opt_dive_color_scheme, TXREG1 ; RCREG1=0x31 | |
582 | 1109 dcfsnz WREG |
604 | 1110 movff opt_language, TXREG1 ; RCREG1=0x32 |
1111 dcfsnz WREG | |
1112 movff opt_dateformat, TXREG1 ; RCREG1=0x33 | |
582 | 1113 dcfsnz WREG |
604 | 1114 movff opt_compass_gain, TXREG1 ; RCREG1=0x34 |
582 | 1115 dcfsnz WREG |
604 | 1116 movff opt_pressure_adjust, TXREG1 ; RCREG1=0x35 |
582 | 1117 dcfsnz WREG |
604 | 1118 movff opt_enable_safetystop, TXREG1 ; RCREG1=0x36 |
1119 dcfsnz WREG | |
1120 movff opt_calibration_O2_ratio, TXREG1 ; RCREG1=0x37 | |
582 | 1121 dcfsnz WREG |
604 | 1122 clrf TXREG1 ; RCREG1=0x38 NOT USED ANYMORE (ex opt_sensor_fallback) |
1123 dcfsnz WREG | |
1124 movff opt_flip_screen, TXREG1 ; RCREG1=0x39 | |
582 | 1125 dcfsnz WREG |
604 | 1126 movff opt_cR_button_left, TXREG1 ; RCREG1=0x3A |
1127 dcfsnz WREG | |
1128 movff opt_cR_button_right, TXREG1 ; RCREG1=0x3B | |
582 | 1129 dcfsnz WREG |
604 | 1130 movff char_I_bottom_usage, TXREG1 ; RCREG1=0x3C |
582 | 1131 dcfsnz WREG |
604 | 1132 movff char_I_deco_usage, TXREG1 ; RCREG1=0x3D |
582 | 1133 dcfsnz WREG |
604 | 1134 movff opt_modwarning, TXREG1 ; RCREG1=0x3E |
1135 dcfsnz WREG | |
1136 movff opt_vsitextv2, TXREG1 ; RCREG1=0x3F | |
582 | 1137 dcfsnz WREG |
604 | 1138 movff opt_vsigraph, TXREG1 ; RCREG1=0x40 |
1139 dcfsnz WREG | |
1140 movff opt_showppo2, TXREG1 ; RCREG1=0x41 | |
582 | 1141 dcfsnz WREG |
604 | 1142 movff opt_temperature_adjust, TXREG1 ; RCREG1=0x42 |
1143 dcfsnz WREG | |
1144 movff opt_safety_stop_length, TXREG1 ; RCREG1=0x43 | |
582 | 1145 dcfsnz WREG |
604 | 1146 movff opt_safety_stop_start, TXREG1 ; RCREG1=0x44 |
582 | 1147 dcfsnz WREG |
604 | 1148 movff opt_safety_stop_end, TXREG1 ; RCREG1=0x45 |
582 | 1149 dcfsnz WREG |
604 | 1150 movff opt_safety_stop_reset, TXREG1 ; RCREG1=0x46 |
1151 dcfsnz WREG | |
1152 clrf TXREG1 ; RCREG1=0x47, ignore conservatism in hwOS tech firmware | |
582 | 1153 dcfsnz WREG |
604 | 1154 movff opt_diveTimeout, TXREG1 ; RCREG1=0x48 |
1155 dcfsnz WREG | |
1156 movff button_polarity, TXREG1 ; RCREG1=0x49 | |
582 | 1157 dcfsnz WREG |
604 | 1158 movff char_I_PSCR_drop, TXREG1 ; RCREG1=0x4A |
1159 dcfsnz WREG | |
1160 movff char_I_PSCR_lungratio, TXREG1 ; RCREG1=0x4B | |
582 | 1161 dcfsnz WREG |
604 | 1162 movff char_I_ppO2_max_deco, TXREG1 ; RCREG1=0x4C |
582 | 1163 dcfsnz WREG |
604 | 1164 movff char_I_ppO2_min_loop, TXREG1 ; RCREG1=0x4D |
582 | 1165 dcfsnz WREG |
604 | 1166 movff char_I_tank_size+0, TXREG1 ; RCREG1=0x4E |
1167 dcfsnz WREG | |
1168 movff char_I_tank_size+1, TXREG1 ; RCREG1=0x4F | |
582 | 1169 dcfsnz WREG |
604 | 1170 movff char_I_tank_size+2, TXREG1 ; RCREG1=0x50 |
1171 dcfsnz WREG | |
1172 movff char_I_tank_size+3, TXREG1 ; RCREG1=0x51 | |
582 | 1173 dcfsnz WREG |
604 | 1174 movff char_I_tank_size+4, TXREG1 ; RCREG1=0x52 |
1175 dcfsnz WREG | |
1176 movff char_I_tank_pres_fill+0, TXREG1 ; RCREG1=0x53 | |
582 | 1177 dcfsnz WREG |
604 | 1178 movff char_I_tank_pres_fill+1, TXREG1 ; RCREG1=0x54 |
582 | 1179 dcfsnz WREG |
604 | 1180 movff char_I_tank_pres_fill+2, TXREG1 ; RCREG1=0x55 |
582 | 1181 dcfsnz WREG |
604 | 1182 movff char_I_tank_pres_fill+3, TXREG1 ; RCREG1=0x56 |
1183 dcfsnz WREG | |
1184 movff char_I_tank_pres_fill+4, TXREG1 ; RCREG1=0x57 | |
582 | 1185 dcfsnz WREG |
604 | 1186 movff char_I_cc_max_frac_o2, TXREG1 ; RCREG1=0x58 |
1187 dcfsnz WREG | |
1188 movff opt_sim_setpoint_number, TXREG1 ; RCREG1=0x59 | |
582 | 1189 dcfsnz WREG |
604 | 1190 movff opt_calc_asc_gasvolume, TXREG1 ; RCREG1=0x5A |
1191 dcfsnz WREG | |
1192 movff opt_sim_use_aGF, TXREG1 ; RCREG1=0x5B | |
582 | 1193 dcfsnz WREG |
604 | 1194 movff char_I_altitude_wait, TXREG1 ; RCREG1=0x5C |
582 | 1195 dcfsnz WREG |
604 | 1196 movff opt_enable_IBCD, TXREG1 ; RCREG1=0x5D |
582 | 1197 dcfsnz WREG |
604 | 1198 movff opt_sat_multiplier_gf, TXREG1 ; RCREG1=0x5E |
1199 dcfsnz WREG | |
1200 movff opt_desat_multiplier_gf, TXREG1 ; RCREG1=0x5F | |
582 | 1201 dcfsnz WREG |
604 | 1202 movff opt_transmitter_id_1+0, TXREG1 ; RCREG1=0x60 |
1203 dcfsnz WREG | |
1204 movff opt_transmitter_id_1+1, TXREG1 ; RCREG1=0x61 | |
582 | 1205 dcfsnz WREG |
604 | 1206 movff opt_transmitter_id_2+0, TXREG1 ; RCREG1=0x62 |
1207 dcfsnz WREG | |
1208 movff opt_transmitter_id_2+1, TXREG1 ; RCREG1=0x63 | |
582 | 1209 dcfsnz WREG |
604 | 1210 movff opt_transmitter_id_3+0, TXREG1 ; RCREG1=0x64 |
582 | 1211 dcfsnz WREG |
604 | 1212 movff opt_transmitter_id_3+1, TXREG1 ; RCREG1=0x65 |
582 | 1213 dcfsnz WREG |
604 | 1214 movff opt_transmitter_id_4+0, TXREG1 ; RCREG1=0x66 |
1215 dcfsnz WREG | |
1216 movff opt_transmitter_id_4+1, TXREG1 ; RCREG1=0x67 | |
582 | 1217 dcfsnz WREG |
604 | 1218 movff opt_transmitter_id_5+0, TXREG1 ; RCREG1=0x68 |
1219 dcfsnz WREG | |
1220 movff opt_transmitter_id_5+1, TXREG1 ; RCREG1=0x69 | |
582 | 1221 dcfsnz WREG |
604 | 1222 movff opt_transmitter_id_6+0, TXREG1 ; RCREG1=0x6A |
1223 dcfsnz WREG | |
1224 movff opt_transmitter_id_6+1, TXREG1 ; RCREG1=0x6B | |
582 | 1225 dcfsnz WREG |
604 | 1226 movff opt_transmitter_id_7+0, TXREG1 ; RCREG1=0x6C |
582 | 1227 dcfsnz WREG |
604 | 1228 movff opt_transmitter_id_7+1, TXREG1 ; RCREG1=0x6D |
582 | 1229 dcfsnz WREG |
604 | 1230 movff opt_transmitter_id_8+0, TXREG1 ; RCREG1=0x6E |
1231 dcfsnz WREG | |
1232 movff opt_transmitter_id_8+1, TXREG1 ; RCREG1=0x6F | |
582 | 1233 dcfsnz WREG |
604 | 1234 movff opt_transmitter_id_9+0, TXREG1 ; RCREG1=0x70 |
1235 dcfsnz WREG | |
1236 movff opt_transmitter_id_9+1, TXREG1 ; RCREG1=0x71 | |
582 | 1237 dcfsnz WREG |
604 | 1238 movff opt_transmitter_id_10+0, TXREG1 ; RCREG1=0x72 |
1239 dcfsnz WREG | |
1240 movff opt_transmitter_id_10+1, TXREG1 ; RCREG1=0x73 | |
582 | 1241 dcfsnz WREG |
604 | 1242 movff char_I_tank_size+5, TXREG1 ; RCREG1=0x74 |
582 | 1243 dcfsnz WREG |
604 | 1244 movff char_I_tank_size+6, TXREG1 ; RCREG1=0x75 |
582 | 1245 dcfsnz WREG |
604 | 1246 movff char_I_tank_size+7, TXREG1 ; RCREG1=0x76 |
1247 dcfsnz WREG | |
1248 movff char_I_tank_size+8, TXREG1 ; RCREG1=0x77 | |
582 | 1249 dcfsnz WREG |
604 | 1250 movff char_I_tank_size+9, TXREG1 ; RCREG1=0x78 |
1251 dcfsnz WREG | |
1252 movff char_I_tank_pres_fill+5, TXREG1 ; RCREG1=0x79 | |
582 | 1253 dcfsnz WREG |
604 | 1254 movff char_I_tank_pres_fill+6, TXREG1 ; RCREG1=0x7A |
1255 dcfsnz WREG | |
1256 movff char_I_tank_pres_fill+7, TXREG1 ; RCREG1=0x7B | |
582 | 1257 dcfsnz WREG |
604 | 1258 movff char_I_tank_pres_fill+8, TXREG1 ; RCREG1=0x7C |
582 | 1259 dcfsnz WREG |
604 | 1260 movff char_I_tank_pres_fill+9, TXREG1 ; RCREG1=0x7D |
582 | 1261 dcfsnz WREG |
604 | 1262 movff opt_TR_mode, TXREG1 ; RCREG1=0x7E |
1263 dcfsnz WREG | |
1264 movff opt_TR_1st_pres, TXREG1 ; RCREG1=0x7F | |
582 | 1265 dcfsnz WREG |
604 | 1266 movff opt_TR_2nd_pres, TXREG1 ; RCREG1=0x80 |
582 | 1267 dcfsnz WREG |
604 | 1268 movff opt_TR_Bail_pres, TXREG1 ; RCREG1=0x81 |
582 | 1269 dcfsnz WREG |
604 | 1270 movff char_I_max_pres_diff, TXREG1 ; RCREG1=0x82 |
1271 dcfsnz WREG | |
1272 movff opt_ZfactorUse, TXREG1 ; RCREG1=0x83 | |
582 | 1273 dcfsnz WREG |
604 | 1274 movff opt_ZfactorTemp, TXREG1 ; RCREG1=0x84 |
582 | 1275 dcfsnz WREG |
604 | 1276 movff opt_2ndDepthDisp, TXREG1 ; RCREG1=0x85 |
582 | 1277 |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1278 comm_read_abort: |
255 | 1279 comm_read_done: |
604 | 1280 bra comm_download_mode0 ; done, loop with timeout reset |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1281 |
604 | 1282 ;----------------------------------------------------------------------------- |
157
5ee76921e359
make new parameters configurable through pc
heinrichsweikamp
parents:
150
diff
changeset
|
1283 |
604 | 1284 ; Memory map is as follows: |
1285 ; ------------------------- | |
1286 ; opt_gas_O2_ratio res 5 ; O2 ratios of OC/bailout gases | |
1287 ; opt_dil_O2_ratio res 5 ; O2 ratios of diluents | |
1288 ; opt_gas_He_ratio res 5 ; He ratios of OC/bailout gases | |
1289 ; opt_dil_He_ratio res 5 ; He ratios of diluents | |
1290 ; opt_gas_type res 5 ; OC/bailout gas type | |
1291 ; opt_dil_type res 5 ; dil type | |
1292 ; opt_gas_change res 5 ; change depths for OC/Bailout gases | |
1293 ; opt_dil_change res 5 ; change depths for diluents | |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1294 |
604 | 1295 comm_read_gas_dil: |
1296 lfsr FSR0,opt_gas_O2_ratio ; load base address of gas data arrays | |
1297 movf up,W ; load index (0-9) of gas/dil into WREG, addressing O2 ratio | |
1298 movff PLUSW0, TXREG1 ; transmit O2 ratio | |
1299 rcall comm_write_byte ; wait for UART | |
1300 addlw .10 ; increment index by 10, addressing He ratio now | |
1301 movff PLUSW0, TXREG1 ; transmit He ratio | |
1302 rcall comm_write_byte ; wait for UART | |
1303 addlw .10 ; increment index by 10, addressing gas/dil type now | |
1304 movff PLUSW0, TXREG1 ; transmit gas/dil type | |
1305 rcall comm_write_byte ; wait for UART | |
1306 addlw .10 ; increment index by 10, addressing change depth now | |
1307 movff PLUSW0,TXREG1 ; transmit change depth | |
1308 bra comm_read_done ; done, wait for UART and loop with timeout reset | |
110 | 1309 |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1310 |
604 | 1311 ; Memory map is as follows: |
1312 ; ------------------------- | |
1313 ; char_I_setpoint_cbar res 5 ; setpoints in cbar | |
1314 ; char_I_setpoint_change res 5 ; change depth for the setpoints in meter | |
1315 | |
1316 comm_read_sp: | |
1317 lfsr FSR0,char_I_setpoint_cbar ; load base address of setpoint cbar values | |
1318 movf up,W ; load index (0-4) of setpoint into WREG, addressing cbar value | |
1319 movff PLUSW0, TXREG1 ; transmit setpoint cbar value | |
1320 rcall comm_write_byte ; wait for UART | |
1321 addlw .5 ; increment index by 5, addressing change depth now | |
1322 movff PLUSW0, TXREG1 ; transmit change depth | |
1323 bra comm_read_done ; done, wait for UART and loop with timeout reset | |
1324 | |
80 | 1325 ;----------------------------------------------------------------------------- |
1326 | |
1327 comm_write_setting: | |
582 | 1328 movlw "w" |
80 | 1329 movwf TXREG1 |
604 | 1330 rcall comm_get_byte ; "Byte 2" |
1331 btfsc rs232_receive_overflow ; got byte? | |
1332 bra comm_write_abort ; NO - abort! | |
1333 movff RCREG1,lo ; copy | |
1334 rcall comm_get_byte ; "Byte 3" | |
1335 rcall comm_write_byte ; wait for UART | |
582 | 1336 movlw 0x0F |
1337 cpfsgt lo ; 0x00-0x0F: unused | |
1338 bra comm_write_abort ; abort! | |
604 | 1339 subwf lo,W ; subtract unused commands |
1340 | |
1341 clrf up ; set gas/dil index to 0 (0 = gas 1) | |
582 | 1342 dcfsnz WREG |
604 | 1343 bra comm_write_gas_dil ; RCREG1=0x10 |
1344 incf up ; increment gas/dil index (1 = gas 2) | |
582 | 1345 dcfsnz WREG |
604 | 1346 bra comm_write_gas_dil ; RCREG1=0x11 |
1347 incf up ; increment gas/dil index (2 = gas 3) | |
582 | 1348 dcfsnz WREG |
604 | 1349 bra comm_write_gas_dil ; RCREG1=0x12 |
1350 incf up ; increment gas/dil index (3 = gas 4) | |
582 | 1351 dcfsnz WREG |
604 | 1352 bra comm_write_gas_dil ; RCREG1=0x13 |
1353 incf up ; increment gas/dil index (4 = gas 5) | |
582 | 1354 dcfsnz WREG |
604 | 1355 bra comm_write_gas_dil ; RCREG1=0x14 |
1356 incf up ; increment gas/dil index (5 = dil 1) | |
582 | 1357 dcfsnz WREG |
604 | 1358 bra comm_write_gas_dil ; RCREG1=0x15 |
1359 incf up ; increment gas/dil index (6 = dil 2) | |
1360 dcfsnz WREG | |
1361 bra comm_write_gas_dil ; RCREG1=0x16 | |
1362 incf up ; increment gas/dil index (7 = dil 3) | |
582 | 1363 dcfsnz WREG |
604 | 1364 bra comm_write_gas_dil ; RCREG1=0x17 |
1365 incf up ; increment gas/dil index (8 = dil 4) | |
582 | 1366 dcfsnz WREG |
604 | 1367 bra comm_write_gas_dil ; RCREG1=0x18 |
1368 incf up ; increment gas/dil index (9 = dil 5) | |
582 | 1369 dcfsnz WREG |
604 | 1370 bra comm_write_gas_dil ; RCREG1=0x19 |
1371 | |
1372 clrf up ; set setpoint index to 0 (0 = SP 1) | |
582 | 1373 dcfsnz WREG |
604 | 1374 bra comm_write_sp ; RCREG1=0x1A |
1375 incf up ; increment setpoint index (1 = SP2) | |
582 | 1376 dcfsnz WREG |
604 | 1377 bra comm_write_sp ; RCREG1=0x1B |
1378 incf up ; increment setpoint index (2 = SP3) | |
582 | 1379 dcfsnz WREG |
604 | 1380 bra comm_write_sp ; RCREG1=0x1C |
1381 incf up ; increment setpoint index (3 = SP4) | |
582 | 1382 dcfsnz WREG |
604 | 1383 bra comm_write_sp ; RCREG1=0x1D |
1384 incf up ; increment setpoint index (4 = SP5) | |
1385 dcfsnz WREG | |
1386 bra comm_write_sp ; RCREG1=0x1E | |
1387 | |
582 | 1388 dcfsnz WREG |
1389 movff RCREG1, opt_ccr_mode ; RCREG1=0x1F | |
1390 dcfsnz WREG | |
1391 movff RCREG1, opt_dive_mode ; RCREG1=0x20 | |
1392 dcfsnz WREG | |
1393 movff RCREG1, char_I_deco_model ; RCREG1=0x21 | |
1394 dcfsnz WREG | |
1395 movff RCREG1, char_I_ppO2_max ; RCREG1=0x22 | |
1396 dcfsnz WREG | |
1397 movff RCREG1, char_I_ppO2_min ; RCREG1=0x23 | |
1398 dcfsnz WREG | |
1399 movff RCREG1, char_I_extra_time ; RCREG1=0x24 | |
1400 dcfsnz WREG | |
1401 movff RCREG1, opt_GF_low ; RCREG1=0x25 | |
1402 dcfsnz WREG | |
1403 movff RCREG1, opt_GF_high ; RCREG1=0x26 | |
1404 dcfsnz WREG | |
1405 movff RCREG1, opt_aGF_low ; RCREG1=0x27 | |
1406 dcfsnz WREG | |
1407 movff RCREG1, opt_aGF_high ; RCREG1=0x28 | |
1408 dcfsnz WREG | |
1409 movff RCREG1, opt_enable_aGF ; RCREG1=0x29 | |
1410 dcfsnz WREG | |
1411 movff RCREG1, opt_sat_multiplier_non_gf ; RCREG1=0x2A | |
1412 dcfsnz WREG | |
1413 movff RCREG1, opt_desat_multiplier_non_gf ; RCREG1=0x2B | |
1414 dcfsnz WREG | |
1415 movff RCREG1, opt_last_stop ; RCREG1=0x2C | |
1416 dcfsnz WREG | |
1417 movff RCREG1, opt_brightness ; RCREG1=0x2D | |
1418 dcfsnz WREG | |
1419 movff RCREG1, opt_units ; RCREG1=0x2E | |
1420 dcfsnz WREG | |
1421 movff RCREG1, opt_sampling_rate ; RCREG1=0x2F | |
1422 dcfsnz WREG | |
1423 movff RCREG1, opt_salinity ; RCREG1=0x30 | |
1424 dcfsnz WREG | |
1425 movff RCREG1, opt_dive_color_scheme ; RCREG1=0x31 | |
1426 dcfsnz WREG | |
1427 movff RCREG1, opt_language ; RCREG1=0x32 | |
1428 dcfsnz WREG | |
1429 movff RCREG1, opt_dateformat ; RCREG1=0x33 | |
1430 dcfsnz WREG | |
1431 movff RCREG1, opt_compass_gain ; RCREG1=0x34 | |
1432 dcfsnz WREG | |
1433 movff RCREG1, opt_pressure_adjust ; RCREG1=0x35 | |
1434 dcfsnz WREG | |
1435 movff RCREG1, opt_enable_safetystop ; RCREG1=0x36 | |
1436 dcfsnz WREG | |
1437 movff RCREG1, opt_calibration_O2_ratio; RCREG1=0x37 | |
1438 dcfsnz WREG | |
604 | 1439 nop ; RCREG1=0x38 NOT USED ANYMORE (ex opt_sensor_fallback) |
582 | 1440 dcfsnz WREG |
1441 movff RCREG1, opt_flip_screen ; RCREG1=0x39 | |
1442 dcfsnz WREG | |
1443 movff RCREG1, opt_cR_button_left ; RCREG1=0x3A | |
1444 dcfsnz WREG | |
1445 movff RCREG1, opt_cR_button_right ; RCREG1=0x3B | |
1446 dcfsnz WREG | |
1447 movff RCREG1, char_I_bottom_usage ; RCREG1=0x3C | |
1448 dcfsnz WREG | |
1449 movff RCREG1, char_I_deco_usage ; RCREG1=0x3D | |
1450 dcfsnz WREG | |
1451 movff RCREG1, opt_modwarning ; RCREG1=0x3E | |
1452 dcfsnz WREG | |
1453 movff RCREG1, opt_vsitextv2 ; RCREG1=0x3F | |
1454 dcfsnz WREG | |
1455 movff RCREG1, opt_vsigraph ; RCREG1=0x40 | |
1456 dcfsnz WREG | |
1457 movff RCREG1, opt_showppo2 ; RCREG1=0x41 | |
1458 dcfsnz WREG | |
1459 movff RCREG1, opt_temperature_adjust ; RCREG1=0x42 | |
1460 dcfsnz WREG | |
1461 movff RCREG1, opt_safety_stop_length ; RCREG1=0x43 | |
1462 dcfsnz WREG | |
1463 movff RCREG1, opt_safety_stop_start ; RCREG1=0x44 | |
1464 dcfsnz WREG | |
1465 movff RCREG1, opt_safety_stop_end ; RCREG1=0x45 | |
1466 dcfsnz WREG | |
1467 movff RCREG1, opt_safety_stop_reset ; RCREG1=0x46 | |
1468 dcfsnz WREG | |
1469 nop ; RCREG1=0x47, ignore conservatism for standard hwOS | |
1470 dcfsnz WREG | |
1471 movff RCREG1, opt_diveTimeout ; RCREG1=0x48 | |
1472 dcfsnz WREG | |
1473 bra comm_write_button_polarity ; RCREG1=0x49 | |
1474 dcfsnz WREG | |
1475 movff RCREG1, char_I_PSCR_drop ; RCREG1=0x4A | |
1476 dcfsnz WREG | |
1477 movff RCREG1, char_I_PSCR_lungratio ; RCREG1=0x4B | |
1478 dcfsnz WREG | |
1479 movff RCREG1, char_I_ppO2_max_deco ; RCREG1=0x4C | |
1480 dcfsnz WREG | |
1481 movff RCREG1, char_I_ppO2_min_loop ; RCREG1=0x4D | |
1482 dcfsnz WREG | |
1483 movff RCREG1, char_I_tank_size+0 ; RCREG1=0x4E | |
1484 dcfsnz WREG | |
1485 movff RCREG1, char_I_tank_size+1 ; RCREG1=0x4F | |
1486 dcfsnz WREG | |
1487 movff RCREG1, char_I_tank_size+2 ; RCREG1=0x50 | |
1488 dcfsnz WREG | |
1489 movff RCREG1, char_I_tank_size+3 ; RCREG1=0x51 | |
1490 dcfsnz WREG | |
1491 movff RCREG1, char_I_tank_size+4 ; RCREG1=0x52 | |
1492 dcfsnz WREG | |
1493 movff RCREG1, char_I_tank_pres_fill+0 ; RCREG1=0x53 | |
1494 dcfsnz WREG | |
1495 movff RCREG1, char_I_tank_pres_fill+1 ; RCREG1=0x54 | |
1496 dcfsnz WREG | |
1497 movff RCREG1, char_I_tank_pres_fill+2 ; RCREG1=0x55 | |
1498 dcfsnz WREG | |
1499 movff RCREG1, char_I_tank_pres_fill+3 ; RCREG1=0x56 | |
1500 dcfsnz WREG | |
1501 movff RCREG1, char_I_tank_pres_fill+4 ; RCREG1=0x57 | |
1502 dcfsnz WREG | |
1503 movff RCREG1, char_I_cc_max_frac_o2 ; RCREG1=0x58 | |
1504 dcfsnz WREG | |
1505 movff RCREG1, opt_sim_setpoint_number ; RCREG1=0x59 | |
1506 dcfsnz WREG | |
1507 movff RCREG1, opt_calc_asc_gasvolume ; RCREG1=0x5A | |
1508 dcfsnz WREG | |
1509 movff RCREG1, opt_sim_use_aGF ; RCREG1=0x5B | |
1510 dcfsnz WREG | |
1511 movff RCREG1, char_I_altitude_wait ; RCREG1=0x5C | |
1512 dcfsnz WREG | |
1513 movff RCREG1, opt_enable_IBCD ; RCREG1=0x5D | |
1514 dcfsnz WREG | |
1515 movff RCREG1, opt_sat_multiplier_gf ; RCREG1=0x5E | |
1516 dcfsnz WREG | |
1517 movff RCREG1, opt_desat_multiplier_gf ; RCREG1=0x5F | |
604 | 1518 dcfsnz WREG |
1519 movff RCREG1, opt_transmitter_id_1+0 ; RCREG1=0x60 | |
1520 dcfsnz WREG | |
1521 movff RCREG1, opt_transmitter_id_1+1 ; RCREG1=0x61 | |
1522 dcfsnz WREG | |
1523 movff RCREG1, opt_transmitter_id_2+0 ; RCREG1=0x62 | |
1524 dcfsnz WREG | |
1525 movff RCREG1, opt_transmitter_id_2+1 ; RCREG1=0x63 | |
1526 dcfsnz WREG | |
1527 movff RCREG1, opt_transmitter_id_3+0 ; RCREG1=0x64 | |
1528 dcfsnz WREG | |
1529 movff RCREG1, opt_transmitter_id_3+1 ; RCREG1=0x65 | |
1530 dcfsnz WREG | |
1531 movff RCREG1, opt_transmitter_id_4+0 ; RCREG1=0x66 | |
1532 dcfsnz WREG | |
1533 movff RCREG1, opt_transmitter_id_4+1 ; RCREG1=0x67 | |
1534 dcfsnz WREG | |
1535 movff RCREG1, opt_transmitter_id_5+0 ; RCREG1=0x68 | |
1536 dcfsnz WREG | |
1537 movff RCREG1, opt_transmitter_id_5+1 ; RCREG1=0x69 | |
1538 dcfsnz WREG | |
1539 movff RCREG1, opt_transmitter_id_6+0 ; RCREG1=0x6A | |
1540 dcfsnz WREG | |
1541 movff RCREG1, opt_transmitter_id_6+1 ; RCREG1=0x6B | |
1542 dcfsnz WREG | |
1543 movff RCREG1, opt_transmitter_id_7+0 ; RCREG1=0x6C | |
1544 dcfsnz WREG | |
1545 movff RCREG1, opt_transmitter_id_7+1 ; RCREG1=0x6D | |
1546 dcfsnz WREG | |
1547 movff RCREG1, opt_transmitter_id_8+0 ; RCREG1=0x6E | |
1548 dcfsnz WREG | |
1549 movff RCREG1, opt_transmitter_id_8+1 ; RCREG1=0x6F | |
1550 dcfsnz WREG | |
1551 movff RCREG1, opt_transmitter_id_9+0 ; RCREG1=0x70 | |
1552 dcfsnz WREG | |
1553 movff RCREG1, opt_transmitter_id_9+1 ; RCREG1=0x71 | |
1554 dcfsnz WREG | |
1555 movff RCREG1, opt_transmitter_id_10+0 ; RCREG1=0x72 | |
1556 dcfsnz WREG | |
1557 movff RCREG1, opt_transmitter_id_10+1 ; RCREG1=0x73 | |
1558 dcfsnz WREG | |
1559 movff RCREG1, char_I_tank_size+5 ; RCREG1=0x74 | |
1560 dcfsnz WREG | |
1561 movff RCREG1, char_I_tank_size+6 ; RCREG1=0x75 | |
1562 dcfsnz WREG | |
1563 movff RCREG1, char_I_tank_size+7 ; RCREG1=0x76 | |
1564 dcfsnz WREG | |
1565 movff RCREG1, char_I_tank_size+8 ; RCREG1=0x77 | |
1566 dcfsnz WREG | |
1567 movff RCREG1, char_I_tank_size+9 ; RCREG1=0x78 | |
1568 dcfsnz WREG | |
1569 movff RCREG1, char_I_tank_pres_fill+5 ; RCREG1=0x79 | |
1570 dcfsnz WREG | |
1571 movff RCREG1, char_I_tank_pres_fill+6 ; RCREG1=0x7A | |
1572 dcfsnz WREG | |
1573 movff RCREG1, char_I_tank_pres_fill+7 ; RCREG1=0x7B | |
1574 dcfsnz WREG | |
1575 movff RCREG1, char_I_tank_pres_fill+8 ; RCREG1=0x7C | |
1576 dcfsnz WREG | |
1577 movff RCREG1, char_I_tank_pres_fill+9 ; RCREG1=0x7D | |
1578 dcfsnz WREG | |
1579 movff RCREG1, opt_TR_mode ; RCREG1=0x7E | |
1580 dcfsnz WREG | |
1581 movff RCREG1, opt_TR_1st_pres ; RCREG1=0x7F | |
1582 dcfsnz WREG | |
1583 movff RCREG1, opt_TR_2nd_pres ; RCREG1=0x80 | |
1584 dcfsnz WREG | |
1585 movff RCREG1, opt_TR_Bail_pres ; RCREG1=0x81 | |
1586 dcfsnz WREG | |
1587 movff RCREG1, char_I_max_pres_diff ; RCREG1=0x82 | |
1588 dcfsnz WREG | |
1589 movff RCREG1, opt_ZfactorUse ; RCREG1=0x83 | |
1590 dcfsnz WREG | |
1591 movff RCREG1, opt_ZfactorTemp ; RCREG1=0x84 | |
1592 dcfsnz WREG | |
1593 movff RCREG1, opt_2ndDepthDisp ; RCREG1=0x85 | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
1594 |
80 | 1595 comm_write_abort: |
604 | 1596 comm_write_done: |
1597 ; check options, gases and diluents | |
1598 call option_check_all ; check all options (and reset if not within their min/max boundaries) | |
1599 bsf FLAG_diluent_setup ; =1: setting up diluents | |
1600 call gaslist_cleanup_list ; take care that only one gas can be first and first has 0m change depth | |
1601 bcf FLAG_diluent_setup ; =1: Setting up diluents | |
1602 call gaslist_cleanup_list ; take care that only one gas can be first and first has 0m change depth | |
1603 call get_first_gas_to_WREG ; make sure at least one gas is "First" | |
1604 call get_first_dil_to_WREG ; make sure at least one diluent is "First" | |
1605 goto comm_download_mode0 ; done, loop with timeout reset | |
1606 | |
1607 ;----------------------------------------------------------------------------- | |
1608 | |
1609 ; Memory map is as follows: | |
1610 ; ------------------------- | |
1611 ; opt_gas_O2_ratio res 5 ; O2 ratios of OC/bailout gases | |
1612 ; opt_dil_O2_ratio res 5 ; O2 ratios of diluents | |
1613 ; opt_gas_He_ratio res 5 ; He ratios of OC/bailout gases | |
1614 ; opt_dil_He_ratio res 5 ; He ratios of diluents | |
1615 ; opt_gas_type res 5 ; OC/bailout gas type | |
1616 ; opt_dil_type res 5 ; dil type | |
1617 ; opt_gas_change res 5 ; change depths for OC/Bailout gases | |
1618 ; opt_dil_change res 5 ; change depths for diluents | |
80 | 1619 |
604 | 1620 comm_write_gas_dil: |
1621 lfsr FSR0,opt_gas_O2_ratio ; load base address of gas data arrays | |
1622 movf up,W ; load index (0-9) of gas/dil into WREG, addressing O2 ratio | |
1623 movff RCREG1,PLUSW0 ; receive O2 ratio | |
1624 rcall comm_get_byte ; wait for UART | |
1625 addlw .10 ; increment index by 10, addressing He ratio now | |
1626 movff RCREG1,PLUSW0 ; receive He ratio | |
1627 rcall comm_get_byte ; wait for UART | |
1628 addlw .10 ; increment index by 10, addressing gas/dil type now | |
1629 movff RCREG1,PLUSW0 ; receive gas/dil type | |
1630 rcall comm_get_byte ; wait for UART | |
1631 addlw .10 ; increment index by 10, addressing change depth now | |
1632 movff RCREG1,PLUSW0 ; receive change depth | |
1633 bra comm_write_done ; done, loop with timeout reset | |
80 | 1634 |
604 | 1635 |
1636 ; Memory map is as follows: | |
1637 ; ------------------------- | |
1638 ; char_I_setpoint_cbar res 5 ; setpoints in cbar | |
1639 ; char_I_setpoint_change res 5 ; change depth for the setpoints in meter | |
1640 | |
1641 comm_write_sp: | |
1642 lfsr FSR0,char_I_setpoint_cbar ; load base address of setpoint cbar values | |
1643 movf up,W ; load index (0-4) of setpoint into WREG, addressing cbar value | |
1644 movff RCREG1,PLUSW0 ; receive setpoint cbar value | |
1645 rcall comm_get_byte ; wait for UART | |
1646 addlw .5 ; increment index by 5, addressing change depth now | |
1647 movff RCREG1,PLUSW0 ; receive change depth | |
1648 bra comm_write_done ; done, loop with timeout reset | |
80 | 1649 |
79
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1650 ;----------------------------------------------------------------------------- |
0fc8113ddf6d
new command in download mode: "r" - read setting
mh@mh-THINK.localdomain
parents:
69
diff
changeset
|
1651 |
0 | 1652 comm_send_string: |
604 | 1653 movlw "n" ; send echo |
0 | 1654 movwf TXREG1 |
604 | 1655 call comm_write_byte ; wait for UART |
582 | 1656 WIN_SMALL comm_string_column, comm_string_row |
0 | 1657 movlw .16 |
604 | 1658 movwf lo ; counter |
0 | 1659 comm_send_string_loop: |
604 | 1660 call comm_get_byte |
1661 btfsc rs232_receive_overflow ; got byte? | |
1662 bra comm_send_string_abort ; NO - abort! | |
1663 movff RCREG1,POSTINC2 ; store character | |
0 | 1664 decfsz lo,F |
1665 bra comm_send_string_loop | |
1666 comm_send_string_abort: | |
604 | 1667 STRCAT_PRINT "" ; show the text |
1668 goto comm_download_mode0 ; done, loop with timeout reset | |
0 | 1669 |
1670 ;----------------------------------------------------------------------------- | |
1671 | |
1672 comm_check_day: | |
582 | 1673 movff RCREG1,day |
604 | 1674 movff month,lo ; new month |
0 | 1675 dcfsnz lo,F |
1676 movlw .31 | |
1677 dcfsnz lo,F | |
1678 movlw .28 | |
1679 dcfsnz lo,F | |
1680 movlw .31 | |
1681 dcfsnz lo,F | |
1682 movlw .30 | |
1683 dcfsnz lo,F | |
1684 movlw .31 | |
1685 dcfsnz lo,F | |
1686 movlw .30 | |
1687 dcfsnz lo,F | |
1688 movlw .31 | |
1689 dcfsnz lo,F | |
1690 movlw .31 | |
1691 dcfsnz lo,F | |
1692 movlw .30 | |
1693 dcfsnz lo,F | |
1694 movlw .31 | |
1695 dcfsnz lo,F | |
1696 movlw .30 | |
1697 dcfsnz lo,F | |
1698 movlw .31 | |
604 | 1699 cpfsgt day ; day ok? |
1700 return ; YES | |
1701 movlw .1 ; NO - set to 1st | |
0 | 1702 movwf day |
582 | 1703 return |
0 | 1704 |
475 | 1705 comm_write_button_polarity: |
604 | 1706 ; store RCREG1 into EEPROM .897 |
582 | 1707 movlw LOW .897 |
475 | 1708 movwf EEADR |
582 | 1709 movlw HIGH .897 |
475 | 1710 movwf EEADRH |
1711 movff RCREG1,EEDATA | |
604 | 1712 movff EEDATA,button_polarity ; 0xFF (both normal), 0x00 (both inverted), 0x01 (left inverted only), 0x02 (right inverted only) |
1713 call write_eeprom ; EEDATA into EEPROM@EEADR | |
1714 clrf EEADRH ; reset EEADRH | |
1715 goto comm_download_mode0 ; done, loop with timeout reset | |
582 | 1716 |
0 | 1717 ;---------------------------------------------------------------------------- |
582 | 1718 END |