main.lst
来自「学校水POS读卡程序」· LST 代码 · 共 1,499 行 · 第 1/5 页
LST
1,499 行
863 * Input: _50us *
864 * Output: - *
865 * *
866 * Description: *
867 * *
868 * Time delay with a resolution of 50 us. *
869 * *
870 ****************************************************************************/
871
872 void delay_50us (uchar _50us)
873 {
874 1
875 1 RCAP2LH = RCAP2_50us;
876 1 T2LH = RCAP2_50us;
877 1 ET2 = 0; // Disable timer2 interrupt
878 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
879 1
880 1 while (_50us--)
881 1 {
882 2 while (!TF2);
883 2 TF2 = FALSE;
884 2 }
885 1
886 1 TR2 = FALSE;
887 1
888 1 }
889
890
891 /****************************************************************************
892 * *
893 * Function: delay_1ms *
894 * *
895 * Input: _1ms *
896 * Output: - *
897 * *
898 * Description: *
899 * *
900 * Time delay with a resolution of 1 ms. *
901 * *
902 ****************************************************************************/
903
904 void delay_1ms (uchar _1ms)
905 {
906 1
907 1 RCAP2LH = RCAP2_1ms;
908 1 T2LH = RCAP2_1ms;
909 1 ET2 = 0; // Disable timer2 interrupt
910 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
911 1
912 1 while (_1ms--)
913 1 {
914 2 while (!TF2);
915 2 TF2 = FALSE;
916 2 }
917 1 TR2 = FALSE;
918 1
919 1 }
920
921
922 /****************************************************************************
C51 COMPILER V6.23a MAIN 08/03/2004 08:47:24 PAGE 16
923 * *
924 * Function: delay_10ms *
925 * *
926 * Input: _10ms *
927 * Output: - *
928 * *
929 * Description: *
930 * *
931 * Time delay with a resolution of 10 ms. *
932 * *
933 ****************************************************************************/
934
935 void delay_10ms (uint _10ms)
936 {
937 1
938 1 RCAP2LH = RCAP2_10ms;
939 1 T2LH = RCAP2_10ms;
940 1 ET2 = 0; // Disable timer2 interrupt
941 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
942 1
943 1
944 1 while (_10ms--)
945 1 {
946 2 while (!TF2)
947 2 {
948 3 if (CmdValid || CmdReceived)
949 3 {
950 4 TR2 = FALSE;
951 4 TF2 = FALSE;
952 4 return;
953 4 }
954 3 }
955 2 TF2 = FALSE;
956 2 }
957 1 TR2 = FALSE;
958 1
959 1 }
960
961
962
963 void test_10ms(uint n_10ms)
964 {
965 1
966 1 RCAP2LH = RCAP2_10ms;
967 1 T2LH = RCAP2_10ms;
968 1 ET2 = 0; // Disable timer2 interrupt
969 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
970 1
971 1
972 1 while (n_10ms--)
973 1 {
974 2 while (!TF2)
975 2 {
976 3 if (CmdValid || CmdReceived)
977 3 {
978 4 TR2 = FALSE;
979 4 TF2 = FALSE;
980 4 return;
981 4 }
982 3 }
983 2 TF2 = FALSE;
984 2 }
C51 COMPILER V6.23a MAIN 08/03/2004 08:47:24 PAGE 17
985 1 TR2 = FALSE;
986 1
987 1 }
988
989
990
991
992
993
994
995 #ifdef NOP_DELAY
/****************************************************************************
* *
* Function: delay_50us_NOP *
* *
* Input: - *
* Output: - *
* *
* Description: 延时函数 *
* *
* *
* *
****************************************************************************/
void delay_50us_NOP (void)
{
uchar i;
for(i=0; i<81; i++) _nop_();
}
#endif
1018
1019
1020 /****************************************************************************
1021 * *
1022 * Function: delay_8us_NOP *
1023 * *
1024 * Input: - *
1025 * Output: - *
1026 * *
1027 * Description: *
1028 * *
1029 * *
1030 ****************************************************************************/
1031
1032 void delay_8us_NOP (void)
1033 {
1034 1 uchar i;
1035 1
1036 1 for(i=0; i<14; i++) _nop_();
1037 1 }
1038
1039
1040 /*****************************************************
1041
1042
1043 *******************************************************/
1044 void RingOn (void)
1045 {
1046 1 BEEP = 0;
C51 COMPILER V6.23a MAIN 08/03/2004 08:47:24 PAGE 18
1047 1 delay_10ms(2);
1048 1 BEEP = 1;
1049 1 delay_10ms(2);
1050 1 BEEP = 0;
1051 1 delay_10ms(2);
1052 1 BEEP = 1;
1053 1 delay_10ms(2);
1054 1 BEEP = 0;
1055 1 delay_10ms(2);
1056 1 BEEP = 1;
1057 1 }
1058
1059
1060 #pragma aregs
1061
1062
1063 /****************************************************************************
1064 * *
1065 * Function: xtoa_h *
1066 * *
1067 * Input: _byte *
1068 * Output: ASCII High-Nibble *
1069 * *
1070 * Description: *
1071 * *
1072 * Wandelt das High-Nibble des 乥ergebenen Bytes in ein ASCII-Zeichen um. *
1073 * *
1074 ****************************************************************************/
1075
1076 uchar xtoa_h (uchar _byte)
1077 {
1078 1 uchar nibble = _byte >> 4;
1079 1
1080 1 return ((nibble > 9)? nibble + 'A' - 10 : nibble + '0');
1081 1 }
1082
1083
1084 /****************************************************************************
1085 * *
1086 * Function: xtoa_l *
1087 * *
1088 * Input: _byte *
1089 * Output: ASCII Low-Nibble *
1090 * *
1091 * Description: *
1092 * *
1093 * Wandelt das Low-Nibble des 乥ergebenen Bytes in ein ASCII-Zeichen um. *
1094 * *
1095 ****************************************************************************/
1096
1097 uchar xtoa_l (uchar _byte)
1098 {
1099 1 uchar nibble = _byte & 0x0F;
1100 1
1101 1 return ((nibble > 9)? nibble + 'A' - 10 : nibble + '0');
1102 1 }
1103
1104
1105 /****************************************************************************
1106 * *
1107 * Function: isr_timer0 *
1108 * *
C51 COMPILER V6.23a MAIN 08/03/2004 08:47:24 PAGE 19
1109 * Input: - *
1110 * Output: - *
1111 * *
1112 * Description: *
1113 * *
1114 * *
1115 ****************************************************************************/
1116
1117 void isr_timer0 (void) interrupt 1 using 2
1118 {
1119 1 if (Timer0Cnt)
1120 1 {
1121 2 --Timer0Cnt;
1122 2 }
1123 1 else
1124 1 {
1125 2 STOP_T0();
1126 2
1127 2 #ifdef AUTODELAY
1128 2 if (DelayRate < MAXDELAYRATE && CmdCnt > 0)
1129 2 {
1130 3 DelayRate++;
1131 3 DelayRateLocked = FALSE;
1132 3 }
1133 2 #endif
1134 2
1135 2 RecvState = RECV_STX;
1136 2
1137 2 if (!SendReady && LLfReady)
1138 2 {
1139 3 if (RepCnt < MAXREPCNT)
1140 3 {
1141 4 RepCnt++;
1142 4 CALL_isr_UART();
1143 4 }
1144 3 else
1145 3 {
1146 4 RepCnt = 0;
1147 4 Quit = FALSE;
1148 4 SendReady = TRUE;
1149 4 }
1150 3 }
1151 2 }
1152 1 }
1153
1154
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?