📄 mainloop.lst
字号:
C51 COMPILER V6.12 MAINLOOP 10/08/2003 08:56:04 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE MAINLOOP
OBJECT MODULE PLACED IN .\Mainloop.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\Mainloop.c OPTIMIZE(2,SPEED) DEBUG OBJECTEXTEND
stmt level source
1 #include <stdio.h>
2 #include <string.h>
3
4 #include <reg51.h> /* special function register declarations */
5
6 #include "epphal.h"
7 #include "d12ci.h"
8 #include "mainloop.h"
9 #include "usb100.h"
10 #include "chap_9.h"
11 #include "protodma.h"
12 /*
13 //*************************************************************************
14 // USB protocol function pointer arrays
15 //*************************************************************************
16 */
17
18
19 //USB标准请求
20 code void (*StandardDeviceRequest[])(void) =
21 {
22 get_status,
23 clear_feature,
24 reserved,
25 set_feature,
26 reserved,
27 set_address,
28 get_descriptor,
29 reserved,
30 get_configuration,
31 set_configuration,
32 get_interface,
33 set_interface,
34 reserved,
35 reserved,
36 reserved,
37 reserved
38 };
39
40 //用户厂商请求
41 code void (*VendorDeviceRequest[])(void) =
42 {
43 reserved,
44 reserved,
45 reserved,
46 reserved,
47 reserved,
48 reserved,
49 reserved,
50 reserved,
51 reserved,
52 reserved,
53 reserved,
54 reserved,
55 read_write_register,
C51 COMPILER V6.12 MAINLOOP 10/08/2003 08:56:04 PAGE 2
56 reserved,
57 reserved,
58 reserved
59 };
60
61 /*
62 //*************************************************************************
63 // Public static data
64 //*************************************************************************
65 */
66
67 extern EPPFLAGS bEPPflags;
68 extern unsigned long ClockTicks;
69 extern unsigned char idata GenEpBuf[];
70 extern IO_REQUEST idata ioRequest;
71 extern showarray();
72 extern unsigned char rownum;
73 extern unsigned char ioSize, ioCount;
74 extern unsigned char idata EpBuf[];
75
76 CONTROL_XFER ControlData;
77 BOOL bNoRAM;
78
79 code char * _NAME_USB_REQUEST_DIRECTION[] =
80 {
81 "Host_to_device",
82 "Device_to_host"
83 };
84
85 code char * _NAME_USB_REQUEST_RECIPIENT[] =
86 {
87 "Device",
88 "Interface",
89 "Endpoint(0)",
90 "Other"
91 };
92
93 code char * _NAME_USB_REQUEST_TYPE[] =
94 {
95 "Standard",
96 "Class",
97 "Vendor",
98 "Reserved"
99 };
100
101 code char * _NAME_USB_STANDARD_REQUEST[] =
102 {
103 "GET_STATUS",
104 "CLEAR_FEATURE",
105 "RESERVED",
106 "SET_FEATURE",
107 "RESERVED",
108 "SET_ADDRESS",
109 "GET_DESCRIPTOR",
110 "SET_DESCRIPTOR",
111 "GET_CONFIGURATION",
112 "SET_CONFIGURATION",
113 "GET_INTERFACE",
114 "SET_INTERFACE",
115 "SYNC_FRAME"
116 };
117
C51 COMPILER V6.12 MAINLOOP 10/08/2003 08:56:04 PAGE 3
118
119 void help_devreq(unsigned char typ, unsigned char req)
120 {
121 1 typ >>= 5;
122 1
123 1 if(typ == USB_STANDARD_REQUEST) {
124 2 }
125 1 else {
126 2 if(bEPPflags.bits.verbose)
127 2 printf("Request Type = %s, bRequest = 0x%bx.\n", _NAME_USB_REQUEST_TYPE[typ],
128 2 req);
129 2 }
130 1 }
131
132 /* Configure Timer 0
133 - Mode = 1
134 - Interrupt = ENABLED
135 - Clock Source = INTERNAL
136 - Enable Gating Control = DISABLED
137 */
138 //定时器0初始化程序
139 //定时器用来定时检测按键状态
140 void init_timer0(void)
141 {
142 1 TMOD &= 0XF0; /* clear Timer 0 */
143 1 TMOD |= 0X01;
144 1 TL0 = 0X0; /* value set by user */
145 1 TH0 = 0X0; /* value set by user */
146 1 ET0 = 1; /* IE.1*/
147 1 TR0 = 1; /* TCON.4 start timer */
148 1 PT0 = 1;
149 1
150 1 EA = 1;
151 1 }
152 /*void init_timer1(void)
153 {
154 TMOD &= 0X0F;
155 TMOD |= 0X10;
156 TL1 = 0X0;
157 TH1 = 0Xff;
158 ET1 = 1;
159 TR1 = 1;
160 PT1 = 0;
161 EA = 1;
162
163 }
164 */
165
166 /* Interrupt Control Unit */
167 /* **** Enabled interrupts in Interrupt Enable Register ****
168 **** GLOBAL INTERRUPT MUST BE ENABLED FOR ANY OTHER
169 **** INTERRUPT TO WORK!
170 */
171 /* GLOBAL INTERRUPT DISABLED ALL INTERRUPTS
172 ARE DISABLED */
173 /* External interrupt 0 */
174 /* Priority Level = 0 */
175 /* Timer 0 interrupt */
176 /* Priority Level = 0 */
177 //中断设置
178 void init_special_interrupts(void)
179 {
C51 COMPILER V6.12 MAINLOOP 10/08/2003 08:56:04 PAGE 4
180 1 IT0 = 0; //负电平触发
181 1 EX0 = 1; //使能外部中断0
182 1 PX0 = 0; //定以外部中断0优先级,低优先级
183 1 }
184
185 //I/O口初始化程序
186 void init_port()
187 {
188 1 P0 = 0xFF;
189 1 P1 = 0xFF;
190 1 P2 = 0xFF;
191 1 P3 = 0xFF;
192 1 MCU_D12CS = 0x0;
193 1 D12SUSPD = 0;
194 1 }
195
196 /*Serial Port */
197 /*Mode = 1 /8-bit UART
198 Serial Port Interrupt = Disabled */
199 /*Receive = Enabled */
200 /*Auto Addressing = Disabled */
201 //串行口设置
202 void init_serial(void)
203 {
204 1 SCON = 0X52;
205 1 PCON = 0X80 | PCON;
206 1 TMOD = 0X20;
207 1 TCON = 0x69; // TCON
208 1 TH1 = 0xF3;
209 1 }
210
211
212 void main(void)
213 {
214 1 unsigned char key, i;
215 1 init_port();//初始化I/O口
216 1 init_serial();//初始化串行口
217 1 //注:串行口是用来外扩LCD和键盘,用于查询显示当前的工作状态
218 1 //在USB Smart Board标准配置中并未带该LCD和键盘,这里给出的程序仅供参考
219 1
220 1 init_timer0();//初始化定时器0
221 1 // init_timer1();//初始化定时器1
222 1 init_special_interrupts();//设置中断
223 1
224 1 MCU_D12CS = 0x1;
225 1
226 1 MCU_D12CS = 0x0;
227 1
228 1 D12_ReadChipID();
229 1
230 1 /* if(MCU_SWM0 == 0 && MCU_SWM1 == 0) {
231 1 MCU_D12RST = 0;//DMA设置
232 1 MCU_D12RST = 1;
233 1 D12_SetDMA(0x0);
234 1 }
235 1 */
236 1 bEPPflags.value = 0;
237 1 reconnect_USB();//重新连接USB
238 1 /*
239 1 if((i = D12_GetDMA()) == 0xC3) {
240 1 D12_SendResume();//发送恢复处理
241 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -