📄 mainloop.lst
字号:
C51 COMPILER V7.50 MAINLOOP 03/23/2005 21:15:55 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE MAINLOOP
OBJECT MODULE PLACED IN mainloop.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE mainloop.c DEBUG OBJECTEXTEND SRC(.\mainloop.SRC)
line level source
1 /*
2 //*************************************************************************
3 //
4 // BASBA P R O P R I E T A R Y
5 //
6 // COPYRIGHT (c) 2003 BY BASBA USA.
7 // -- ALL RIGHTS RESERVED --
8 //
9 // File Name: MAINLOOP.H
10 // Purpose: Checks event flags and passes to appropriate subroutine
11 // for further processing. It also contain the code for
12 // human interface such as LED and key scan.
13 // Author: Shuming Yu
14 // Created: 10 May 2003
15 // Modified:
16 // Revision: 1.0
17 //
18 //*************************************************************************
19 */
20 #include <reg51.h> /* special function register declarations */
21
22 #include "d12hal.h"
23 #include "cmds.h"
24 #include "mainloop.h"
25 #include "usbStruc.h"
26 #include "USBProto.h"
27
28 /*
29 //*************************************************************************
30 // USB protocol function pointer arrays
31 //*************************************************************************
32 */
33 code void (*StandardDeviceRequest[])(void) =
34 {
35 get_status,
36 clear_feature,
37 reserved,
38 set_feature,
39 reserved,
40 set_address,
41 get_descriptor,
42 reserved,
43 get_configuration,
44 set_configuration,
45 get_interface,
46 set_interface,
47 reserved,
48 reserved,
49 reserved,
50 reserved
51 };
52
53 code void (*ClassRequest[])(void) =
54 {
55 reserved,
C51 COMPILER V7.50 MAINLOOP 03/23/2005 21:15:55 PAGE 2
56 get_report,
57 get_idle,
58 get_protocol,
59 reserved,
60 reserved,
61 reserved,
62 reserved,
63 reserved,
64 set_report,
65 set_idle,
66 reserved,
67 reserved,
68 reserved,
69 reserved,
70 reserved
71 };
72
73 code void (*VendorDeviceRequest[])(void) =
74 {
75 reserved,
76 reserved,
77 reserved,
78 reserved,
79 reserved,
80 reserved,
81 reserved,
82 reserved,
83 reserved,
84 reserved,
85 reserved,
86 reserved,
87 reserved,
88 reserved,
89 reserved,
90 reserved
91 };
92
93 /*
94 //*************************************************************************
95 // Public static data
96 //*************************************************************************
97 */
98
99
100 extern unsigned long ClockTicks;
101 extern unsigned char idata GenEpBuf[];
102
103 EPPFLAGS bEPPflags; /* USB event flags */
104 CONTROL_XFER ControlData; /* Control endpoint TX/RX buffers */
105
106 code char * _NAME_USB_REQUEST_DIRECTION[] =
107 {
108 "Host_to_device",
109 "Device_to_host"
110 };
111
112 code char * _NAME_USB_REQUEST_RECIPIENT[] =
113 {
114 "Device",
115 "Interface",
116 "Endpoint(0)",
117 "Other"
C51 COMPILER V7.50 MAINLOOP 03/23/2005 21:15:55 PAGE 3
118 };
119
120 code char * _NAME_USB_REQUEST_TYPE[] =
121 {
122 "Standard",
123 "Class",
124 "Vendor",
125 "Reserved"
126 };
127
128 code char * _NAME_USB_STANDARD_REQUEST[] =
129 {
130 "GET_STATUS",
131 "CLEAR_FEATURE",
132 "RESERVED",
133 "SET_FEATURE",
134 "RESERVED",
135 "SET_ADDRESS",
136 "GET_DESCRIPTOR",
137 "SET_DESCRIPTOR",
138 "GET_CONFIGURATION",
139 "SET_CONFIGURATION",
140 "GET_INTERFACE",
141 "SET_INTERFACE",
142 "SYNC_FRAME"
143 };
144
145 void blinkLED(unsigned char num)
146 {
147 1 unsigned int i;
148 1 for (i=0; i<3; i++) {
149 2 if (num==0) {
150 3 MCU_LED0 = 0;
151 3 loop_delay(100);
152 3 MCU_LED0 = 1;
153 3 loop_delay(100);
154 3 }
155 2 else {
156 3 MCU_LED1 = 0;
157 3 loop_delay(100);
158 3 MCU_LED1 = 1;
159 3 loop_delay(100);
160 3
161 3 }
162 2 }
163 1 }
164 /* Configure Timer 0
165 - Mode = 1
166 - Interrupt = ENABLED
167 - Clock Source = INTERNAL
168 - Enable Gating Control = DISABLED
169 */
170 void init_timer0(void)
171 {
172 1 /* Configure Timer 0 as a 16 bit timer */
173 1 TMOD &= 0XF0; /* clear Timer 0, timer 1 left unchanged */
174 1 TMOD |= 0X1; /* set timer working mode 1 */
175 1
176 1 /* load the timer registers with the initial timer value */
177 1 TL0 = 0X0; /* value set by user */
178 1 TH0 = 0X0; /* value set by user */
179 1
C51 COMPILER V7.50 MAINLOOP 03/23/2005 21:15:55 PAGE 4
180 1 ET0 = 1; /* Allow timer 0 interrupt */
181 1 TR0 = 1; /* Start timer 0 */
182 1 PT0 = 1; /* Set timer 0 interrupt high priority */
183 1
184 1 EA = 1;
185 1 }
186
187 void init_special_interrupts(void)
188 {
189 1 IT0 = 0;
190 1 EX0 = 1; // allow external INT0 interrupt
191 1 PX0 = 0; // set INT0 low interrupt priority
192 1 }
193
194 void init_port()
195 {
196 1 P0 = 0xFF;
197 1 P1 = 0xFF;
198 1 P2 = 0xFF;
199 1
200 1 D12SUSPD = 0; /* Prevents D12 to go into Suspend state */
201 1 }
202
203 void main(void)
204 {
205 1 BOOL in_loop = TRUE;
206 1 unsigned char key, i;
207 1
208 1 init_port();
209 1
210 1 init_timer0();
211 1
212 1 init_special_interrupts();
213 1
214 1 bEPPflags.value = 0; /* clear flags of bEPPflags */
215 1
216 1 /* Power on reset, lightup LEDs for 1 sec,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -