📄 access.lst
字号:
C51 COMPILER V7.50 ACCESS 07/28/2008 16:10:58 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE ACCESS
OBJECT MODULE PLACED IN .\REL_OUT\Access.obj
COMPILER INVOKED BY: D:\keil-701\C51\BIN\C51.EXE Access.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\REL_OUT\Ac
-cess.lst) OBJECT(.\REL_OUT\Access.obj)
line level source
1 #define __ACCESS__
2
3 #include "reg52.h"
4 #include "intrins.h"
5
6 #include "MAIN_DEF.H"
7 #include "ACCESS.h"
8 #include "CONFIG.H"
9 #include "MTV512.H"
10
11 void BitDly(void)
12 {
13 1 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
14 1 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
15 1 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
16 1 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
17 1 }
18
19 void I2CRead(unsigned char addr, unsigned char index, unsigned char count)
20 {
21 1 unsigned char n;
22 1
23 1 if (count)
24 1 {
25 2 I2CSendAddr(addr, index, 0);
26 2
27 2 I2CSendAddr(addr, 0, 1);
28 2
29 2 count = count - 1;
30 2
31 2 for (n = 0; n < count; n++) Data[n] = I2CGetByte(0);
32 2
33 2 Data[count] = I2CGetByte(1);
34 2
35 2 I2CSendStop();
36 2 }
37 1 }
38
39 void I2CWrite(unsigned char *array)
40 {
41 1 unsigned char n, len;
42 1
43 1 if (3 <= array[0])
44 1 {
45 2 len = array[0];
46 2 I2CSendAddr(array[1], array[2], 0);
47 2
48 2 for (n = 3; n < len; n++) I2CSendByte(array[n]);
49 2
50 2 I2CSendStop();
51 2 }
52 1 }
53
54
C51 COMPILER V7.50 ACCESS 07/28/2008 16:10:58 PAGE 2
55 unsigned char I2CGetByte(unsigned char ack)
56 {
57 1 unsigned char r, m;
58 1
59 1 r = 0;
60 1
61 1 for (m = 0; m < 8; m++) // Each bit at a time, MSB first
62 1 {
63 2 bIIC_SCL = 1;
64 2
65 2 BitDly(); // Delay
66 2
67 2 r = (r << 1) | bIIC_SDA;
68 2
69 2 bIIC_SCL = 0;
70 2
71 2 BitDly(); // Delay
72 2 }
73 1
74 1 // Send ACK according to 'ack'
75 1 bIIC_SDA = (bit)(ack & 0x01);
76 1 BitDly(); // Delay
77 1
78 1 bIIC_SCL = 1;
79 1 BitDly(); // Delay
80 1
81 1 bIIC_SCL = 0;
82 1 BitDly(); // Delay
83 1
84 1 bIIC_SDA = 1;
85 1
86 1 return (r);
87 1 }
88
89 void I2CSendByte(unsigned char send)
90 {
91 1 unsigned char m;
92 1
93 1 for (m = 0; m < 8; m++)
94 1 {
95 2 bIIC_SDA = (bit)(send & 0x80); // Send each bit, MSB first
96 2 BitDly();
97 2
98 2 bIIC_SCL = 1;
99 2 BitDly();
100 2
101 2 bIIC_SCL = 0;
102 2
103 2 send = send << 1;
104 2 }
105 1
106 1 bIIC_SDA = 1;
107 1 BitDly();
108 1 bIIC_SCL = 1;
109 1 BitDly();
110 1
111 1 bIIC_SCL = 0;
112 1 BitDly();
113 1 }
114
115 void I2CSendAddr(unsigned char addr, unsigned char index, unsigned char rd)
116 {
C51 COMPILER V7.50 ACCESS 07/28/2008 16:10:58 PAGE 3
117 1 bIIC_SCL = 1;
118 1 BitDly();
119 1 bIIC_SDA = 0; // Start
120 1 BitDly();
121 1
122 1 bIIC_SCL = 0;
123 1 BitDly();
124 1
125 1 I2CSendByte(addr + rd); // Send address byte
126 1
127 1 if (0 == rd) I2CSendByte(index); // Send index byte
128 1 }
129
130 void I2CSendStop(void)
131 {
132 1 bIIC_SDA = 0;
133 1 BitDly();
134 1
135 1 bIIC_SCL = 1;
136 1 BitDly();
137 1
138 1 bIIC_SDA = 1;
139 1 BitDly();
140 1 }
141
142 unsigned char RTDGetByte(void)
143 {
144 1
145 1 bRTD_SCLK = 1;
146 1 bRTD_SCLK = 0;
147 1 r0 = bRTD_SDO;
148 1
149 1 bRTD_SCLK = 1;
150 1 bRTD_SCLK = 0;
151 1 r1 = bRTD_SDO;
152 1
153 1 bRTD_SCLK = 1;
154 1 bRTD_SCLK = 0;
155 1 r2 = bRTD_SDO;
156 1
157 1 bRTD_SCLK = 1;
158 1 bRTD_SCLK = 0;
159 1 r3 = bRTD_SDO;
160 1
161 1 bRTD_SCLK = 1;
162 1 bRTD_SCLK = 0;
163 1 r4 = bRTD_SDO;
164 1
165 1 bRTD_SCLK = 1;
166 1 bRTD_SCLK = 0;
167 1 r5 = bRTD_SDO;
168 1
169 1 bRTD_SCLK = 1;
170 1 bRTD_SCLK = 0;
171 1 r6 = bRTD_SDO;
172 1
173 1 bRTD_SCLK = 1;
174 1 bRTD_SCLK = 0;
175 1 r7 = bRTD_SDO;
176 1
177 1 bRTD_SCLK = 1;
178 1
C51 COMPILER V7.50 ACCESS 07/28/2008 16:10:58 PAGE 4
179 1 return Reg;
180 1 }
181
182 void RTDSendByte(unsigned char send)
183 {
184 1
185 1 bRTD_SDI = (bit)(send & 0x01);
186 1 bRTD_SCLK = 1;
187 1 bRTD_SCLK = 0;
188 1
189 1 bRTD_SDI = (bit)(send & 0x02);
190 1 bRTD_SCLK = 1;
191 1 bRTD_SCLK = 0;
192 1
193 1 bRTD_SDI = (bit)(send & 0x04);
194 1 bRTD_SCLK = 1;
195 1 bRTD_SCLK = 0;
196 1
197 1 bRTD_SDI = (bit)(send & 0x08);
198 1 bRTD_SCLK = 1;
199 1 bRTD_SCLK = 0;
200 1
201 1 bRTD_SDI = (bit)(send & 0x10);
202 1 bRTD_SCLK = 1;
203 1 bRTD_SCLK = 0;
204 1
205 1 bRTD_SDI = (bit)(send & 0x20);
206 1 bRTD_SCLK = 1;
207 1 bRTD_SCLK = 0;
208 1
209 1 bRTD_SDI = (bit)(send & 0x40);
210 1 bRTD_SCLK = 1;
211 1 bRTD_SCLK = 0;
212 1
213 1 bRTD_SDI = (bit)(send & 0x80);
214 1 bRTD_SCLK = 1;
215 1 bRTD_SCLK = 0;
216 1
217 1 bRTD_SDI = 1;
218 1 bRTD_SCLK = 1;
219 1
220 1 }
221
222 void RTDSendAddr(unsigned char addr, unsigned char rd, unsigned char inc) // rd : 0 - Write, 1 - Read
223 {
224 1
225 1 RTDSendByte(addr);
226 1
227 1 bRTD_SDI = 1;
228 1 bRTD_SCLK = 1;
229 1 bRTD_SDI = (bit)(rd & 0x01);
230 1 bRTD_SCLK = 1;
231 1 bRTD_SCLK = 0;
232 1 bRTD_SDI = (bit)(inc & 0x01);
233 1 bRTD_SCLK = 1;
234 1 bRTD_SCLK = 0;
235 1 bRTD_SDI = 1;
236 1
237 1 }
238
239 void RTDRead(unsigned char index, unsigned char count, unsigned char inc)
240 {
C51 COMPILER V7.50 ACCESS 07/28/2008 16:10:58 PAGE 5
241 1
242 1 if (count)
243 1 {
244 2 bRTD_SCSB = 0;
245 2 RTDSendAddr(index, 1, inc);
246 2
247 2 index = 0;
248 2 do
249 2 {
250 3 Data[index++] = RTDGetByte();
251 3 }
252 2 while (--count);
253 2
254 2 bRTD_SCLK = 0;
255 2 bRTD_SCLK = 1;
256 2 bRTD_SCSB = 1;
257 2 }
258 1 }
259
260 void RTDWrite(unsigned char data *array)
261 {
262 1 unsigned char len, m;
263 1
264 1 do
265 1 {
266 2 if (0 == (array[0] & 0xfc)) return;
267 2
268 2 len = array[0] - 3;
269 2 array = array + 1;
270 2
271 2 bRTD_SCSB = 0;
272 2
273 2 if (BURST == array[0])
274 2 {
275 3 RTDSendAddr(array[1], 0, N_INC);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -