📄 bulkext.lst
字号:
C51 COMPILER V7.02a BULKEXT 12/02/2005 17:56:12 PAGE 1
C51 COMPILER V7.02a, COMPILATION OF MODULE BULKEXT
OBJECT MODULE PLACED IN bulkext.OBJ
COMPILER INVOKED BY: c:\Keil\C51\BIN\C51.EXE bulkext.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: bulkext.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // performs loopback on EP2OUT->EP6IN and EP4OUT->EP8IN
7 // this code uses the external auto pointers to first move the data
8 // to external RAM (0x2800) before looping back to the IN endpoint.
9 //
10 // Copyright (c) 2000 Cypress Semiconductor All rights reserved
11 //-----------------------------------------------------------------------------
12 #include "fx2.h"
13 #include "fx2regs.h"
14 #include "fx2sdly.h" // SYNCDELAY macro
15
16 extern BOOL GotSUD; // Received setup data flag
17 extern BOOL Sleep;
18 extern BOOL Rwuen;
19 extern BOOL Selfpwr;
20
21 BYTE Configuration; // Current configuration
22 BYTE AlternateSetting; // Alternate settings
23 WORD j=0;
24 extern BYTE xdata Digit[];
25 //-----------------------------------------------------------------------------
26 // Task Dispatcher hooks
27 // The following hooks are called by the task dispatcher.
28 //-----------------------------------------------------------------------------
29
30
31 void TD_Init(void) // Called once at startup
32 {
33 1
34 1 EZUSB_InitI2C(); // Initialize EZ-USB I2C controller
35 1 // Registers which require a synchronization delay, see section 15.14
36 1 // FIFORESET FIFOPINPOLAR
37 1 // INPKTEND OUTPKTEND
38 1 // EPxBCH:L REVCTL
39 1 // GPIFTCB3 GPIFTCB2
40 1 // GPIFTCB1 GPIFTCB0
41 1 // EPxFIFOPFH:L EPxAUTOINLENH:L
42 1 // EPxFIFOCFG EPxGPIFFLGSEL
43 1 // PINFLAGSxx EPxFIFOIRQ
44 1 // EPxFIFOIE GPIFIRQ
45 1 // GPIFIE GPIFADRH:L
46 1 // UDMACRCH:L EPxGPIFTRIG
47 1 // GPIFTRIG
48 1
49 1 // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
50 1 // ...these have been replaced by GPIFTC[B3:B0] registers
51 1
52 1 // default: all endpoints have their VALID bit set
53 1 // default: TYPE1 = 1 and TYPE0 = 0 --> BULK
54 1 // default: EP2 and EP4 DIR bits are 0 (OUT direction)
55 1 // default: EP6 and EP8 DIR bits are 1 (IN direction)
C51 COMPILER V7.02a BULKEXT 12/02/2005 17:56:12 PAGE 2
56 1 // default: EP2, EP4, EP6, and EP8 are double buffered
57 1
58 1 // we are just using the default values, yes this is not necessary...
59 1 EP1OUTCFG = 0xA0;
60 1 EP1INCFG = 0xA0;
61 1 SYNCDELAY; // see TRM section 15.14
62 1 EP2CFG = 0xA2;
63 1 SYNCDELAY;
64 1 EP4CFG = 0xA0;
65 1 SYNCDELAY;
66 1 EP6CFG = 0xE2;
67 1 SYNCDELAY;
68 1 EP8CFG = 0xE0;
69 1
70 1 // out endpoints do not come up armed
71 1
72 1 // since the defaults are double buffered we must write dummy byte counts twice
73 1 SYNCDELAY;
74 1 EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
75 1 SYNCDELAY;
76 1 EP2BCL = 0x80;
77 1 SYNCDELAY;
78 1 EP4BCL = 0x80; // arm EP4OUT by writing byte count w/skip.
79 1 SYNCDELAY;
80 1 EP4BCL = 0x80;
81 1
82 1 // enable dual autopointer feature
83 1 AUTOPTRSETUP |= 0x01;
84 1
85 1 Rwuen = TRUE; // Enable remote-wakeup
86 1
87 1
88 1 //enable
89 1 EPIRQ = 0xFF;
90 1 SYNCDELAY;
91 1 EPIE |= 0x50; //enable the EP0 IN ep2 & ep6
92 1
93 1 SYNCDELAY;
94 1
95 1
96 1
97 1 }
98
99
100
101
102
103 void TD_Poll(void) // Called repeatedly while the device is idle
104 {
105 1
106 1
107 1 WORD i;
108 1
109 1 WORD count;
110 1
111 1 if(!(EP2468STAT & bmEP4EMPTY))
112 1 { // check EP4 EMPTY(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is empty
113 2 if(!(EP2468STAT & bmEP8FULL))
114 2 { // check EP8 FULL(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is full
115 3 // setup AUTOPOINTER(s) in SFR space
116 3 // source is EP4OUT
117 3 AUTOPTR1H = MSB( &EP4FIFOBUF );
C51 COMPILER V7.02a BULKEXT 12/02/2005 17:56:12 PAGE 3
118 3 AUTOPTR1L = LSB( &EP4FIFOBUF );
119 3
120 3 count = (EP4BCH << 8) + EP4BCL;
121 3
122 3
123 3 AUTOPTRH2 = MSB( &EP8FIFOBUF );
124 3 AUTOPTRL2 = LSB( &EP8FIFOBUF );
125 3
126 3
127 3 for( i = 0x0000; i < count; i++ )
128 3 {
129 4 EXTAUTODAT2 = EXTAUTODAT1;
130 4 }
131 3
132 3
133 3 EP8BCH = EP4BCH;
134 3 SYNCDELAY;
135 3 EP8BCL = EP4BCL; // arm EP8IN
136 3 SYNCDELAY;
137 3 EP4BCL = 0x80; // re(arm) EP2OUT
138 3 SYNCDELAY;
139 3
140 3 }
141 2 }
142 1 j=j+1;
143 1 EZUSB_WriteI2C(0x21, 0x01, &(Digit[j]));
144 1 }
145
146 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
147 {
148 1 return(TRUE);
149 1 }
150
151 BOOL TD_Resume(void) // Called after the device resumes
152 {
153 1 return(TRUE);
154 1 }
155
156 //-----------------------------------------------------------------------------
157 // Device Request hooks
158 // The following hooks are called by the end point 0 device request parser.
159 //-----------------------------------------------------------------------------
160
161 BOOL DR_GetDescriptor(void)
162 {
163 1 return(TRUE);
164 1 }
165
166 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
167 {
168 1 Configuration = SETUPDAT[2];
169 1 return(TRUE); // Handled by user code
170 1 }
171
172 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
173 {
174 1 EP0BUF[0] = Configuration;
175 1 EP0BCH = 0;
176 1 EP0BCL = 1;
177 1 return(TRUE); // Handled by user code
178 1 }
179
C51 COMPILER V7.02a BULKEXT 12/02/2005 17:56:12 PAGE 4
180 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
181 {
182 1 AlternateSetting = SETUPDAT[2];
183 1 return(TRUE); // Handled by user code
184 1 }
185
186 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
187 {
188 1 EP0BUF[0] = AlternateSetting;
189 1 EP0BCH = 0;
190 1 EP0BCL = 1;
191 1 return(TRUE); // Handled by user code
192 1 }
193
194 BOOL DR_GetStatus(void)
195 {
196 1 return(TRUE);
197 1 }
198
199 BOOL DR_ClearFeature(void)
200 {
201 1 return(TRUE);
202 1 }
203
204 BOOL DR_SetFeature(void)
205 {
206 1 return(TRUE);
207 1 }
208
209 BOOL DR_VendorCmnd(void)
210 {
211 1 return(TRUE);
212 1 }
213
214 //-----------------------------------------------------------------------------
215 // USB Interrupt Handlers
216 // The following functions are called by the USB interrupt jump table.
217 //-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -