comparison src/comm.asm @ 79:0fc8113ddf6d

new command in download mode: "r" - read setting
author mh@mh-THINK.localdomain
date Thu, 27 Feb 2014 12:56:52 +0100
parents 50697bd41c54
children db920ca01491
comparison
equal deleted inserted replaced
78:668b432dcae9 79:0fc8113ddf6d
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 24
25 extern testloop,new_battery_menu,restart,option_reset_all 25 extern testloop,new_battery_menu,restart,option_reset_all
26 extern char_I_deco_gas_change, char_I_dil_change, char_I_setpoint_cbar, char_I_setpoint_change
27 extern char_I_deco_model, char_I_extra_time, char_I_saturation_multiplier, char_I_desaturation_multiplier
26 28
27 #DEFINE timeout_comm_pre_mode .120 ; Pre-loop 29 #DEFINE timeout_comm_pre_mode .120 ; Pre-loop
28 #DEFINE timeout_comm_mode .120 ; Download mode 30 #DEFINE timeout_comm_mode .120 ; Download mode
29 #DEFINE timeout_service_mode .120 ; Service mode 31 #DEFINE timeout_service_mode .120 ; Service mode
30 32
254 clrf EEDATA 256 clrf EEDATA
255 write_int_eeprom .4 257 write_int_eeprom .4
256 write_int_eeprom .5 258 write_int_eeprom .5
257 write_int_eeprom .6 259 write_int_eeprom .6
258 write_int_eeprom .2 ; Also, delete total dive counter 260 write_int_eeprom .2 ; Also, delete total dive counter
259 write_int_eeprom .3 261 write_int_eeprom .3
262 write_int_eeprom .15
263 write_int_eeprom .16 ; And the backup counter, too
260 call ext_flash_erase_logbook ; And complete logbook (!) 264 call ext_flash_erase_logbook ; And complete logbook (!)
261 bra comm_download_mode0 ; Done. 265 bra comm_download_mode0 ; Done.
262 266
263 ;----------------------------------------------------------------------------- 267 ;-----------------------------------------------------------------------------
264 comm_reset_battery_gauge: ; Resets battery gauge registers 268 comm_reset_battery_gauge: ; Resets battery gauge registers
473 bra comm_send_string ; Send a 15byte string to the screen 477 bra comm_send_string ; Send a 15byte string to the screen
474 movlw "l" 478 movlw "l"
475 cpfseq RCREG1 479 cpfseq RCREG1
476 bra $+4 480 bra $+4
477 call TFT_dump_screen ; Dump the screen contents 481 call TFT_dump_screen ; Dump the screen contents
482 movlw "r"
483 cpfseq RCREG1
484 bra $+4
485 bra comm_read_setting ; Read a setting (And send via USB)
486
478 487
479 btfss comm_service_enabled ; Done for Download mode 488 btfss comm_service_enabled ; Done for Download mode
480 bra comm_download_mode0 ; Loop with timeout reset 489 bra comm_download_mode0 ; Loop with timeout reset
481 490
482 movlw 0x20 491 movlw 0x20
509 bra comm_send_firmware ; sends firmware from external flash from 0x3E0000 to 0x3FD000 (118784bytes) via comm 518 bra comm_send_firmware ; sends firmware from external flash from 0x3E0000 to 0x3FD000 (118784bytes) via comm
510 movlw "t" 519 movlw "t"
511 cpfseq RCREG1 520 cpfseq RCREG1
512 bra $+4 521 bra $+4
513 goto testloop ; Start raw-data testloop 522 goto testloop ; Start raw-data testloop
514 movlw "r" 523 movlw "x"
515 cpfseq RCREG1 524 cpfseq RCREG1
516 bra $+4 525 bra $+4
517 call option_reset_all ; Reset all options to factory default. 526 call option_reset_all ; Reset all options to factory default.
518 movlw 0xC1 527 movlw 0xC1
519 cpfseq RCREG1 528 cpfseq RCREG1
781 cpfseq ext_flash_address+2 790 cpfseq ext_flash_address+2
782 bra comm_send_dive_profile 791 bra comm_send_dive_profile
783 792
784 call rs232_wait_tx ; Wait for UART 793 call rs232_wait_tx ; Wait for UART
785 bra comm_download_mode0 ; Done. Loop with timeout reset 794 bra comm_download_mode0 ; Done. Loop with timeout reset
795
796 ;-----------------------------------------------------------------------------
797
798 comm_read_setting:
799 movlw "r"
800 movwf TXREG1
801 call rs232_get_byte
802 btfsc rs232_recieve_overflow ; Got byte?
803 bra comm_read_abort ; No, abort!
804 call rs232_wait_tx ; Wait for UART
805 movf RCREG1,W ; Copy
806 bz comm_read_unused ; RCREG1=0
807 dcfsnz WREG
808 bra comm_read_unused ; RCREG1=1
809 dcfsnz WREG
810 bra comm_read_unused ; RCREG1=2
811 dcfsnz WREG
812 bra comm_read_unused ; RCREG1=3
813 dcfsnz WREG
814 bra comm_read_unused ; RCREG1=4
815 dcfsnz WREG
816 bra comm_read_unused ; RCREG1=5
817 dcfsnz WREG
818 bra comm_read_unused ; RCREG1=6
819 dcfsnz WREG
820 bra comm_read_unused ; RCREG1=7
821 dcfsnz WREG
822 bra comm_read_unused ; RCREG1=8
823 dcfsnz WREG
824 bra comm_read_unused ; RCREG1=9
825 dcfsnz WREG
826 bra comm_read_unused ; RCREG1=10
827 dcfsnz WREG
828 bra comm_read_unused ; RCREG1=11
829 dcfsnz WREG
830 bra comm_read_unused ; RCREG1=12
831 dcfsnz WREG
832 bra comm_read_unused ; RCREG1=13
833 dcfsnz WREG
834 bra comm_read_unused ; RCREG1=14
835 dcfsnz WREG
836 bra comm_read_unused ; RCREG1=15
837 dcfsnz WREG
838 bra comm_read_gas1 ; RCREG1=0x10
839 dcfsnz WREG
840 bra comm_read_gas2 ; RCREG1=0x11
841 dcfsnz WREG
842 bra comm_read_gas3 ; RCREG1=0x12
843 dcfsnz WREG
844 bra comm_read_gas4 ; RCREG1=0x13
845 dcfsnz WREG
846 bra comm_read_gas5 ; RCREG1=0x14
847 dcfsnz WREG
848 bra comm_read_dil1 ; RCREG1=0x15
849 dcfsnz WREG
850 bra comm_read_dil2 ; RCREG1=0x16
851 dcfsnz WREG
852 bra comm_read_dil3 ; RCREG1=0x17
853 dcfsnz WREG
854 bra comm_read_dil4 ; RCREG1=0x18
855 dcfsnz WREG
856 bra comm_read_dil5 ; RCREG1=0x19
857 dcfsnz WREG
858 bra comm_read_sp1 ; RCREG1=0x1A
859 dcfsnz WREG
860 bra comm_read_sp2 ; RCREG1=0x1B
861 dcfsnz WREG
862 bra comm_read_sp3 ; RCREG1=0x1C
863 dcfsnz WREG
864 bra comm_read_sp4 ; RCREG1=0x1D
865 dcfsnz WREG
866 bra comm_read_sp5 ; RCREG1=0x1E
867 dcfsnz WREG
868 bra comm_read_ccr_mode ; RCREG1=0x1F
869 dcfsnz WREG
870 bra comm_read_dive_mode ; RCREG1=0x20
871 dcfsnz WREG
872 bra comm_read_decotype ; RCREG1=0x21
873 dcfsnz WREG
874 bra comm_read_ppo2_max ; RCREG1=0x22
875 dcfsnz WREG
876 bra comm_read_ppo2_min ; RCREG1=0x23
877 dcfsnz WREG
878 bra comm_read_ftts ; RCREG1=0x24
879 dcfsnz WREG
880 bra comm_read_gf_low ; RCREG1=0x25
881 dcfsnz WREG
882 bra comm_read_gf_high ; RCREG1=0x26
883 dcfsnz WREG
884 bra comm_read_agf_low ; RCREG1=0x27
885 dcfsnz WREG
886 bra comm_read_agf_high ; RCREG1=0x28
887 dcfsnz WREG
888 bra comm_read_agf_selectable ; RCREG1=0x29
889 dcfsnz WREG
890 bra comm_read_saturation ; RCREG1=0x2A
891 dcfsnz WREG
892 bra comm_read_desaturation ; RCREG1=0x2B
893 dcfsnz WREG
894 bra comm_read_last_deco ; RCREG1=0x2C
895 dcfsnz WREG
896 bra comm_read_brightness ; RCREG1=0x2D
897 dcfsnz WREG
898 bra comm_read_units ; RCREG1=0x2E
899 dcfsnz WREG
900 bra comm_read_samplingrate ; RCREG1=0x2F
901 dcfsnz WREG
902 bra comm_read_salinity ; RCREG1=0x30
903 dcfsnz WREG
904 bra comm_read_divemode_colour ; RCREG1=0x31
905 dcfsnz WREG
906 bra comm_read_language ; RCREG1=0x32
907 dcfsnz WREG
908 bra comm_read_date_format ; RCREG1=0x33
909 dcfsnz WREG
910 bra comm_read_compass_gain ; RCREG1=0x34
911
912
913
914 comm_read_unused:
915 comm_read_abort:
916 bra comm_download_mode0 ; Done. Loop with timeout reset
917
918 comm_read_setting_wait:
919 call rs232_wait_tx ; Wait for UART
920 return
921
922 comm_read_gas1:
923 movff opt_gas_O2_ratio+0, TXREG1
924 rcall comm_read_setting_wait ; Wait for UART
925 movff opt_gas_He_ratio+0, TXREG1
926 rcall comm_read_setting_wait ; Wait for UART
927 movff opt_gas_type+0, TXREG1
928 rcall comm_read_setting_wait ; Wait for UART
929 movff char_I_deco_gas_change+0,TXREG1
930 bra comm_download_mode0 ; Done. Loop with timeout reset
931 comm_read_gas2:
932 movff opt_gas_O2_ratio+1, TXREG1
933 rcall comm_read_setting_wait ; Wait for UART
934 movff opt_gas_He_ratio+1, TXREG1
935 rcall comm_read_setting_wait ; Wait for UART
936 movff opt_gas_type+1, TXREG1
937 rcall comm_read_setting_wait ; Wait for UART
938 movff char_I_deco_gas_change+1,TXREG1
939 bra comm_download_mode0 ; Done. Loop with timeout reset
940 comm_read_gas3:
941 movff opt_gas_O2_ratio+2, TXREG1
942 rcall comm_read_setting_wait ; Wait for UART
943 movff opt_gas_He_ratio+2, TXREG1
944 rcall comm_read_setting_wait ; Wait for UART
945 movff opt_gas_type+2, TXREG1
946 rcall comm_read_setting_wait ; Wait for UART
947 movff char_I_deco_gas_change+2,TXREG1
948 bra comm_download_mode0 ; Done. Loop with timeout reset
949 comm_read_gas4:
950 movff opt_gas_O2_ratio+3, TXREG1
951 rcall comm_read_setting_wait ; Wait for UART
952 movff opt_gas_He_ratio+3, TXREG1
953 rcall comm_read_setting_wait ; Wait for UART
954 movff opt_gas_type+3, TXREG1
955 rcall comm_read_setting_wait ; Wait for UART
956 movff char_I_deco_gas_change+3,TXREG1
957 bra comm_download_mode0 ; Done. Loop with timeout reset
958 comm_read_gas5:
959 movff opt_gas_O2_ratio+4, TXREG1
960 rcall comm_read_setting_wait ; Wait for UART
961 movff opt_gas_He_ratio+4, TXREG1
962 rcall comm_read_setting_wait ; Wait for UART
963 movff opt_gas_type+4, TXREG1
964 rcall comm_read_setting_wait ; Wait for UART
965 movff char_I_deco_gas_change+4,TXREG1
966 bra comm_download_mode0 ; Done. Loop with timeout reset
967
968 comm_read_dil1:
969 movff opt_dil_O2_ratio+0, TXREG1
970 rcall comm_read_setting_wait ; Wait for UART
971 movff opt_dil_He_ratio+0, TXREG1
972 rcall comm_read_setting_wait ; Wait for UART
973 movff opt_dil_type+0, TXREG1
974 rcall comm_read_setting_wait ; Wait for UART
975 movff char_I_dil_change+0,TXREG1
976 bra comm_download_mode0 ; Done. Loop with timeout reset
977 comm_read_dil2:
978 movff opt_dil_O2_ratio+1, TXREG1
979 rcall comm_read_setting_wait ; Wait for UART
980 movff opt_dil_He_ratio+1, TXREG1
981 rcall comm_read_setting_wait ; Wait for UART
982 movff opt_dil_type+1, TXREG1
983 rcall comm_read_setting_wait ; Wait for UART
984 movff char_I_dil_change+1,TXREG1
985 bra comm_download_mode0 ; Done. Loop with timeout reset
986 comm_read_dil3:
987 movff opt_dil_O2_ratio+2, TXREG1
988 rcall comm_read_setting_wait ; Wait for UART
989 movff opt_dil_He_ratio+2, TXREG1
990 rcall comm_read_setting_wait ; Wait for UART
991 movff opt_dil_type+2, TXREG1
992 rcall comm_read_setting_wait ; Wait for UART
993 movff char_I_dil_change+2,TXREG1
994 bra comm_download_mode0 ; Done. Loop with timeout reset
995 comm_read_dil4:
996 movff opt_dil_O2_ratio+3, TXREG1
997 rcall comm_read_setting_wait ; Wait for UART
998 movff opt_dil_He_ratio+3, TXREG1
999 rcall comm_read_setting_wait ; Wait for UART
1000 movff opt_dil_type+3, TXREG1
1001 rcall comm_read_setting_wait ; Wait for UART
1002 movff char_I_dil_change+3,TXREG1
1003 bra comm_download_mode0 ; Done. Loop with timeout reset
1004 comm_read_dil5:
1005 movff opt_dil_O2_ratio+4, TXREG1
1006 rcall comm_read_setting_wait ; Wait for UART
1007 movff opt_dil_He_ratio+4, TXREG1
1008 rcall comm_read_setting_wait ; Wait for UART
1009 movff opt_dil_type+4, TXREG1
1010 rcall comm_read_setting_wait ; Wait for UART
1011 movff char_I_dil_change+4,TXREG1
1012 bra comm_download_mode0 ; Done. Loop with timeout reset
1013
1014 comm_read_sp1:
1015 movff char_I_setpoint_cbar+0, TXREG1
1016 rcall comm_read_setting_wait ; Wait for UART
1017 movff char_I_setpoint_change+0, TXREG1
1018 rcall comm_read_setting_wait ; Wait for UART
1019 bra comm_download_mode0 ; Done. Loop with timeout reset
1020 comm_read_sp2:
1021 movff char_I_setpoint_cbar+1, TXREG1
1022 rcall comm_read_setting_wait ; Wait for UART
1023 movff char_I_setpoint_change+1, TXREG1
1024 rcall comm_read_setting_wait ; Wait for UART
1025 bra comm_download_mode0 ; Done. Loop with timeout reset
1026 comm_read_sp3:
1027 movff char_I_setpoint_cbar+2, TXREG1
1028 rcall comm_read_setting_wait ; Wait for UART
1029 movff char_I_setpoint_change+2, TXREG1
1030 rcall comm_read_setting_wait ; Wait for UART
1031 bra comm_download_mode0 ; Done. Loop with timeout reset
1032 comm_read_sp4:
1033 movff char_I_setpoint_cbar+3, TXREG1
1034 rcall comm_read_setting_wait ; Wait for UART
1035 movff char_I_setpoint_change+3, TXREG1
1036 rcall comm_read_setting_wait ; Wait for UART
1037 bra comm_download_mode0 ; Done. Loop with timeout reset
1038 comm_read_sp5:
1039 movff char_I_setpoint_cbar+4, TXREG1
1040 rcall comm_read_setting_wait ; Wait for UART
1041 movff char_I_setpoint_change+4, TXREG1
1042 rcall comm_read_setting_wait ; Wait for UART
1043 bra comm_download_mode0 ; Done. Loop with timeout reset
1044
1045 comm_read_ccr_mode:
1046 movff opt_ccr_mode, TXREG1
1047 rcall comm_read_setting_wait ; Wait for UART
1048 bra comm_download_mode0 ; Done. Loop with timeout reset
1049 comm_read_dive_mode:
1050 movff opt_dive_mode, TXREG1
1051 rcall comm_read_setting_wait ; Wait for UART
1052 bra comm_download_mode0 ; Done. Loop with timeout reset
1053 comm_read_decotype:
1054 movff char_I_deco_model, TXREG1
1055 rcall comm_read_setting_wait ; Wait for UART
1056 bra comm_download_mode0 ; Done. Loop with timeout reset
1057 comm_read_ppo2_max:
1058 movff opt_ppO2_max, TXREG1
1059 rcall comm_read_setting_wait ; Wait for UART
1060 bra comm_download_mode0 ; Done. Loop with timeout reset
1061 comm_read_ppo2_min:
1062 movff opt_ppO2_min, TXREG1
1063 rcall comm_read_setting_wait ; Wait for UART
1064 bra comm_download_mode0 ; Done. Loop with timeout reset
1065 comm_read_ftts:
1066 movff char_I_extra_time, TXREG1
1067 rcall comm_read_setting_wait ; Wait for UART
1068 bra comm_download_mode0 ; Done. Loop with timeout reset
1069 comm_read_gf_low:
1070 movff opt_GF_low, TXREG1
1071 rcall comm_read_setting_wait ; Wait for UART
1072 bra comm_download_mode0 ; Done. Loop with timeout reset
1073 comm_read_gf_high:
1074 movff opt_GF_high, TXREG1
1075 rcall comm_read_setting_wait ; Wait for UART
1076 bra comm_download_mode0 ; Done. Loop with timeout reset
1077 comm_read_agf_low:
1078 movff opt_aGF_low, TXREG1
1079 rcall comm_read_setting_wait ; Wait for UART
1080 bra comm_download_mode0 ; Done. Loop with timeout reset
1081 comm_read_agf_high:
1082 movff opt_aGF_high, TXREG1
1083 rcall comm_read_setting_wait ; Wait for UART
1084 bra comm_download_mode0 ; Done. Loop with timeout reset
1085 comm_read_agf_selectable:
1086 movff opt_enable_aGF, TXREG1
1087 rcall comm_read_setting_wait ; Wait for UART
1088 bra comm_download_mode0 ; Done. Loop with timeout reset
1089 comm_read_saturation:
1090 movff char_I_saturation_multiplier, TXREG1
1091 rcall comm_read_setting_wait ; Wait for UART
1092 bra comm_download_mode0 ; Done. Loop with timeout reset
1093 comm_read_desaturation:
1094 movff char_I_desaturation_multiplier, TXREG1
1095 rcall comm_read_setting_wait ; Wait for UART
1096 bra comm_download_mode0 ; Done. Loop with timeout reset
1097 comm_read_last_deco:
1098 movff opt_last_stop, TXREG1
1099 rcall comm_read_setting_wait ; Wait for UART
1100 bra comm_download_mode0 ; Done. Loop with timeout reset
1101 comm_read_brightness:
1102 movff opt_brightness, TXREG1
1103 rcall comm_read_setting_wait ; Wait for UART
1104 bra comm_download_mode0 ; Done. Loop with timeout reset
1105 comm_read_units:
1106 movff opt_units, TXREG1
1107 rcall comm_read_setting_wait ; Wait for UART
1108 bra comm_download_mode0 ; Done. Loop with timeout reset
1109 comm_read_samplingrate:
1110 movff opt_sampling_rate, TXREG1
1111 rcall comm_read_setting_wait ; Wait for UART
1112 bra comm_download_mode0 ; Done. Loop with timeout reset
1113 comm_read_salinity:
1114 movff opt_salinity, TXREG1
1115 rcall comm_read_setting_wait ; Wait for UART
1116 bra comm_download_mode0 ; Done. Loop with timeout reset
1117 comm_read_divemode_colour:
1118 movff opt_dive_color_scheme, TXREG1
1119 rcall comm_read_setting_wait ; Wait for UART
1120 bra comm_download_mode0 ; Done. Loop with timeout reset
1121 comm_read_language:
1122 movff opt_language, TXREG1
1123 rcall comm_read_setting_wait ; Wait for UART
1124 bra comm_download_mode0 ; Done. Loop with timeout reset
1125 comm_read_date_format:
1126 movff opt_dateformat, TXREG1
1127 rcall comm_read_setting_wait ; Wait for UART
1128 bra comm_download_mode0 ; Done. Loop with timeout reset
1129 comm_read_compass_gain:
1130 movff opt_compass_gain, TXREG1
1131 rcall comm_read_setting_wait ; Wait for UART
1132 bra comm_download_mode0 ; Done. Loop with timeout reset
1133
786 1134
787 ;----------------------------------------------------------------------------- 1135 ;-----------------------------------------------------------------------------
788 1136
789 comm_send_string: 1137 comm_send_string:
790 movlw "n" ; send echo 1138 movlw "n" ; send echo