?? exp.lst
字號:
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE EXP
OBJECT MODULE PLACED IN exp.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE exp.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*=====================================================================
2 *
3 * nRF24E1-Quick-Dev快速開發(fā)系統(tǒng)源代碼
4 * 2003.7.1
5 * 功能:
6 * 1.nRF24E1的初始化控制
7 * 2.nRF24E1的數(shù)據(jù)發(fā)射與數(shù)據(jù)接收
8 * 3.串口通信
9 * 4.由 Keil C51 V6.10 and V7.05 編譯通過
10 *
11 * 迅通科技保留版權(quán)
12 * 版本: 1.1
13 *
14 *==============================================================================
15 */
16 #include <reg24e1.h>
17 #include <intrins.h>
18 #include <absacc.h>
19 #include "ISD51.h"
20 /* S1-S4 */
21 sbit S1 = P0^3;
22 sbit S2 = P0^0;
23 sbit S3 = P1^1;
24 sbit S4 = P1^0;
25
26 /* LED1-LED4 */
27 sbit LED1 = P0^7;
28 sbit LED2 = P0^6;
29 sbit LED3 = P0^5;
30 sbit LED4 = P0^4;
31
32 unsigned char bdata KeyByte;
33 sbit L1 = KeyByte^0;
34 sbit L2 = KeyByte^1;
35 sbit L3 = KeyByte^2;
36 sbit L4 = KeyByte^3;
37
38 struct RFConfig
39 {
40 unsigned char n;
41 unsigned char buf[15];
42 };
43
44 typedef struct RFConfig RFConfig;
45
46 #define ADDR_INDEX 8 // Index to address bytes in RFConfig.buf
47 #define ADDR_COUNT 4 // Number of address bytes
48
49
50 const RFConfig tconf =
51 {
52 15,
53 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0xaa, 0xbb, 0x12, 0x34, 0x83, 0x4f, 0x04
55 };
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 2
56
57 const RFConfig rconf =
58 {
59 15,
60 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0xaa, 0xbb, 0x12, 0x34, 0x83, 0x4f, 0x05
62 };
63
64 void Delay100us(volatile unsigned char n)
65 {
66 1 unsigned char i;
67 1 while(n--)
68 1 for(i=0;i<35;i++)
69 1 ;
70 1 }
71
72 void Delayms(volatile unsigned char n)
73 {
74 1 unsigned char j;
75 1 while(n--)
76 1 for(j=0;j<10;j++)
77 1 Delay100us(10);
78 1
79 1 }
80
81 unsigned char SpiReadWrite(unsigned char b)
82 {
83 1 EXIF &= ~0x20; // Clear SPI interrupt
84 1 SPI_DATA = b; // Move byte to send to SPI data register
85 1 while((EXIF & 0x20) == 0x00) // Wait until SPI hs finished transmitting
86 1 ;
87 1 return SPI_DATA;
88 1 }
89
90 void InitADC(void)
91 {
92 1 ADCCON = 0x20; // Channel 0, NPD=1, ADCRUN=0, EXTREF=0
93 1 ADCSTATIC &= 0x1c;
94 1 ADCSTATIC |= 0x03; // 12bit
95 1 ADCCON &= ~0x80; // Start..
96 1 ADCCON |= 0x80; // ..new conversion
97 1 }
98
99 void InitPWM(void)
100 {
101 1 P0_ALT = 0x80; // Enable PWM output
102 1 PWMCON = 0xc0; // Enable 8 bit PWM with minimum prescaler
103 1 }
104
105 unsigned char ReceivePacket()
106 {
107 1 unsigned char b;
108 1 CE = 1;
109 1 while(DR1 == 0)
110 1 ;
111 1 b = SpiReadWrite(0);
112 1 CE = 0;
113 1 return b;
114 1 }
115
116 void TransmitPacket(unsigned char b)
117 {
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 3
118 1 unsigned char i;
119 1 CE = 1;
120 1 Delay100us(0);
121 1 for(i=0;i<ADDR_COUNT;i++)
122 1 SpiReadWrite(tconf.buf[ADDR_INDEX+i]);
123 1 SpiReadWrite(b);
124 1 CE = 0;
125 1 Delay100us(3); // Wait ~300us
126 1 }
127
128 unsigned char ReadADC(void)
129 {
130 1 unsigned char b;
131 1
132 1 while((EXIF & 0x10) == 0) // Wait until ADC conversion complete
133 1 ;
134 1 EXIF &= ~0x10; // Clear ADC completion bit
135 1 b = ADCDATAH; // Read ADC data
136 1 ADCCON &= ~0x80; // Start..
137 1 ADCCON |= 0x80; // ..new conversion
138 1 return b;
139 1 }
140
141 void WritePWM(unsigned char b)
142 {
143 1 PWMDUTY = b;
144 1 }
145
146 void PutChar0(char c)
147 {
148 1 while(!TI)
149 1 ;
150 1 TI = 0;
151 1 SBUF = c;
152 1 }
153
154 void PutString(const char *s)
155 {
156 1 while(*s != 0)
157 1 PutChar0(*s++);
158 1 }
159
160 void Init_Receiver(void)
161 {
162 1 unsigned char b;
163 1
164 1 CS = 1;
165 1 Delay100us(0);
166 1 for(b=0;b<rconf.n;b++)
167 1 {
168 2 SpiReadWrite(rconf.buf[b]);
169 2 }
170 1 CS = 0;
171 1
172 1 CE = 1;
173 1 }
174
175 void Receiver(void)
176 {
177 1 unsigned char b;
178 1 CS = 1;
179 1 Delay100us(0);
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 4
180 1 for(b=0;b<rconf.n;b++)
181 1 {
182 2 SpiReadWrite(rconf.buf[b]);
183 2 }
184 1 CS = 0;
185 1 for(;;)
186 1 {
187 2 b = ReceivePacket();
188 2 PutChar0(b);
189 2 // WritePWM(b);
190 2 }
191 1 }
192
193 void Transmitter(void)
194 {
195 1 unsigned char b;
196 1
197 1 CS = 1;
198 1 Delay100us(0);
199 1 for(b=0;b<tconf.n;b++)
200 1 {
201 2 SpiReadWrite(tconf.buf[b]);
202 2 }
203 1 CS = 0;
204 1 // for(;;)
205 1 // {
206 1 // b = ReadADC(); // Read ADC
207 1 // b= KeyByte;
208 1 b= 0x55;
209 1 PutChar0(b); // To serial port
210 1 TransmitPacket(b); // Transmit data
211 1 // }
212 1 }
213 void light(void)
214 {LED1=0;
215 1 LED2=0;
216 1 LED3=0;
217 1 LED4=0;
218 1 }
219
220 void KeyScan(void)
221 {
222 1
223 1 if (S1==0) //switch 1 haveing been pushed
224 1 {
225 2 L1=0;
226 2 light(); // ON LED1
227 2 }
228 1 if (S2==0) //switch 1 haveing been pushed
229 1 {
230 2 L2=0;
231 2 light(); // ON LED2
232 2 }
233 1 if (S3==0) //switch 1 haveing been pushed
234 1 {
235 2 L3=0;
236 2 light(); // ON LED3
237 2 }
238 1 if (S4==0) //switch 1 haveing been pushed
239 1 {
240 2 L4=0;
241 2 light(); // ON LED4
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 5
242 2 }
243 1
244 1 }
245
246 void Init(void)
247 {
248 1
249 1 // Port ini
250 1 P0_ALT = 0x06; // Select alternate functions on pins P0.1 and P0.2, TXD RXD
251 1 P0_DIR = 0x09; // P0.0, P0.3 is input(S1, S2), the rest output
252 1 P0 = 0xF0; // P0.7-P0.4 = 1 for OFF LED1-LED4
253 1 P1_DIR = 0x03; // P0.0, P0.3 is input(S3, S4),
254 1
255 1 LED1=1;
256 1 LED2=1;
257 1 LED3=1;
258 1 LED4=1;
259 1
260 1 PWR_UP = 1; // Turn on Radio
261 1 Delay100us(30); // Wait > 3ms
262 1 SPICLK = 0; // Max SPI clock (XTAL/8)
263 1 SPI_CTRL = 0x02; // Connect internal SPI controller to Radio
264 1
265 1 // serial communication ini
266 1 T2CON = 0x34; /* Use Timer 2 as baudrate generator */
267 1
268 1 RCAP2H = 0xFF;
269 1 RCAP2L = 0xF7; //* 57600 baud @ 16MHz
270 1 CKCON |= 0x10; // T1M=1 (/4 timer clock)
271 1 SCON = 0x52; // Serial mode1, enable receiver
272 1
273 1 EA = 1; /* Enable global interrupt flag */
274 1 }
275
276
277
278 void main(void)
279 {
280 1 Init();
281 1 KeyByte=0xff;
282 1 // PutString("Hello World!\n");
283 1 // Receiver();
284 1 // InitADC();
285 1
286 1 Init_Receiver();
287 1
288 1 LED1=0;
289 1 Delayms(20);
290 1 LED1=1;
291 1
292 1 LED2=0;
293 1 Delayms(20);
294 1 LED2=1;
295 1
296 1 LED3=0;
297 1 Delayms(20);
298 1 LED3=1;
299 1
300 1 LED4=0;
301 1 Delayms(20);
302 1 LED4=1;
303 1
C51 COMPILER V7.06 EXP 11/03/2006 17:07:50 PAGE 6
304 1 while(1)
305 1 {
306 2 #if 1 // init ISD51 only when the uVision2 Debugger tries to connect
307 2 ISDcheck(); // initialize uVision2 Debugger and continue program run
308 2 #endif
309 2 if (DR1 == 1)
310 2 {
311 3 KeyByte = SpiReadWrite(0);
312 3 if (L1==0) //switch 1 haveing been pushed
313 3 {
314 4 light(); // ON LED1
315 4 }
316 3 if (L2==0) //switch 1 haveing been pushed
317 3 {
318 4 light(); // ON LED2
319 4 }
320 3 if (L3==0) //switch 1 haveing been pushed
321 3 {
322 4 light(); // ON LED3
323 4 }
324 3 if (L4==0) //switch 1 haveing been pushed
325 3 {
326 4 light(); // ON LED4
327 4 }
328 3
329 3 PutChar0(KeyByte); // To serial port
330 3 Delayms(20);
331 3 KeyByte=0xff;
332 3 LED1=1;
333 3 LED2=1;
334 3 LED3=1;
335 3 LED4=1;
336 3 }
337 2
338 2 KeyScan();
339 2 if (KeyByte!=0xff)
340 2 {
341 3 Transmitter();
342 3 Delayms(20);
343 3 KeyByte=0xff;
344 3 Init_Receiver();
345 3 LED1=1;
346 3 LED2=1;
347 3 LED3=1;
348 3 LED4=1;
349 3 }
350 2 }
351 1
352 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 527 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 33 5
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -