comparison src/comm.asm @ 80:db920ca01491

new commands in download mode: "w" - write setting "x" - Reset all settings
author mh@mh-THINK.localdomain
date Thu, 27 Feb 2014 14:38:08 +0100
parents 0fc8113ddf6d
children 8e13866b5496
comparison
equal deleted inserted replaced
79:0fc8113ddf6d 80:db920ca01491
472 bra $+4 472 bra $+4
473 bra comm_identify ; Send firmware, serial, etc. 473 bra comm_identify ; Send firmware, serial, etc.
474 movlw "n" 474 movlw "n"
475 cpfseq RCREG1 475 cpfseq RCREG1
476 bra $+4 476 bra $+4
477 bra comm_send_string ; Send a 15byte string to the screen 477 goto comm_send_string ; Send a 15byte string to the screen
478 movlw "l" 478 movlw "l"
479 cpfseq RCREG1 479 cpfseq RCREG1
480 bra $+4 480 bra $+4
481 call TFT_dump_screen ; Dump the screen contents 481 call TFT_dump_screen ; Dump the screen contents
482 movlw "r" 482 movlw "r"
483 cpfseq RCREG1 483 cpfseq RCREG1
484 bra $+4 484 bra $+4
485 bra comm_read_setting ; Read a setting (And send via USB) 485 bra comm_read_setting ; Read a setting (And send via USB)
486 movlw "w"
487 cpfseq RCREG1
488 bra $+4
489 bra comm_write_setting ; Write a setting (Into RAM)
490 movlw "x"
491 cpfseq RCREG1
492 bra $+4
493 bra comm_option_reset_all ; Reset all options to factory default.
486 494
487 495
488 btfss comm_service_enabled ; Done for Download mode 496 btfss comm_service_enabled ; Done for Download mode
489 bra comm_download_mode0 ; Loop with timeout reset 497 bra comm_download_mode0 ; Loop with timeout reset
490 498
518 bra comm_send_firmware ; sends firmware from external flash from 0x3E0000 to 0x3FD000 (118784bytes) via comm 526 bra comm_send_firmware ; sends firmware from external flash from 0x3E0000 to 0x3FD000 (118784bytes) via comm
519 movlw "t" 527 movlw "t"
520 cpfseq RCREG1 528 cpfseq RCREG1
521 bra $+4 529 bra $+4
522 goto testloop ; Start raw-data testloop 530 goto testloop ; Start raw-data testloop
523 movlw "x"
524 cpfseq RCREG1
525 bra $+4
526 call option_reset_all ; Reset all options to factory default.
527 movlw 0xC1 531 movlw 0xC1
528 cpfseq RCREG1 532 cpfseq RCREG1
529 bra $+4 533 bra $+4
530 bra comm_service_ll_bootloader ; Start low-level bootloader 534 bra comm_service_ll_bootloader ; Start low-level bootloader
531 bra comm_download_mode0 ; Loop with timeout reset 535 bra comm_download_mode0 ; Loop with timeout reset
575 bra comm_send_headers_loop 579 bra comm_send_headers_loop
576 call ext_flash_read_block_stop 580 call ext_flash_read_block_stop
577 bra comm_send_headers2 ; continue 581 bra comm_send_headers2 ; continue
578 582
579 ;----------------------------------------------------------------------------- 583 ;-----------------------------------------------------------------------------
580 ; 584
585 comm_option_reset_all: ; Reset all options to factory default.
586 movlw "x" ; send echo
587 movwf TXREG1
588 call option_reset_all
589 bra comm_download_mode0 ; Done. back to loop with timeout reset
590
591 ;-----------------------------------------------------------------------------
581 592
582 comm_set_time: 593 comm_set_time:
583 movlw "b" ; send echo 594 movlw "b" ; send echo
584 movwf TXREG1 595 movwf TXREG1
585 596
1129 comm_read_compass_gain: 1140 comm_read_compass_gain:
1130 movff opt_compass_gain, TXREG1 1141 movff opt_compass_gain, TXREG1
1131 rcall comm_read_setting_wait ; Wait for UART 1142 rcall comm_read_setting_wait ; Wait for UART
1132 bra comm_download_mode0 ; Done. Loop with timeout reset 1143 bra comm_download_mode0 ; Done. Loop with timeout reset
1133 1144
1145 ;-----------------------------------------------------------------------------
1146
1147
1148 comm_write_setting:
1149 movlw "w"
1150 movwf TXREG1
1151 call rs232_get_byte
1152 btfsc rs232_recieve_overflow ; Got byte?
1153 bra comm_write_abort ; No, abort!
1154 call rs232_wait_tx ; Wait for UART
1155 movf RCREG1,W ; Copy
1156 bz comm_write_unused ; RCREG1=0
1157 dcfsnz WREG
1158 bra comm_write_unused ; RCREG1=1
1159 dcfsnz WREG
1160 bra comm_write_unused ; RCREG1=2
1161 dcfsnz WREG
1162 bra comm_write_unused ; RCREG1=3
1163 dcfsnz WREG
1164 bra comm_write_unused ; RCREG1=4
1165 dcfsnz WREG
1166 bra comm_write_unused ; RCREG1=5
1167 dcfsnz WREG
1168 bra comm_write_unused ; RCREG1=6
1169 dcfsnz WREG
1170 bra comm_write_unused ; RCREG1=7
1171 dcfsnz WREG
1172 bra comm_write_unused ; RCREG1=8
1173 dcfsnz WREG
1174 bra comm_write_unused ; RCREG1=9
1175 dcfsnz WREG
1176 bra comm_write_unused ; RCREG1=10
1177 dcfsnz WREG
1178 bra comm_write_unused ; RCREG1=11
1179 dcfsnz WREG
1180 bra comm_write_unused ; RCREG1=12
1181 dcfsnz WREG
1182 bra comm_write_unused ; RCREG1=13
1183 dcfsnz WREG
1184 bra comm_write_unused ; RCREG1=14
1185 dcfsnz WREG
1186 bra comm_write_unused ; RCREG1=15
1187 dcfsnz WREG
1188 bra comm_write_gas1 ; RCREG1=0x10
1189 dcfsnz WREG
1190 bra comm_write_gas2 ; RCREG1=0x11
1191 dcfsnz WREG
1192 bra comm_write_gas3 ; RCREG1=0x12
1193 dcfsnz WREG
1194 bra comm_write_gas4 ; RCREG1=0x13
1195 dcfsnz WREG
1196 bra comm_write_gas5 ; RCREG1=0x14
1197 dcfsnz WREG
1198 bra comm_write_dil1 ; RCREG1=0x15
1199 dcfsnz WREG
1200 bra comm_write_dil2 ; RCREG1=0x16
1201 dcfsnz WREG
1202 bra comm_write_dil3 ; RCREG1=0x17
1203 dcfsnz WREG
1204 bra comm_write_dil4 ; RCREG1=0x18
1205 dcfsnz WREG
1206 bra comm_write_dil5 ; RCREG1=0x19
1207 dcfsnz WREG
1208 bra comm_write_sp1 ; RCREG1=0x1A
1209 dcfsnz WREG
1210 bra comm_write_sp2 ; RCREG1=0x1B
1211 dcfsnz WREG
1212 bra comm_write_sp3 ; RCREG1=0x1C
1213 dcfsnz WREG
1214 bra comm_write_sp4 ; RCREG1=0x1D
1215 dcfsnz WREG
1216 bra comm_write_sp5 ; RCREG1=0x1E
1217 dcfsnz WREG
1218 bra comm_write_ccr_mode ; RCREG1=0x1F
1219 dcfsnz WREG
1220 bra comm_write_dive_mode ; RCREG1=0x20
1221 dcfsnz WREG
1222 bra comm_write_decotype ; RCREG1=0x21
1223 dcfsnz WREG
1224 bra comm_write_ppo2_max ; RCREG1=0x22
1225 dcfsnz WREG
1226 bra comm_write_ppo2_min ; RCREG1=0x23
1227 dcfsnz WREG
1228 bra comm_write_ftts ; RCREG1=0x24
1229 dcfsnz WREG
1230 bra comm_write_gf_low ; RCREG1=0x25
1231 dcfsnz WREG
1232 bra comm_write_gf_high ; RCREG1=0x26
1233 dcfsnz WREG
1234 bra comm_write_agf_low ; RCREG1=0x27
1235 dcfsnz WREG
1236 bra comm_write_agf_high ; RCREG1=0x28
1237 dcfsnz WREG
1238 bra comm_write_agf_selectable ; RCREG1=0x29
1239 dcfsnz WREG
1240 bra comm_write_saturation ; RCREG1=0x2A
1241 dcfsnz WREG
1242 bra comm_write_desaturation ; RCREG1=0x2B
1243 dcfsnz WREG
1244 bra comm_write_last_deco ; RCREG1=0x2C
1245 dcfsnz WREG
1246 bra comm_write_brightness ; RCREG1=0x2D
1247 dcfsnz WREG
1248 bra comm_write_units ; RCREG1=0x2E
1249 dcfsnz WREG
1250 bra comm_write_samplingrate ; RCREG1=0x2F
1251 dcfsnz WREG
1252 bra comm_write_salinity ; RCREG1=0x30
1253 dcfsnz WREG
1254 bra comm_write_divemode_colour ; RCREG1=0x31
1255 dcfsnz WREG
1256 bra comm_write_language ; RCREG1=0x32
1257 dcfsnz WREG
1258 bra comm_write_date_format ; RCREG1=0x33
1259 dcfsnz WREG
1260 bra comm_write_compass_gain ; RCREG1=0x34
1261
1262 comm_write_unused:
1263 comm_write_abort:
1264 bra comm_download_mode0 ; Done. Loop with timeout reset
1265
1266 comm_write_gas1:
1267 call rs232_get_byte
1268 movff RCREG1,opt_gas_O2_ratio+0
1269 call rs232_get_byte
1270 movff RCREG1,opt_gas_He_ratio+0
1271 call rs232_get_byte
1272 movff RCREG1,opt_gas_type+0
1273 call rs232_get_byte
1274 movff RCREG1,char_I_deco_gas_change+0
1275 bra comm_write_abort ; Done. Loop with timeout reset
1276 comm_write_gas2:
1277 call rs232_get_byte
1278 movff RCREG1,opt_gas_O2_ratio+1
1279 call rs232_get_byte
1280 movff RCREG1,opt_gas_He_ratio+1
1281 call rs232_get_byte
1282 movff RCREG1,opt_gas_type+1
1283 call rs232_get_byte
1284 movff RCREG1,char_I_deco_gas_change+1
1285 bra comm_write_abort ; Done. Loop with timeout reset
1286 comm_write_gas3:
1287 call rs232_get_byte
1288 movff RCREG1,opt_gas_O2_ratio+2
1289 call rs232_get_byte
1290 movff RCREG1,opt_gas_He_ratio+2
1291 call rs232_get_byte
1292 movff RCREG1,opt_gas_type+2
1293 call rs232_get_byte
1294 movff RCREG1,char_I_deco_gas_change+2
1295 bra comm_write_abort ; Done. Loop with timeout reset
1296 comm_write_gas4:
1297 call rs232_get_byte
1298 movff RCREG1,opt_gas_O2_ratio+3
1299 call rs232_get_byte
1300 movff RCREG1,opt_gas_He_ratio+3
1301 call rs232_get_byte
1302 movff RCREG1,opt_gas_type+3
1303 call rs232_get_byte
1304 movff RCREG1,char_I_deco_gas_change+3
1305 bra comm_write_abort ; Done. Loop with timeout reset
1306 comm_write_gas5:
1307 call rs232_get_byte
1308 movff RCREG1,opt_gas_O2_ratio+4
1309 call rs232_get_byte
1310 movff RCREG1,opt_gas_He_ratio+4
1311 call rs232_get_byte
1312 movff RCREG1,opt_gas_type+4
1313 call rs232_get_byte
1314 movff RCREG1,char_I_deco_gas_change+4
1315 bra comm_write_abort ; Done. Loop with timeout reset
1316
1317 comm_write_dil1:
1318 call rs232_get_byte
1319 movff RCREG1,opt_dil_O2_ratio+0
1320 call rs232_get_byte
1321 movff RCREG1,opt_dil_He_ratio+0
1322 call rs232_get_byte
1323 movff RCREG1,opt_dil_type+0
1324 call rs232_get_byte
1325 movff RCREG1,char_I_dil_change+0
1326 bra comm_write_abort ; Done. Loop with timeout reset
1327 comm_write_dil2:
1328 call rs232_get_byte
1329 movff RCREG1,opt_dil_O2_ratio+1
1330 call rs232_get_byte
1331 movff RCREG1,opt_dil_He_ratio+1
1332 call rs232_get_byte
1333 movff RCREG1,opt_dil_type+1
1334 call rs232_get_byte
1335 movff RCREG1,char_I_dil_change+1
1336 bra comm_write_abort ; Done. Loop with timeout reset
1337 comm_write_dil3:
1338 call rs232_get_byte
1339 movff RCREG1,opt_dil_O2_ratio+2
1340 call rs232_get_byte
1341 movff RCREG1,opt_dil_He_ratio+2
1342 call rs232_get_byte
1343 movff RCREG1,opt_dil_type+2
1344 call rs232_get_byte
1345 movff RCREG1,char_I_dil_change+2
1346 bra comm_write_abort ; Done. Loop with timeout reset
1347 comm_write_dil4:
1348 call rs232_get_byte
1349 movff RCREG1,opt_dil_O2_ratio+3
1350 call rs232_get_byte
1351 movff RCREG1,opt_dil_He_ratio+3
1352 call rs232_get_byte
1353 movff RCREG1,opt_dil_type+3
1354 call rs232_get_byte
1355 movff RCREG1,char_I_dil_change+3
1356 bra comm_write_abort ; Done. Loop with timeout reset
1357 comm_write_dil5:
1358 call rs232_get_byte
1359 movff RCREG1,opt_dil_O2_ratio+4
1360 call rs232_get_byte
1361 movff RCREG1,opt_dil_He_ratio+4
1362 call rs232_get_byte
1363 movff RCREG1,opt_dil_type+4
1364 call rs232_get_byte
1365 movff RCREG1,char_I_dil_change+4
1366 bra comm_write_abort ; Done. Loop with timeout reset
1367
1368 comm_write_sp1:
1369 call rs232_get_byte
1370 movff RCREG1,char_I_setpoint_cbar+0
1371 call rs232_get_byte
1372 movff RCREG1,char_I_setpoint_change+0
1373 bra comm_write_abort ; Done. Loop with timeout reset
1374 comm_write_sp2:
1375 call rs232_get_byte
1376 movff RCREG1,char_I_setpoint_cbar+1
1377 call rs232_get_byte
1378 movff RCREG1,char_I_setpoint_change+1
1379 bra comm_write_abort ; Done. Loop with timeout reset
1380 comm_write_sp3:
1381 call rs232_get_byte
1382 movff RCREG1,char_I_setpoint_cbar+2
1383 call rs232_get_byte
1384 movff RCREG1,char_I_setpoint_change+2
1385 bra comm_write_abort ; Done. Loop with timeout reset
1386 comm_write_sp4:
1387 call rs232_get_byte
1388 movff RCREG1,char_I_setpoint_cbar+3
1389 call rs232_get_byte
1390 movff RCREG1,char_I_setpoint_change+3
1391 bra comm_write_abort ; Done. Loop with timeout reset
1392 comm_write_sp5:
1393 call rs232_get_byte
1394 movff RCREG1,char_I_setpoint_cbar+4
1395 call rs232_get_byte
1396 movff RCREG1,char_I_setpoint_change+4
1397 bra comm_write_abort ; Done. Loop with timeout reset
1398
1399 comm_write_ccr_mode:
1400 call rs232_get_byte
1401 movff RCREG1, opt_ccr_mode
1402 bra comm_write_abort ; Done. Loop with timeout reset
1403 comm_write_dive_mode:
1404 call rs232_get_byte
1405 movff RCREG1, opt_dive_mode
1406 bra comm_write_abort ; Done. Loop with timeout reset
1407 comm_write_decotype:
1408 call rs232_get_byte
1409 movff RCREG1, char_I_deco_model
1410 bra comm_write_abort ; Done. Loop with timeout reset
1411 comm_write_ppo2_max:
1412 call rs232_get_byte
1413 movff RCREG1, opt_ppO2_max
1414 bra comm_write_abort ; Done. Loop with timeout reset
1415 comm_write_ppo2_min:
1416 call rs232_get_byte
1417 movff RCREG1, opt_ppO2_min
1418 bra comm_write_abort ; Done. Loop with timeout reset
1419 comm_write_ftts:
1420 call rs232_get_byte
1421 movff RCREG1, char_I_extra_time
1422 bra comm_write_abort ; Done. Loop with timeout reset
1423 comm_write_gf_low:
1424 call rs232_get_byte
1425 movff RCREG1, opt_GF_low
1426 bra comm_write_abort ; Done. Loop with timeout reset
1427 comm_write_gf_high:
1428 call rs232_get_byte
1429 movff RCREG1, opt_GF_high
1430 bra comm_write_abort ; Done. Loop with timeout reset
1431 comm_write_agf_low:
1432 call rs232_get_byte
1433 movff RCREG1, opt_aGF_low
1434 bra comm_write_abort ; Done. Loop with timeout reset
1435 comm_write_agf_high:
1436 call rs232_get_byte
1437 movff RCREG1, opt_aGF_high
1438 bra comm_write_abort ; Done. Loop with timeout reset
1439 comm_write_agf_selectable:
1440 call rs232_get_byte
1441 movff RCREG1, opt_enable_aGF
1442 bra comm_write_abort ; Done. Loop with timeout reset
1443 comm_write_saturation:
1444 call rs232_get_byte
1445 movff RCREG1, char_I_saturation_multiplier
1446 bra comm_write_abort ; Done. Loop with timeout reset
1447 comm_write_desaturation:
1448 call rs232_get_byte
1449 movff RCREG1, char_I_desaturation_multiplier
1450 bra comm_write_abort ; Done. Loop with timeout reset
1451 comm_write_last_deco:
1452 call rs232_get_byte
1453 movff RCREG1, opt_last_stop
1454 bra comm_write_abort ; Done. Loop with timeout reset
1455 comm_write_brightness:
1456 call rs232_get_byte
1457 movff RCREG1, opt_brightness
1458 bra comm_write_abort ; Done. Loop with timeout reset
1459 comm_write_units:
1460 call rs232_get_byte
1461 movff RCREG1, opt_units
1462 bra comm_write_abort ; Done. Loop with timeout reset
1463 comm_write_samplingrate:
1464 call rs232_get_byte
1465 movff RCREG1, opt_sampling_rate
1466 bra comm_write_abort ; Done. Loop with timeout reset
1467 comm_write_salinity:
1468 call rs232_get_byte
1469 movff RCREG1, opt_salinity
1470 bra comm_write_abort ; Done. Loop with timeout reset
1471 comm_write_divemode_colour:
1472 call rs232_get_byte
1473 movff RCREG1, opt_dive_color_scheme
1474 bra comm_write_abort ; Done. Loop with timeout reset
1475 comm_write_language:
1476 call rs232_get_byte
1477 movff RCREG1, opt_language
1478 bra comm_write_abort ; Done. Loop with timeout reset
1479 comm_write_date_format:
1480 call rs232_get_byte
1481 movff RCREG1, opt_dateformat
1482 bra comm_write_abort ; Done. Loop with timeout reset
1483 comm_write_compass_gain:
1484 call rs232_get_byte
1485 movff RCREG1, opt_compass_gain
1486 bra comm_write_abort ; Done. Loop with timeout reset
1134 1487
1135 ;----------------------------------------------------------------------------- 1488 ;-----------------------------------------------------------------------------
1136 1489
1137 comm_send_string: 1490 comm_send_string:
1138 movlw "n" ; send echo 1491 movlw "n" ; send echo
1149 movff RCREG1,POSTINC2 ; Store character 1502 movff RCREG1,POSTINC2 ; Store character
1150 decfsz lo,F 1503 decfsz lo,F
1151 bra comm_send_string_loop 1504 bra comm_send_string_loop
1152 comm_send_string_abort: 1505 comm_send_string_abort:
1153 STRCAT_PRINT "" ; Show the text 1506 STRCAT_PRINT "" ; Show the text
1154 bra comm_download_mode0 ; Done. Loop with timeout reset 1507 goto comm_download_mode0 ; Done. Loop with timeout reset
1155 1508
1156 ;----------------------------------------------------------------------------- 1509 ;-----------------------------------------------------------------------------
1157 1510
1158 comm_check_day: 1511 comm_check_day:
1159 movff RCREG1, day 1512 movff RCREG1, day