📄 bulkloop.lst
字号:
C51 COMPILER V7.02b BULKLOOP 10/27/2004 22:55:34 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE BULKLOOP
OBJECT MODULE PLACED IN bulkloop.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bulkloop.c DEBUG OBJECTEXTEND
stmt 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 // Task Dispatcher hooks
25 // The following hooks are called by the task dispatcher.
26 //-----------------------------------------------------------------------------
27
28 void TD_Init(void) // Called once at startup
29 {
30 1 // set the CPU clock to 48MHz
31 1 CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
32 1
33 1 // set the slave FIFO interface to 48MHz
34 1 IFCONFIG |= 0x40;
35 1
36 1 // Registers which require a synchronization delay, see section 15.14
37 1 // FIFORESET FIFOPINPOLAR
38 1 // INPKTEND OUTPKTEND
39 1 // EPxBCH:L REVCTL
40 1 // GPIFTCB3 GPIFTCB2
41 1 // GPIFTCB1 GPIFTCB0
42 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
43 1 // EPxFIFOCFG EPxGPIFFLGSEL
44 1 // PINFLAGSxx EPxFIFOIRQ
45 1 // EPxFIFOIE GPIFIRQ
46 1 // GPIFIE GPIFADRH:L
47 1 // UDMACRCH:L EPxGPIFTRIG
48 1 // GPIFTRIG
49 1
50 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
51 1 // ...these have been replaced by GPIFTC[B3:B0] registers
52 1
53 1 // default: all endpoints have their VALID bit set
54 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
55 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
C51 COMPILER V7.02b BULKLOOP 10/27/2004 22:55:34 PAGE 2
56 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
57 1 // default: EP2, EP4, EP6, and EP8 are double buffered
58 1 //
59 1 // we are just using the default values, yes this is not necessary...
60 1 EP1OUTCFG = 0xA0;
61 1 // SYNCDELAY;
62 1 EP1INCFG = 0xA3;
63 1 // SYNCDELAY; // see TRM section 15.14
64 1 //EP2CFG Endpoint 2 Configuration VALID DIR TYPE1 TYPE0 SIZE 0 BUF1 BUF0
65 1 //端点2配置,OUT,双缓冲,BULK
66 1 //0xA0 四缓冲
67 1 //0xA2 双缓冲
68 1 //0xA3 三缓冲
69 1 SYNCDELAY;
70 1 EP2CFG = 0xA0; // EP2OUT, bulk, size 512, 4x buffered
71 1 SYNCDELAY;
72 1 EP4CFG = 0x00; // EP4 not valid
73 1 SYNCDELAY;
74 1 EP6CFG = 0xE0; // EP6 not valid
75 1 SYNCDELAY;
76 1 EP8CFG = 0x00; // EP8 not valid
77 1
78 1
79 1 //根据端点2缓冲区数目多少来确定装载端点计数器的次数
80 1 SYNCDELAY;
81 1 EP2BCL = 0x80;
82 1 SYNCDELAY;
83 1 EP2BCL = 0x80;
84 1 // SYNCDELAY;
85 1 // EP2BCL = 0x80;
86 1 // SYNCDELAY;
87 1 // EP2BCL = 0x80;
88 1
89 1
90 1 // enable dual autopointer feature
91 1 AUTOPTRSETUP |= 0x01;
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
100 1 WORD count;
101 1 unsigned char temp;
102 1 WORD i;
103 1 if(!(EP2468STAT & bmEP2EMPTY))//ENDPOINT2非空,则开始接收数据
104 1 {
105 2 /*
106 2 APTR1H = MSB( &EP2FIFOBUF );
107 2 APTR1L = LSB( &EP2FIFOBUF );
108 2
109 2 count = (EP2BCH << 8) + EP2BCL;
110 2
111 2 // 循环将端点2中的数据取出,因为单片机指令慢,会影响测试速度
112 2 for( i = 0x0000; i < count; i++ )
113 2 {
114 2 // setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s)
115 2 temp = EXTAUTODAT1;
116 2
117 2 }
C51 COMPILER V7.02b BULKLOOP 10/27/2004 22:55:34 PAGE 3
118 2 */
119 2 //根据端点2缓冲区数目多少来确定装载端点计数器的次数次数
120 2 SYNCDELAY;
121 2 EP2BCL = 0x80; // re(arm) EP2OUT
122 2 SYNCDELAY;
123 2 EP2BCL = 0x80; // re(arm) EP2OUT
124 2 // SYNCDELAY;
125 2 // EP2BCL = 0x80; // re(arm) EP2OUT
126 2 // SYNCDELAY;
127 2 // EP2BCL = 0x80; // re(arm) EP2OUT
128 2 }
129 1 }
*** WARNING C280 IN LINE 100 OF BULKLOOP.C: 'count': unreferenced local variable
*** WARNING C280 IN LINE 101 OF BULKLOOP.C: 'temp': unreferenced local variable
*** WARNING C280 IN LINE 102 OF BULKLOOP.C: 'i': unreferenced local variable
130
131 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
132 {
133 1 return(TRUE);
134 1 }
135
136 BOOL TD_Resume(void) // Called after the device resumes
137 {
138 1 return(TRUE);
139 1 }
140
141 //-----------------------------------------------------------------------------
142 // Device Request hooks
143 // The following hooks are called by the end point 0 device request parser.
144 //-----------------------------------------------------------------------------
145
146 BOOL DR_GetDescriptor(void)
147 {
148 1 return(TRUE);
149 1 }
150
151 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
152 {
153 1 Configuration = SETUPDAT[2];
154 1 return(TRUE); // Handled by user code
155 1 }
156
157 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
158 {
159 1 EP0BUF[0] = Configuration;
160 1 EP0BCH = 0;
161 1 EP0BCL = 1;
162 1 return(TRUE); // Handled by user code
163 1 }
164
165 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
166 {
167 1 AlternateSetting = SETUPDAT[2];
168 1 return(TRUE); // Handled by user code
169 1 }
170
171 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
172 {
173 1 EP0BUF[0] = AlternateSetting;
174 1 EP0BCH = 0;
175 1 EP0BCL = 1;
176 1 return(TRUE); // Handled by user code
C51 COMPILER V7.02b BULKLOOP 10/27/2004 22:55:34 PAGE 4
177 1 }
178
179 BOOL DR_GetStatus(void)
180 {
181 1 return(TRUE);
182 1 }
183
184 BOOL DR_ClearFeature(void)
185 {
186 1 return(TRUE);
187 1 }
188
189 BOOL DR_SetFeature(void)
190 {
191 1 return(TRUE);
192 1 }
193
194
195 #define VX_B2 0xB2 // get ENP2 CFG
196 #define VX_B3 0xB3 // get ENP4 CFG
197 #define VX_B4 0xB4 // get ENP6 CFG
198 #define VX_B5 0xB5 // get ENP8 CFG
199 #define VX_B6 0xB6 // get status
200 //#define VX_B6 0xB6 //get ENP2 CFG
201
202
203 BOOL DR_VendorCmnd(void)
204 {
205 1 BYTE tmp;
206 1
207 1 switch (SETUPDAT[1])
208 1 {
209 2 case VX_B2:
210 2 EP0BUF[0] = VX_B2;
211 2 SYNCDELAY;
212 2 EP0BUF[1] = EP2CFG;
213 2 SYNCDELAY;
214 2 EP0BCH = 0;
215 2 EP0BCL = 2;
216 2 EP0CS |= bmHSNAK;
217 2 break;
218 2 case VX_B3:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -