1 Star 0 Fork 14

VeniVidiVici/RFID-RC522_with_C51

forked from Zany/RFID-RC522_with_C51 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MAIN.LST 9.96 KB
一键复制 编辑 原始数据 按行查看 历史
Zany 提交于 2015-05-19 18:11 . fucking work done
C51 COMPILER V9.00 MAIN 05/19/2015 18:06:25 PAGE 1
C51 COMPILER V9.00, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN MAIN.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MAIN.C OMF2 BROWSE DEBUG
line level source
1 #include "lpcreg.h"
2 #include "main.h"
3 #include "mfrc522.h"
4
5 unsigned char code data1[16] = {0x12,0x34,0x56,0x78,0xED,0xCB,0xA9,0x87,0x12,0x34,0x56,0x78,0x01,0xFE,0x01
-,0xFE};
6 //M1卡的某一块写为如下格式,则该块为钱包,可接收扣款和充值命令
7 //4字节金额(低字节在前)+4字节金额取反+4字节金额+1字节块地址+1字节块地址取反+1字节块地址+1字节块地
-啡》
8 unsigned char code data2[4] = {0x12,0,0,0};
9 unsigned char code DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10 unsigned char idata Read_Data[16]={0x00};
11 unsigned char g_ucTempbuf[20];
12
13 //----------------------------------------------------------
14 //是否被初始化
15 //1表示 是,0表示否
16 //sbit isInit=0;
17 //unsigned char orderCode=0;
18 //-----------------------------------------------------------
19
20 //---
21 //蜂鸣器
22 sbit beep=P0^2;
23 //---
24
25 #define LOCK 0;
26 #define OPEN 1;
27 sbit DOOR=P0^0;
28 //
29
30 //延迟
31 void delays(void)
32 {
33 1 unsigned char m,n;
34 1 for(m=0;m<200;m++)
35 1 for(n=0;n<258;n++)
36 1 ;
37 1 }
38 //错误指示灯
39 void flash_ERR(){
40 1 LED_ERR=1;
41 1 delays();
42 1 LED_ERR=0;
43 1 }
44
45 //初始化RFID-RC522
46 void InitRc522(void)
47 {
48 1 PcdReset();
49 1 PcdAntennaOff();
50 1 PcdAntennaOn();
51 1 M500PcdConfigISOType('A');
52 1 }
53
C51 COMPILER V9.00 MAIN 05/19/2015 18:06:25 PAGE 2
54
55 //初始化
56 void UsartConfiguration()
57 {
58 1 SCON=0X50; //设置为工作方式1
59 1 TMOD=0X20; //设置计数器工作方式2
60 1 PCON=0X80; //波特率加倍
61 1 TH1=0XF3; //计数器初始值设置,注意波特率是4800的
62 1 TL1=0XF3;
63 1 ES=1; //打开接收中断
64 1 EA=1; //打开总中断
65 1 TR1=1; //打开计数器
66 1 }
67
68 void Send(unsigned char dat)
69 {
70 1 SBUF=dat;
71 1 while(TI==0)
72 1 ;
73 1 TI=0;
74 1 }
75
76 void delay(unsigned int i)
77 {
78 1 char j;
79 1 for(i; i > 0; i--)
80 1 for(j = 150; j > 0; j--);
81 1 }
82
83 void Usart() interrupt 4
84 {
85 1 unsigned char receiveData,i=0;
86 1 receiveData=SBUF; //出去接收到的数据
87 1 RI = 0; //清除接收中断标志位
88 1
89 1 if(receiveData ==0xff) //上锁指令
90 1 {
91 2 DOOR=LOCK;
92 2 }
93 1 if(receiveData ==0xf0) //开锁指令
94 1 {
95 2 DOOR=OPEN;
96 2 while(i<240)
97 2 {
98 3 beep=1;
99 3 delay(25);
100 3 beep=0;
101 3 i++;
102 3 }
103 2 }
104 1 }
105
106 void Delay10ms(unsigned int c) //误差 0us
107 {
108 1 unsigned char a, b;
109 1
110 1 //--c已经在传递过来的时候已经赋值了,所以在for语句第一句就不用赋值了--//
111 1 for (;c>0;c--)
112 1 {
113 2 for (b=38;b>0;b--)
114 2 {
115 3 for (a=130;a>0;a--);
C51 COMPILER V9.00 MAIN 05/19/2015 18:06:25 PAGE 3
116 3 }
117 2 }
118 1 }
119
120 void main( )
121 {
122 1 unsigned char status;
123 1 unsigned char c=0;
124 1 InitializeSystem( ); //初始化
125 1 while ( 1 )
126 1 {
127 2 //InitializeSystem( ); //初始化
128 2 status = PcdRequest(PICC_REQALL, g_ucTempbuf);//寻卡
129 2
130 2 if (status != MI_OK)
131 2 {
132 3 continue;
133 3 }
134 2 status = PcdAnticoll(g_ucTempbuf); //防冲撞----返回 卡片序列号,4字节
135 2 if (status != MI_OK)
136 2 {
137 3 continue;
138 3 }
139 2 //向串口发送卡片序列号
140 2 for(c=0;c<4;c++)
141 2 {
142 3 LED_GREEN=0;
143 3 Send(g_ucTempbuf[c]);
144 3 LED_GREEN=1;
145 3 }
146 2 PcdHalt();
147 2 Delay10ms(300);
148 2 ///////////////////////////////////////////////////////////////////////
149 2 /// ///
150 2 /// 以下的代码不能删 ///
151 2 /// 删了就无法正常编译 ///
152 2 ///////////////////////////////////////////////////////////////////////
153 2 status = PcdSelect(g_ucTempbuf);
154 2 if (status != MI_OK)
155 2 {
156 3 continue;
157 3 }
158 2 status = PcdAuthState(PICC_AUTHENT1A, 1, DefaultKey, g_ucTempbuf);
159 2 if (status != MI_OK)
160 2 {
161 3 continue;
162 3 }
163 2
164 2 status = PcdWrite(1, data1);
165 2 if (status != MI_OK)
166 2 {
167 3 continue;
168 3 }
169 2
170 2 status = PcdValue(PICC_DECREMENT,1,data2);
171 2 if (status != MI_OK)
172 2 {
173 3 continue;
174 3 }
175 2
176 2 status = PcdBakValue(1, 2);
177 2 if (status != MI_OK)
C51 COMPILER V9.00 MAIN 05/19/2015 18:06:25 PAGE 4
178 2 {
179 3 continue;
180 3 }
181 2
182 2 status = PcdRead(2, g_ucTempbuf);
183 2 if (status != MI_OK)
184 2 {
185 3 continue;
186 3 }
187 2 LED_GREEN=1;
188 2
189 2 }
190 1 }
191
192
193 /////////////////////////////////////////////////////////////////////
194 //系统初始化
195 /////////////////////////////////////////////////////////////////////
196 void InitializeSystem()
197 {
198 1 P0M1 = 0x0;
199 1 P0M2 = 0x0;
200 1
201 1 P1M1 = 0x0;
202 1 P1M2 = 0x0;
203 1
204 1 P3M1 = 0x0;
205 1 P3M2 = 0xFF;
206 1
207 1 P0 = 0xFF;
208 1 P1 = 0xFF;
209 1 P3 = 0xFF;
210 1 DOOR=LOCK;
211 1 InitRc522();
212 1 UsartConfiguration();
213 1 }
214
215
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 416 ----
CONSTANT SIZE = 26 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 20 1
IDATA SIZE = 16 ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/VeniVidiVici/RFID-RC522_with_C51.git
[email protected]:VeniVidiVici/RFID-RC522_with_C51.git
VeniVidiVici
RFID-RC522_with_C51
RFID-RC522_with_C51
master

搜索帮助