comparison src/comm.asm @ 582:b455b31ce022

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