📄 iic.lst
字号:
23 =1 typedef struct{
24 =1 BYTE year;
25 =1 BYTE month;
26 =1 BYTE day;
27 =1 }DATE;
28 =1
29 =1 typedef struct{
30 =1 BYTE shiftcnt;
31 =1 BYTE funcnt;
32 =1 BYTE shiftval;
33 =1 BYTE memval;
34 =1 BYTE modeval;
35 =1 BYTE funval;
36 =1 }KEYRET;
37 =1
38 =1 /***UNIONs, STRUCTUREs***/
39 =1 typedef union UNION_LONG { // byte-addressable LONG
40 =1 DWORD L;
41 =1 BYTE B[4];
42 =1 } UNION_LONG;
43 =1
44 =1 typedef union UNION_FLOAT { // byte-addressable LONG
45 =1 FLOAT F;
46 =1 BYTE B[4];
47 =1 } UNION_FLOAT;
48 =1
49 =1 typedef union UNION_INT { // byte-addressable INT
C51 COMPILER V7.50 IIC 05/27/2006 14:01:00 PAGE 6
50 =1 WORD I;
51 =1 BYTE B[2];
52 =1 } UNION_INT;
53 =1
54 =1 /*****11.0592MHZ*****/
55 =1 #define V_TMOD 0x11
56 =1 #define V_TH0 0x4c //50ms
57 =1 #define V_TL0 0x0f
58 =1 //#define V_TH1 0xb8//20ms
59 =1 //#define V_TL1 0x00
60 =1 #define V_TH1 0xdc //10ms
61 =1 #define V_TL1 0x00
62 =1 #define V_TH2 0xff //9600 bps
63 =1 #define V_TL2 0xdb
64 =1 //#define SEC 50
65 =1 #define SEC 100
66 =1 #define N 1
67 =1
68 =1 #define LIGHT P3_7
69 =1 #define AC_DECT P1_2
70 =1 #define BAT_DECT P3_3
71 =1 #define FALSE 0
72 =1 #define TRUE 1
73 =1 #define PAND 0
74 =1 #define FOOKTIN 1
75 =1 #define LCD_MODE 0x08 //display(1:4,1/3)
76 =1 #define LCD_GLITTER 0x00 //off
77 =1 #define MAX_RECORD 0xbb8 //3000
78 =1 #define PLU_LEN 22
79 =1 #define TABLE_LEN 64
80 =1 #define RECORD_LEN 15
81 =1 /**********mode**********/
82 =1 #define Input_code_mode 1
83 =1 #define Calibration_mode 2
84 =1 #define Initialization_mode 3
85 =1 #define Sales_mode 4
86 =1 #define Total_mode 5
87 =1 #define Payback_mode 6
88 =1 #define PLU_Setup_mode 7
89 =1 #define Time_Setup_mode 8
90 =1 #define Beep_and_Light_Setup_mode 9
91 =1 #define Calculator_mode 10
92 =1 #define Reports_mode 11
93 =1 #define Download_mode 12
94 =1 #define Power_down_mode 13
95 =1 #define Print_Cancel_mode 14
96 =1 /**********state**********/
97 =1 #define WEIGHING 1
98 =1 #define NON_WEIGHING 2
99 =1 #define PAYBACK 3
100 =1
101 =1 #define PLU_EDIT 1
102 =1 #define PLU_SAVE 2
103 =1
104 =1 #define SET_BEEP 1
105 =1 #define SET_LIGHT 2
106 =1
107 =1 #define MENU_1 1
108 =1 #define MENU_1_1 11
109 =1 #define MENU_1_2 12
110 =1 #define MENU_1_2_1 121
111 =1 #define MENU_1_2_2 122
C51 COMPILER V7.50 IIC 05/27/2006 14:01:00 PAGE 7
112 =1 #define MENU_1_2_2_0 1221
113 =1 #define MENU_1_3 13
114 =1 #define MENU_1_4 14
115 =1
116 =1 #define MENU_2 2
117 =1 #define MENU_2_1 21
118 =1 #define MENU_2_2 22
119 =1 #define MENU_2_2_1 221
120 =1 #define MENU_2_2_2 222
121 =1 #define MENU_2_2_2_0 2221
122 =1 #define MENU_2_3 23
123 =1
124 =1 #define MENU_3 3
125 =1 #define MENU_3_1 31
126 =1 #define MENU_3_2 32
127 =1 #define MENU_3_2_1 321
128 =1 #define MENU_3_2_2 322
129 =1 #define MENU_3_2_2_0 3221
130 =1 #define MENU_3_3 33
131 =1
132 =1 #define EDIT_YEAR 1
133 =1 #define EDIT_MONTH 2
134 =1 #define EDIT_DAY 3
135 =1 #define EDIT_HOUR 4
136 =1 #define EDIT_MINUTE 5
137 =1 #define EDIT_SECOND 6
138 =1
139 =1 /**********sales type**********/
140 =1 #define PW 1
141 =1 #define PN 2
142 =1 #define MW 3
143 =1 #define MN 4
144 =1 #define DELE 0xaa
145 =1
146 =1 /**********print type***********/
147 =1 #define PW 1
148 =1 #define PN 2
149 =1 #define MW 3
150 =1 #define MN 4
151 =1 #define TOTAL 5
152 =1
153 =1 /**********report type**********/
154 =1 #define TOTAL_ALL_MONEY 1
155 =1 #define TOTAL_ALL_PLU_MONEY 2
156 =1 #define TOTAL_SEL_PLU_MONEY 3
157 =1 #define TOTAL_ALL_MANUL_MONEY 4
158 =1 #define TOTAL_ALL_NUMBER_MONEY 5
159 =1 #define TOTAL_ALL_WEIGHT 6
160 =1 #define TOTAL_ALL_PLU_WEIGHT 7
161 =1 #define TOTAL_SEL_PLU_WEIGHT 8
162 =1 #define TOTAL_ALL_MANUL_WEIGHT 9
163 =1 #define TOTAL_ALL_NUMBER 10
164 =1 #define TOTAL_ALL_PLU_NUMBER 11
165 =1 #define TOTAL_SEL_PLU_NUMBER 12
166 =1 #define TOTAL_ALL_MANUL_NUMBER 13
167 =1
168 =1 /********operate status********/
169 =1 #define ADD 1
170 =1 #define SUM 2
171 =1 #define PAY 3
172 =1
173 =1 /********eeprom address********/
C51 COMPILER V7.50 IIC 05/27/2006 14:01:00 PAGE 8
174 =1 #define EEPROM_ID 0
175 =1 #define Option_Param_address 2
176 =1 #define Graduation_Grade_address 3
177 =1 #define Graduation1_address 5
178 =1 #define Graduation2_address 6
179 =1 #define Max_Capacity_address 7
180 =1 #define Initial_Zero_Setting_limit_address 9
181 =1 #define Zero_Setting_and_Zero_Tracking_limit_address 10
182 =1 #define Zero_Stable_count_address 11
183 =1 #define Zero_Stable_times_address 13
184 =1 #define Weight_Stable_count_address 14
185 =1 #define Weight_Stable_times_address 16
186 =1 #define Err1_Timeout_address 17
187 =1 #define Local_Height_address 18
188 =1 #define Local_Latitude_address 20
189 =1 #define Destination_Height_address 21
190 =1 #define Destination_Latitude_address 23
191 =1 #define Soft_Ver_address 24
192 =1 #define Cal_counts_address 26
193 =1 #define Password_address 27
194 =1 #define Cal_Zero_limit_count_address 30
195 =1 #define Cal_One_count_address 36
196 =1 #define Cal_Zero_count_address 40
197 =1 #define Cal_Weight_count_address 44
198 =1 #define Logo_address 48
199 =1 #define PLU_DATA_ADR 0x40
200 =1 #define RECORD_DATA_ADR 0x2600
201 =1
202 =1 /********report save address********/
203 =1 #define PLU_no_Save_address 1
204 =1 #define Unit_Price_Save_address 3
205 =1 #define Weight_Save_address 6
206 =1 #define Quantity_Save_address 6
207 =1 #define Total_Price_Save_address 9
10 #define HIGH 1
11 #define LOW 0
12 #define SCL P1_0
13 #define SDA P1_1
14 #define Nop() _nop_()
15
16 BOOL Ack;
17
18 VOID IIC_Start()
19 {
20 1 SDA=HIGH;
21 1 Nop();
22 1 SCL=HIGH;
23 1 Nop();/*>4.7us*/
24 1 Nop();
25 1 Nop();
26 1 Nop();
27 1 Nop();
28 1 Nop();
29 1 SDA=LOW;
30 1 Nop();/*>4us*/
31 1 Nop();
32 1 Nop();
33 1 Nop();
34 1 Nop();
35 1 SCL=LOW;
36 1 Nop();/*>4.7us*/
37 1 Nop();
C51 COMPILER V7.50 IIC 05/27/2006 14:01:00 PAGE 9
38 1 Nop();
39 1 Nop();
40 1 Nop();
41 1 Nop();
42 1 }
43
44 VOID IIC_Stop()
45 {
46 1 SDA=LOW;
47 1 Nop();
48 1 SCL=HIGH;
49 1 Nop();/*>4us*/
50 1 Nop();
51 1 Nop();
52 1 Nop();
53 1 Nop();
54 1 SDA=HIGH;
55 1 Nop();
56 1 Nop();
57 1 Nop();
58 1 Nop();
59 1 }
60
61 BYTE IIC_Read()
62 {
63 1 BYTE IIC_data=0;
64 1 BYTE i;
65 1 SDA=HIGH;
66 1 for(i=0;i<8;i++)
67 1 {
68 2 Nop();
69 2 SCL=LOW;
70 2 Nop();/*>4.7us*/
71 2 Nop();
72 2 Nop();
73 2 Nop();
74 2 Nop();
75 2 Nop();
76 2 SCL=HIGH;
77 2 Nop();/*>4us*/
78 2 Nop();
79 2 IIC_data=IIC_data<<1;
80 2 if(SDA==HIGH)
81 2 IIC_data=IIC_data+1;
82 2 Nop();
83 2 Nop();
84 2 Nop();
85 2 }
86 1 SCL=LOW;
87 1 Nop();
88 1 Nop();
89 1 return(IIC_data);
90 1 }
91
92 VOID IIC_Write(BYTE IIC_data)
93 {
94 1 BYTE i;
95 1 for(i=0;i<8;i++)
96 1 {
97 2 if((IIC_data<<i)&0x80)
98 2 SDA=HIGH;
99 2 else
C51 COMPILER V7.50 IIC 05/27/2006 14:01:00 PAGE 10
100 2 SDA=LOW;
101 2 Nop();
102 2 SCL=HIGH;
103 2 Nop();/*>4us*/
104 2 Nop();
105 2 Nop();
106 2 Nop();
107 2 Nop();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -