?? keil00.lst
字號(hào):
C51 COMPILER V7.10 KEIL00 09/13/2007 23:16:12 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE KEIL00
OBJECT MODULE PLACED IN keil00.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE keil00.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*********************************************************
2 2007.4.03
3 **********************************************************
4 A3986步進(jìn)驅(qū)動(dòng)控制板硬件定義
5 P00~~~P07--------方位I1~~~I8 P11---出牌計(jì)數(shù)
6 P10---有無牌檢測(cè) P12---LED燈 P14---出牌電機(jī)
7 P13---傳動(dòng)電機(jī) P32---RS485cs P33---傳感器電源控制
8 P34---按鍵 P36---A3986_Vref P35---A3986時(shí)鐘輸入
9 P37---轉(zhuǎn)動(dòng)方向 P23---A3986_EN P23---A3986_EN
10 P21---A3986_SR(衰減有效) P24.P25---A3986_PFD1.PFD2(衰減選擇)
11 P22---A3986_RST P24.P25---A3986_MS1.MS2(細(xì)分選擇)
12 ***************************************************************
13 計(jì)數(shù)傳感器有牌為H.無牌為L(zhǎng)----有牌檢測(cè)傳感器有牌為L(zhǎng).無牌為H
14 ***************************************************************
15 通信協(xié)議:前導(dǎo)碼RB+接收編號(hào)+發(fā)送編號(hào)+命令+參數(shù)1+參數(shù)2+結(jié)束碼0D
16 編號(hào):A---A倉板 B---B1板 C---B2板 M---主板
17 命令號(hào):0x01---發(fā)牌 0x20---接收出錯(cuò)
18 0x02---過渡輪轉(zhuǎn) 0x21---收到命令
19 0x03---過渡輪停 0x22---執(zhí)行完畢
20 0x04---清牌 0x23---狀態(tài)返回
21 0x07---狀態(tài)查詢 0x24---少牌報(bào)警
22 0x25---卡牌報(bào)警
23 *********************************************************/
24 #include <stdio.h>
25 #include <AT89x52.h>
26 #include <absacc.h>
27 #include <intrins.h>
28
29 #define Back_OPTO P1_0 /*左有無牌 */
30 #define Count_OPTO P1_1 /*出牌計(jì)數(shù)*/
31 #define LED P1_2
32 #define Back_motor P1_3 /*傳動(dòng)電機(jī)2*/
33 #define Front_motor P1_4 /*出牌電機(jī)2*/
34 #define TEST P1_5
35 #define R485cs P3_2
36 #define OPTOV P3_3 /*傳感器電源控制端*/
37 #define KEY P3_4
38 #define Step P3_5 /*脈沖*/
39 #define ConVref P3_6 /*功率控制*/
40 #define DIR P3_7 /*方向控制*/
41 #define A3986_SR P2_1 //A3986
42 #define A3986_RST P2_2 //A3986
43 #define A3986_EN P2_3 //A3986
44 #define A3986_PFD1 P2_4 //A3986
45 #define A3986_PFD2 P2_5 //A3986
46 #define A3986_MS1 P2_6 //A3986
47 #define A3986_MS2 P2_7 //A3986
48 #define azimuth P0 /*方位*/
49
50 void Init(void); /*初始化*/
51 void Rs232int(void); /*串口中斷*/
52 void Receive(void); /*串口接收*/
53 void Transmit(void); /*串口發(fā)射*/
54 void Delay50ms(void); /*延時(shí)50ms*/
55 void OutCard(void); /*發(fā)牌子程序*/
C51 COMPILER V7.10 KEIL00 09/13/2007 23:16:12 PAGE 2
56 void StateB(void); /*B狀態(tài)查詢*/
57 void BboxState(void); /*Bbox狀態(tài)查詢*/
58 void Test1(void); /*測(cè)試程序*/
59 void Test2(void); /*測(cè)試程序*/
60 void Turn(void); /*轉(zhuǎn)動(dòng)程序*/
61 void Riffle1(void); /*A洗牌程序*/
62 void Out1(void); /*A出牌程序*/
63 void ShaoCar(void); /*少牌處理*/
64 void TXok(void); /*任務(wù)發(fā)出及反饋處理*/
65 void ClrCard(void); /*清牌程序*/
66 void OUTremnantCard(void); /*發(fā)底牌子程序*/
67
68 /************************************************************************
69 TX[8]---發(fā)送數(shù)組 ReceivePack[8]---接收數(shù)組
70 BoxNO----當(dāng)前接牌盒編號(hào)變量 Azidata----出牌口方位變量
71 Box1data----牌盒1內(nèi)牌數(shù)變量 Box2data---牌盒2內(nèi)牌數(shù)變量
72 Box3data----牌盒3內(nèi)牌數(shù)變量 Box4data---牌盒4內(nèi)牌數(shù)變量
73 Card_data----每次發(fā)牌數(shù)變量 Count0-----臨時(shí)變量
74 AllCard,Mandata,SingleCard,RemnantCard---總牌數(shù),人數(shù),每人牌數(shù),底牌數(shù)
75 State----工作狀態(tài)變量(0-閑、1-忙、2-任務(wù)完成、3-錯(cuò)誤1、4-錯(cuò)誤2、5-錯(cuò)誤3)
76 *************************************************************************/
77 unsigned char TX[8]={'R','B',0x0,'A',0x0,0x0,0x0,0x0D};
78 unsigned char ReceivePack[10];
79 unsigned char Card_data,BoxNO,Box1data,Box2data,Box3data,Box4data,CarBak;
80 unsigned char AllCard,Mandata,SingleCard,RemnantCard,RemnantBox,firstOUT;
81 unsigned char Place,Command,ErrorNO,State,Count0,Count1,Count2; //Busy,
82
83 bit ShaoCardBit,RxdOKBit,OutBit,BboxErr,PanErr,OUTmodeBit,ClrBit;
84 /*ShaoCardBit:少牌標(biāo)志 RxdOKbit:接收OK*/
85 /*SingleCard,Place--位置變量*/
86 unsigned char bdata Wupaidata;
87 sbit Wupai1=Wupaidata^0;
88 sbit Wupai2=Wupaidata^1;
89 sbit Wupai3=Wupaidata^2;
90 sbit Wupai4=Wupaidata^3;
91
92 void main(void)
93 {
94 1 _nop_();
95 1 _nop_();
96 1 _nop_();
97 1 _nop_();
98 1 _nop_();
99 1 _nop_();
100 1 _nop_();
101 1 _nop_();
102 1 _nop_();
103 1 LED=0; //*正常進(jìn)入程序,亮LED燈0.2'*/
104 1 Delay50ms();
105 1 Delay50ms();
106 1 LED=1;
107 1 ConVref=0; /*步進(jìn)電機(jī)小功率*/
108 1
109 1 Init(); /*初始化*/
110 1
111 1 while(!A3986_SR)
112 1 {
113 2 Test1();
114 2 } /*TEST測(cè)試有效,進(jìn)入測(cè)試程序*/
115 1
116 1 DIR=0; /*順時(shí)針轉(zhuǎn)動(dòng)定位*/
117 1 A3986_EN=0;
C51 COMPILER V7.10 KEIL00 09/13/2007 23:16:12 PAGE 3
118 1 Delay50ms();
119 1 ConVref=1; /*步進(jìn)電機(jī)大功率*/
120 1 while(azimuth==0xff)
121 1 {
122 2 for(Count0=0;Count0<255;Count0++)
123 2 {
124 3 _nop_();
125 3 _nop_();
126 3 }
127 2 Step=!Step;
128 2 }
129 1 ConVref=0; /*小功率*/
130 1 switch(azimuth)
131 1 {
132 2 case 0x7f: Place=1; break; /*當(dāng)前接牌盒位置判斷*/
133 2 case 0xef: Place=2; break; /*Place--位置變量*/
134 2 case 0xbf: Place=3; break; //
135 2 case 0xdf: Place=4; break; //
136 2 default: break;
137 2 }
138 1 if(!KEY)
139 1 {
140 2 while(1) /*測(cè)試有效進(jìn)入測(cè)試程序*/
141 2 {
142 3 Test2();
143 3 }
144 2 }
145 1 ClrBit=0;
146 1 State=0;
147 1 ErrorNO=0;
148 1 TR2=1;
149 1 while(1)
150 1 {
151 2 if(ErrorNO)
152 2 {
153 3 TX[2]='M';
154 3 TX[4]=0x55;
155 3 TX[5]=ErrorNO;
156 3 Transmit();
157 3 ErrorNO=0;
158 3 Command=0;
159 3 }
160 2 //if(Command==0x11||Command==0x12||Command==0x13||Command==0x14||Command==0x04||Command==0x07)
161 2 if(ClrBit)
162 2 Command=0x04;
163 2 if(Command)
164 2 { //TX[2]='M';
165 3 //TX[4]=0x21;
166 3 //TX[5]=Command;
167 3 //Transmit();
168 3 switch(Command)
169 3 {
170 4 case 0x11: Command=0;
171 4 AllCard=ReceivePack[5]; /*0x11--設(shè)置游戲參數(shù)*/
172 4 Mandata=ReceivePack[6];
173 4 SingleCard=ReceivePack[7];
174 4 RemnantCard=ReceivePack[8];
175 4 break;
176 4 case 0x12: State=Command; /*0x12--洗牌*/
177 4 Riffle1(); /*A類游戲洗牌*/
178 4 break;
179 4 case 0x13: State=Command; /*0x13--發(fā)牌*/
C51 COMPILER V7.10 KEIL00 09/13/2007 23:16:12 PAGE 4
180 4 firstOUT=ReceivePack[6]; /*第一個(gè)出牌口(出牌盒)選擇*/
181 4 Out1(); /*A類出牌*/
182 4 break;
183 4 case 0x14: State=Command; /*0x13--發(fā)底牌*/
184 4 Count0=ReceivePack[5]; /*0x13--底牌出口*/
185 4 OUTremnantCard();
186 4 break;
187 4 case 0x04: State=Command; /*0x13--清牌*/
188 4 ClrBit=0;
189 4 ClrCard();
190 4 break;
191 4 case 0x07: State=Command; /*0x13--有無牌檢測(cè)*/
192 4 StateB();
193 4 break;
194 4 default: Command=0;
195 4 break;
196 4 }
197 3 if(!ClrBit&&State)
198 3 {
199 4 if(ErrorNO)
200 4 {
201 5 TX[2]='M'; /*返回錯(cuò)誤類型*/
202 5 TX[4]=0x22; //TX[4]=0x55;
203 5 TX[5]=State; //TX[5]=0x13;
204 5 Transmit();
205 5 }
206 4 else /*執(zhí)行完成后返回*/
207 4 {
208 5 TX[2]='M';
209 5 TX[4]=0x22;
210 5 TX[5]=State;
211 5 Transmit();
212 5 }
213 4 State=0;
214 4 Command=0;
215 4 }
216 3 }
217 2 }
218 1 }
219 /***********************************
220 *-------發(fā)底牌程序--------------*
221 ***********************************/
222 void OUTremnantCard(void)
223 {
224 1 unsigned char x;
225 1
226 1 BoxNO=Count0+2; /*底牌出口確定*/
227 1 if(BoxNO>4)
228 1 BoxNO=BoxNO-4;
229 1 if(0<BoxNO&&BoxNO<5)
230 1 {
231 2 Turn();
232 2 }
233 1 if(PanErr)
234 1 goto OUTremnantexit; /*轉(zhuǎn)盤錯(cuò)誤退出*/
235 1 TX[4]=1; /*無錯(cuò)B倉發(fā)牌*/
236 1 switch(RemnantBox)
237 1 {
238 2 case 1: TX[2]='B'; TX[5]=RemnantCard;TX[6]=0; break;
239 2 case 2: TX[2]='B'; TX[5]=0;TX[6]=RemnantCard; break;
240 2 case 3: TX[2]='C'; TX[5]=RemnantCard;TX[6]=0; break;
241 2 case 4: TX[2]='C'; TX[5]=0;TX[6]=RemnantCard; break;
C51 COMPILER V7.10 KEIL00 09/13/2007 23:16:12 PAGE 5
242 2 default: break;
243 2 }
244 1 Transmit();
245 1 TXok();
246 1 if(ErrorNO)
247 1 goto OUTremnantexit;
248 1 Command=0;
249 1 x=0;
250 1 while(Command==0) /*等待B倉返回信息*/
251 1 {
252 2 Delay50ms();
253 2 if(x>50)
254 2 {
255 3 break;
256 3 }
257 2 x++;
258 2 }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -