📄 fw.lst
字号:
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE FW
OBJECT MODULE PLACED IN fw.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE fw.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //-----------------------------------------------------------------------------
2 // File: fw.c
3 // Contents: Firmware frameworks task dispatcher and device request parser
4 // source.
5 //
6 // indent 3. NO TABS!
7 //
8 // $Revision: 18 $
9 // $Date: 12/04/01 5:33p $
10 //
11 // Copyright (c) 1997 AnchorChips, Inc. All rights reserved
12 //-----------------------------------------------------------------------------
13 #include "fx2.h"
14 #include "fx2regs.h"
15 #include "string.h"
16 #include "io.h"
17 #include "led.h"
18 #include "key.h"
19 #include "OTimer.h"
20
21 //-----------------------------------------------------------------------------
22 // Constants
23 //-----------------------------------------------------------------------------
24 #define DELAY_COUNT 0x9248*8L // Delay for 8 sec at 24Mhz, 4 sec at 48
25 #define _IFREQ 48000 // IFCLK constant for Synchronization Delay
26 #define _CFREQ 48000 // CLKOUT constant for Synchronization Delay
27
28 //-----------------------------------------------------------------------------
29 // Random Macros
30 //-----------------------------------------------------------------------------
31 #define min(a,b) (((a)<(b))?(a):(b))
32 #define max(a,b) (((a)>(b))?(a):(b))
33
34 // Registers which require a synchronization delay, see section 15.14
35 // FIFORESET FIFOPINPOLAR
36 // INPKTEND OUTPKTEND
37 // EPxBCH:L REVCTL
38 // GPIFTCB3 GPIFTCB2
39 // GPIFTCB1 GPIFTCB0
40 // EPxFIFOPFH:L EPxAUTOINLENH:L
41 // EPxFIFOCFG EPxGPIFFLGSEL
42 // PINFLAGSxx EPxFIFOIRQ
43 // EPxFIFOIE GPIFIRQ
44 // GPIFIE GPIFADRH:L
45 // UDMACRCH:L EPxGPIFTRIG
46 // GPIFTRIG
47
48 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
49 // ...these have been replaced by GPIFTC[B3:B0] registers
50
51 #include "fx2sdly.h" // Define _IFREQ and _CFREQ above this #include
52
53 //-----------------------------------------------------------------------------
54 // Global Variables
55 //-----------------------------------------------------------------------------
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 2
56 volatile BOOL GotSUD;
57 BOOL Rwuen;
58 BOOL Selfpwr;
59 volatile BOOL Sleep; // Sleep mode enable flag
60
61 WORD pDeviceDscr; // Pointer to Device Descriptor; Descriptors may be moved
62 WORD pDeviceQualDscr;
63 WORD pHighSpeedConfigDscr;
64 WORD pFullSpeedConfigDscr;
65 WORD pConfigDscr;
66 WORD pOtherConfigDscr;
67 WORD pStringDscr;
68
69
70 //-----------------------------------------------------------------------------
71 // Prototypes
72 //-----------------------------------------------------------------------------
73 void SetupCommand(void);
74 void TD_Init(void);
75 void TD_Poll(void);
76 BOOL TD_Suspend(void);
77 BOOL TD_Resume(void);
78
79 BOOL DR_GetDescriptor(void);
80 BOOL DR_SetConfiguration(void);
81 BOOL DR_GetConfiguration(void);
82 BOOL DR_SetInterface(void);
83 BOOL DR_GetInterface(void);
84 BOOL DR_GetStatus(void);
85 BOOL DR_ClearFeature(void);
86 BOOL DR_SetFeature(void);
87 BOOL DR_VendorCmnd(void);
88
89 // this table is used by the epcs macro
90 const char code EPCS_Offset_Lookup_Table[] =
91 {
92 0, // EP1OUT
93 1, // EP1IN
94 2, // EP2OUT
95 2, // EP2IN
96 3, // EP4OUT
97 3, // EP4IN
98 4, // EP6OUT
99 4, // EP6IN
100 5, // EP8OUT
101 5, // EP8IN
102 };
103
104 // macro for generating the address of an endpoint's control and status register (EPnCS)
105 #define epcs(EP) (EPCS_Offset_Lookup_Table[(EP & 0x7E) | (EP > 128)] + 0xE6A1)
106
107 BYTE Mini; //分钟
108 BYTE Second; //秒
109
110 void Disp_Updata()
111 {
112 1 DispBuf[0] = Second % 10; //更新显示
113 1 DispBuf[1] = Second / 10;
114 1 DispBuf[2] = Mini % 10+0x80;
115 1 DispBuf[3] = Mini / 10;
116 1 }
117
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 3
118 void Clock_Updata(BYTE m_s_flag, BYTE inc_dec_flag)
119 {
120 1 if(m_s_flag == 0) //分钟
121 1 {
122 2 if(inc_dec_flag == 0) //加1
123 2 {
124 3 Mini++;
125 3 if(Mini >= 60)
126 3 {
127 4 Mini = 0;
128 4 }
129 3 }
130 2 else if(inc_dec_flag == 1) //减1
131 2 {
132 3 Mini--;
133 3 if(Mini >= 60)
134 3 {
135 4 Mini = 59;
136 4 }
137 3 }
138 2 else if(inc_dec_flag == 2) //清零
139 2 {
140 3 Mini = 0;
141 3 }
142 2 else if(inc_dec_flag == 3) //置为59
143 2 {
144 3 Mini = 59;
145 3 }
146 2
147 2 }
148 1 else //秒
149 1 {
150 2 if(inc_dec_flag == 0) //加1
151 2 {
152 3 Second++;
153 3 if(Second >= 60)
154 3 {
155 4 Second = 0;
156 4 }
157 3 }
158 2 else if(inc_dec_flag == 1) //减1
159 2 {
160 3 Second--;
161 3 if(Second >= 60)
162 3 {
163 4 Second = 59;
164 4 }
165 3 }
166 2 else if(inc_dec_flag == 2) //清零
167 2 {
168 3 Second = 0;
169 3 }
170 2 else if(inc_dec_flag == 3) //置为59
171 2 {
172 3 Second = 59;
173 3 }
174 2 }
175 1 Disp_Updata();
176 1 }
177
178 //-----------------------------------------------------------------------------
179 // Code
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 4
180 //-----------------------------------------------------------------------------
181
182 // Task dispatcher
183 void main(void)
184 {
185 1 DWORD i;
186 1 WORD offset;
187 1 DWORD DevDescrLen;
188 1 DWORD j=0;
189 1 WORD IntDescrAddr;
190 1 WORD ExtDescrAddr;
191 1 BYTE temp_data;
192 1
193 1 // Initialize Global States
194 1 Sleep = FALSE; // Disable sleep mode
195 1 Rwuen = FALSE; // Disable remote wakeup
196 1 Selfpwr = FALSE; // Disable self powered
197 1 GotSUD = FALSE; // Clear "Got setup data" flag
198 1 Mini = 0;
199 1 Second = 0;
200 1
201 1 // Initialize user device
202 1 TD_Init();
203 1 IO_Init();
204 1 REG_Init();
205 1 Disp_Init();
206 1 OKey_RP_Init();
207 1 Sys_TimerInit (); //系统定时器初始化
208 1
209 1 memset(DispBuf,0,4);
210 1 Sys_TimerRequest(OTimerID0,10,1) ; //1S定时
211 1 Sys_TimerRequest(OTimerID1,5,1) ; //word led flash
212 1 // The following section of code is used to relocate the descriptor table.
213 1 // Since the SUDPTRH and SUDPTRL are assigned the address of the descriptor
214 1 // table, the descriptor table must be located in on-part memory.
215 1 // The 4K demo tools locate all code sections in external memory.
216 1 // The descriptor table is relocated by the frameworks ONLY if it is found
217 1 // to be located in external memory.
218 1 pDeviceDscr = (WORD)&DeviceDscr;
219 1 pDeviceQualDscr = (WORD)&DeviceQualDscr;
220 1 pHighSpeedConfigDscr = (WORD)&HighSpeedConfigDscr;
221 1 pFullSpeedConfigDscr = (WORD)&FullSpeedConfigDscr;
222 1 pStringDscr = (WORD)&StringDscr;
223 1
224 1 if ((WORD)&DeviceDscr & 0xe000)
225 1 {
226 2 IntDescrAddr = INTERNAL_DSCR_ADDR;
227 2 ExtDescrAddr = (WORD)&DeviceDscr;
228 2 DevDescrLen = (WORD)&UserDscr - (WORD)&DeviceDscr + 2;
229 2 for (i = 0; i < DevDescrLen; i++)
230 2 *((BYTE xdata *)IntDescrAddr+i) = 0xCD;
231 2 for (i = 0; i < DevDescrLen; i++)
232 2 *((BYTE xdata *)IntDescrAddr+i) = *((BYTE xdata *)ExtDescrAddr+i);
233 2 pDeviceDscr = IntDescrAddr;
234 2 offset = (WORD)&DeviceDscr - INTERNAL_DSCR_ADDR;
235 2 pDeviceQualDscr -= offset;
236 2 pConfigDscr -= offset;
237 2 pOtherConfigDscr -= offset;
238 2 pHighSpeedConfigDscr -= offset;
239 2 pFullSpeedConfigDscr -= offset;
240 2 pStringDscr -= offset;
241 2 }
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 5
242 1
243 1 EZUSB_IRQ_ENABLE(); // Enable USB interrupt (INT2)
244 1 EZUSB_ENABLE_RSMIRQ(); // Wake-up interrupt
245 1
246 1 INTSETUP |= (bmAV2EN | bmAV4EN); // Enable INT 2 & 4 autovectoring
247 1
248 1 USBIE |= bmSUDAV | bmSUTOK | bmSUSP | bmURES | bmHSGRANT; // Enable selected interrupts
249 1 /////////////////////////////
250 1 EA = 1; // Enable 8051 interrupts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -