comparison src/comm.asm @ 604:ca4556fb60b9

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