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