📄 main.lst
字号:
C51 COMPILER V7.50 MAIN 03/24/2008 11:06:16 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "ds89c4xx.h"
2 #include "mytype.h"
3 #include "chapter9.h"
4 #include "d12ci.h"
5 #include "uart0.h"
6 #include "key.h"
7
8 void SysInit(void);
9 void InterruptInit(void);
10 void ep1_txdone(void);
11 void ep1_rxdone(void);
12 //void main_txdone(void);
13 //void main_rxdone(void);
14
15 uint8 xdata *pt;
16
17 code uint8 billow[11][60] = {
18 "*********************************************************\r\n",
19 "***** author:billowtust *****\r\n",
20 "***** date: ",__DATE__," *****\r\n",
21 "***** time: ",__TIME__," *****\r\n",
22 "***** CPU: DS89C450MNG *****\r\n",
23 "***** Tianjin University of Science & Technology. *****\r\n",
24 "*********************************************************\r\n"};
25
26 void main(void)
27 {
28 1 uint8 idata i;
29 1 uint16 idata inter;
30 1
31 1 //PMR |= 0x01; //访问片内1KB SRAM
32 1 bEPPflags.value = 0;
33 1
34 1 SysInit();
35 1 UartInit0();
36 1 KeyInit();
37 1
38 1 for(i=0;i<11;i++)
39 1 {
40 2 PutString0(billow[i],200);
41 2 }
42 1 PutString0("System is running......\r\n",200);
43 1 readchipid();
44 1 reconnect_USB(); //先断开USB,再连接
45 1 D12_SetEndpointEnable(1);
46 1 while(1)
47 1 {
48 2 if(!P32)
49 2 {
50 3 inter = D12_ReadInterruptRegister();
51 3
52 3 if(inter & D12_INT_BUSRESET)
53 3 {
54 4 bEPPflags.bits.bus_reset = 1;
55 4 #ifdef debug
C51 COMPILER V7.50 MAIN 03/24/2008 11:06:16 PAGE 2
PutString0("usb bus reset\r\n",50);
#endif
58 4 }
59 3 //if(inter & D12_INT_EOT)
60 3 // dma_eot();
61 3 if(inter & D12_INT_SUSPENDCHANGE)
62 3 {
63 4 bEPPflags.bits.suspend = 1;
64 4 #ifdef debug
PutString0("suspend status changed\r\n",50);
#endif
67 4 }
68 3 if(inter & D12_INT_ENDP0OUT) //输出中断 OUT中断
69 3 {
70 4 ep0_rxdone();
71 4 if(bEPPflags.bits.setup_packet)
72 4 {
73 5 bEPPflags.bits.setup_packet = 0;
74 5 control_handler();
75 5 }
76 4 }
77 3 if(inter & D12_INT_ENDP0IN) //输入中断 IN中断
78 3 ep0_txdone();
79 3 if(inter & D12_INT_ENDP1IN)
80 3 ep1_txdone();
81 3 if(inter & D12_INT_ENDP1OUT)
82 3 ep1_rxdone();
83 3 //if(inter & D12_INT_ENDP2IN)
84 3 //main_txdone();
85 3 //if(inter & D12_INT_ENDP2OUT)
86 3 //main_rxdone();
87 3
88 3 }
89 2 }
90 1 }
91
92 void SysInit(void)
93 {
94 1 P0 = 0xff;
95 1 P1 = 0xff;
96 1 P2 = 0xff;
97 1 P3 = 0xff;
98 1 pt = 0x0000;
99 1 }
100
101 void InterruptInit(void)
102 {
103 1 EA = 0;
104 1 IT0 = 0; //外部中断0电平触发,低电平有效
105 1 EX0 = 1; //允许外部中断
106 1 IP1 = 0;
107 1 IP0 = 0; //IP 清0,所有中断都为最低优先级
108 1 EA = 1; //总中断开关,状态:开
109 1 }
110
111 void ep1_txdone(void)
112 {
113 1 uint8 idata temp[3]={0x55,0xaa,0x5a};
114 1 D12_ReadLastTransactionStatus(3);
115 1 KeyChangeable = 0; //禁止修改按键值
116 1 if(KeyPress) //如果有按键按下
117 1 {
C51 COMPILER V7.50 MAIN 03/24/2008 11:06:16 PAGE 3
118 2 if(KeyPress&(KEY1)) //左Ctrl键
119 2 {
120 3 temp[0] = 0x01;
121 3 }
122 2 else
123 2 {
124 3 temp[0] = 0x10;
125 3 }
126 2 if(KeyPress&(KEY2)) //左shift键
127 2 {
128 3 temp[1] = 0x02;
129 3 }
130 2 else
131 2 {
132 3 temp[1] = 0x20;
133 3 }
134 2 }
135 1
136 1 if(KeyUp||KeyDown)
137 1 {
138 2 KeyUp=0;
139 2 KeyDown=0;
140 2 D12_WriteEndpoint(3,2,temp);
141 2 }
142 1
143 1 KeyChangeable = 1; //允许修改按键值
144 1 }
145
146 void ep1_rxdone(void)
147 {
148 1 uint8 idata len;
149 1 D12_ReadLastTransactionStatus(2);
150 1 len = D12_ReadEndpoint(2,16,pt);
151 1 if(len != 0)
152 1 {
153 2 P2 = ~(*pt);
154 2 }
155 1 }
156
157 /*uint8 idata InBuffer[8];
158
159 void main_txdone(void)
160 {
161 uint8 idata i;
162
163 D12_ReadLastTransactionStatus(5);
164
165 KeyChangeable = 0; //禁止修改按键值
166 if(KeyPress) //如果有按键按下
167 {
168
169 if(KeyPress&(KEY1)) //左shift键
170 {
171 InBuffer[0] |= 1 << 1;
172 }
173 else
174 {
175 InBuffer[0] &= ~(1 << 1);
176 }
177 i=2;
178 if(KeyPress&(KEY2))
179 {
C51 COMPILER V7.50 MAIN 03/24/2008 11:06:16 PAGE 4
180 InBuffer[i++] = 0x04; //a键
181 }
182 if(KeyPress&(KEY3))
183 {
184 InBuffer[i++] = 0x05; //b键
185 }
186 if(KeyPress&(KEY4))
187 {
188 InBuffer[i++] = 0x06; //c键
189 }
190 if(KeyPress&(KEY5))
191 {
192 InBuffer[i++] = 0x07; //d键
193 }
194 if(KeyPress&(KEY6))
195 {
196 InBuffer[i++] = 0x08; //e键
197 }
198 if(KeyPress&(KEY7))
199 {
200 InBuffer[i++] = 0x09; //f
201 }
202 if(KeyPress&(KEY8))
203 {
204 InBuffer[i++] = 0x39; //Caps Lock键
205 }
206 for(;i<8;i++)
207 {
208 InBuffer[i] = 0; //多余的清0
209 }
210 }
211 else //如果无按键按下,则返回0
212 {
213 for(i=0;i<8;i++)
214 {
215 InBuffer[i] = 0;
216 }
217 }
218
219 if(KeyUp||KeyDown)
220 {
221 KeyUp=0;
222 KeyDown=0;
223 D12_WriteEndpoint(5,8,InBuffer);
224 }
225
226 KeyChangeable = 1; //允许修改按键值
227 }
228
229 void main_rxdone(void)
230 {
231 uint8 len;
232 static uint8 idata flag1 = 0;
233 D12_ReadLastTransactionStatus(4);
234 len = D12_ReadEndpoint(4,64,pt);
235 if(len != 0)
236 {
237 P2 = ~(*pt);
238 }
239 if(flag1 == 0)
240 {
241 D12_WriteEndpoint(5,0,0);
C51 COMPILER V7.50 MAIN 03/24/2008 11:06:16 PAGE 5
242 flag1++;
243 }
244 } */
245
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 338 ----
CONSTANT SIZE = 689 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 ----
IDATA SIZE = ---- 7
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -