📄 inttest.lst
字号:
C51 COMPILER V7.50 INTTEST 08/10/2005 09:59:08 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE INTTEST
OBJECT MODULE PLACED IN intTest.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE intTest.c DEBUG OBJECTEXTEND
line level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: bulkloop.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // Copyright (c) 2000 Cypress Semiconductor All rights reserved
7 //-----------------------------------------------------------------------------
8 #include "fx2.h"
9 #include "fx2regs.h"
10 #include "fx2sdly.h" // SYNCDELAY macro
11
12 extern BOOL GotSUD; // Received setup data flag
13 extern BOOL Sleep;
14 extern BOOL Rwuen;
15 extern BOOL Selfpwr;
16
17 BYTE Configuration; // Current configuration
18 BYTE AlternateSetting; // Alternate settings
19
20 #define VR_NAKALL_ON 0xD0
21 #define VR_NAKALL_OFF 0xD1
22
23
24 BOOL bInEnable;//IN中断传输使能,通过控制传输设置
25 BYTE status;//状态字节,调试用,通过控制传输读取
26 BYTE xdata Digit[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, 0x88, 0x83, 0xc6, 0xa1,
- 0x86, 0x8e };
27 #define BTN_ADDR 0x20
28 #define LED_ADDR 0x21
29
30 //-----------------------------------------------------------------------------
31 // Task Dispatcher hooks
32 // The following hooks are called by the task dispatcher.
33 //-----------------------------------------------------------------------------
34
35 void TD_Init(void) // Called once at startup
36 {
37 1 // set the CPU clock to 48MHz
38 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
39 1
40 1 // set the slave FIFO interface to 48MHz
41 1 IFCONFIG |= 0x40;
42 1
43 1 // Registers which require a synchronization delay, see section 15.14
44 1 // FIFORESET FIFOPINPOLAR
45 1 // INPKTEND OUTPKTEND
46 1 // EPxBCH:L REVCTL
47 1 // GPIFTCB3 GPIFTCB2
48 1 // GPIFTCB1 GPIFTCB0
49 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
50 1 // EPxFIFOCFG EPxGPIFFLGSEL
51 1 // PINFLAGSxx EPxFIFOIRQ
52 1 // EPxFIFOIE GPIFIRQ
53 1 // GPIFIE GPIFADRH:L
54 1 // UDMACRCH:L EPxGPIFTRIG
C51 COMPILER V7.50 INTTEST 08/10/2005 09:59:08 PAGE 2
55 1 // GPIFTRIG
56 1
57 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
58 1 // ...these have been replaced by GPIFTC[B3:B0] registers
59 1
60 1 // default: all endpoints have their VALID bit set
61 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
62 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
63 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
64 1 // default: EP2, EP4, EP6, and EP8 are double buffered
65 1
66 1 // we are just using the default values, yes this is not necessary...
67 1 EP1OUTCFG = 0xA0;
68 1 EP1INCFG = 0xA0;
69 1
70 1 SYNCDELAY; // see TRM section 15.14
71 1 EP2CFG = 0xB2; //端点2 OUT INT 2xBUFFER
72 1 SYNCDELAY;
73 1 EP4CFG = 0x00; //无效
74 1 SYNCDELAY;
75 1 EP6CFG = 0xF2; //端点6 IN INT 2xBUFFER
76 1 SYNCDELAY;
77 1 EP8CFG = 0x00;//无效
78 1
79 1 // out endpoints do not come up armed
80 1
81 1 // since the defaults are double buffered we must write dummy byte counts twice
82 1 SYNCDELAY;
83 1 EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
84 1 SYNCDELAY;
85 1 EP2BCL = 0x80;
86 1 SYNCDELAY;
87 1 bInEnable=FALSE;//全局变量初始化 中断IN传输使能
88 1 status=0;
89 1 // enable dual autopointer feature
90 1 AUTOPTRSETUP |= 0x01;
91 1
92 1
93 1 Rwuen = TRUE; // Enable remote-wakeup
94 1 }
95
96
97 void TD_Poll(void) // Called repeatedly while the device is idle
98 {
99 1 WORD i;
100 1 EZUSB_InitI2C(); //初始化EZ-USB I2控制器
101 1 //中断IN传输
102 1 if(bInEnable)
103 1 {
104 2 if(!(EP2468STAT & bmEP6FULL))
105 2 {
106 3
107 3 for( i = 0x0000; i < 0x200; i++ )
108 3 {
109 4
110 4 EP6FIFOBUF[i]=(BYTE)(i&0x00ff);
111 4
112 4 }
113 3 EP6BCH = 0x02;
114 3 SYNCDELAY;
115 3 EP6BCL = 0x00;
116 3 SYNCDELAY;
C51 COMPILER V7.50 INTTEST 08/10/2005 09:59:08 PAGE 3
117 3 }
118 2 bInEnable=FALSE;
119 2 status+=1;
120 2 EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[status&0x0f]));
121 2 EZUSB_WaitForEEPROMWrite(LED_ADDR);
122 2
123 2 }
124 1 //中断OUT传输
125 1 if(!(EP2468STAT & bmEP2EMPTY))
126 1 {
127 2 EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[EP2FIFOBUF[0]&0x0f]));
128 2 EZUSB_WaitForEEPROMWrite(LED_ADDR);
129 2 EP2BCL = 0x80;
130 2 SYNCDELAY;
131 2 EP2BCL = 0x80;
132 2 SYNCDELAY;
133 2 }
134 1 }
135
136 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
137 {
138 1 return(TRUE);
139 1 }
140
141 BOOL TD_Resume(void) // Called after the device resumes
142 {
143 1 return(TRUE);
144 1 }
145
146 //-----------------------------------------------------------------------------
147 // Device Request hooks
148 // The following hooks are called by the end point 0 device request parser.
149 //-----------------------------------------------------------------------------
150
151 BOOL DR_GetDescriptor(void)
152 {
153 1 return(TRUE);
154 1 }
155
156 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
157 {
158 1 Configuration = SETUPDAT[2];
159 1 return(TRUE); // Handled by user code
160 1 }
161
162 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
163 {
164 1 EP0BUF[0] = Configuration;
165 1 EP0BCH = 0;
166 1 EP0BCL = 1;
167 1 return(TRUE); // Handled by user code
168 1 }
169
170 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
171 {
172 1 AlternateSetting = SETUPDAT[2];
173 1 return(TRUE); // Handled by user code
174 1 }
175
176 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
177 {
178 1 EP0BUF[0] = AlternateSetting;
C51 COMPILER V7.50 INTTEST 08/10/2005 09:59:08 PAGE 4
179 1 EP0BCH = 0;
180 1 EP0BCL = 1;
181 1 return(TRUE); // Handled by user code
182 1 }
183
184 BOOL DR_GetStatus(void)
185 {
186 1 return(TRUE);
187 1 }
188
189 BOOL DR_ClearFeature(void)
190 {
191 1 return(TRUE);
192 1 }
193
194 BOOL DR_SetFeature(void)
195 {
196 1 return(TRUE);
197 1 }
198 #define VR_B3 0xB3 // enable interrupt trans使能中断IN传输
199 #define VR_B4 0xB4 // disenable interrupt trans非使能中断IN传输
200 #define VR_B5 0xB5 //读取STATUS状态位
201 BOOL DR_VendorCmnd(void)
202 {
203 1 BYTE tmp;
204 1
205 1 switch (SETUPDAT[1])
206 1 {
207 2 case VR_NAKALL_ON:
208 2 tmp = FIFORESET;
209 2 tmp |= bmNAKALL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -