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