📄 bulksrc.lst
字号:
C51 COMPILER V7.06 BULKSRC 01/02/2001 01:38:00 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE BULKSRC
OBJECT MODULE PLACED IN bulksrc.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bulksrc.c DEBUG OBJECTEXTEND
stmt level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: bulksrc.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // $Archive: /USB/Examples/FX2LP/bulksrc/bulksrc.c $
7 // $Date: 3/23/05 2:56p $
8 // $Revision: 3 $
9 //
10 // Copyright (c) 2000 Cypress Semiconductor All rights reserved
11 //-----------------------------------------------------------------------------
12 #include "fx2.h"
13 #include "fx2regs.h"
14 #include "syncdly.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 BYTE xdata myBuffer[512];
24 WORD myBufferCount;
25 WORD packetSize;
26
27 //-----------------------------------------------------------------------------
28 // Task Dispatcher hooks
29 // The following hooks are called by the task dispatcher.
30 //-----------------------------------------------------------------------------
31
32 void TD_Init(void) // Called once at startup
33 {
34 1 int i;
35 1
36 1 // set the CPU clock to 48MHz
37 1 // CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ; //Fans:default:12MHz
38 1
39 1 // set the slave FIFO interface to 48MHz
40 1 IFCONFIG |= 0x40;
41 1 EP1OUTCFG = 0xA0;
42 1 EP1INCFG = 0xA0;
43 1 SYNCDELAY; // see TRM section 15.14
44 1 EP2CFG = 0xA2;
45 1 SYNCDELAY; //
46 1 EP4CFG = 0xA0;
47 1 SYNCDELAY; //
48 1 EP6CFG = 0xE2;
49 1 SYNCDELAY; //
50 1 EP8CFG = 0xE0;
51 1
52 1 // out endpoints do not come up armed
53 1
54 1 // since the defaults are double buffered we must write dummy byte counts twice
55 1 SYNCDELAY; //
C51 COMPILER V7.06 BULKSRC 01/02/2001 01:38:00 PAGE 2
56 1 EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip.
57 1 SYNCDELAY; //
58 1 EP4BCL = 0x80;
59 1 SYNCDELAY; //
60 1 EP2BCL = 0x80; // arm EP4OUT by writing byte count w/skip.
61 1 SYNCDELAY; //
62 1 EP4BCL = 0x80;
63 1
64 1 // fill up both IN endpoints
65 1
66 1 for (i=0;i<512;i++)
67 1 EP6FIFOBUF[i] = i+2;
68 1 SYNCDELAY; //
69 1 EP6BCH = 0x02;
70 1 SYNCDELAY; //
71 1 EP6BCL = 0x00;
72 1
73 1 for (i=0;i<512;i++)
74 1 EP6FIFOBUF[i] = i+2;
75 1 SYNCDELAY; //
76 1 EP6BCH = 0x02;
77 1 SYNCDELAY; //
78 1 EP6BCL = 0x00;
79 1
80 1 myBufferCount = 0;
81 1
82 1 // enable dual autopointer(s)
83 1 AUTOPTRSETUP |= 0x01;
84 1
85 1 OEA = 0XFF;
86 1 //IOA = 0X55; 端点测试程序
87 1 PA5=1;
88 1 PA6=0;
89 1 PA7=1;
90 1
91 1 }
92
93 void TD_Poll(void) // Called repeatedly while the device is idle
94 {
95 1 int i;
96 1
97 1 // if there is some data in EP2 OUT, re-arm it
98 1 if(!(EP2468STAT & bmEP2EMPTY))
99 1 {
100 2 SYNCDELAY; //
101 2 EP2BCL = 0x80;
102 2 }
103 1
104 1 // if EP6 IN is available, re-arm it
105 1 if(!(EP2468STAT & bmEP6FULL))
106 1 {
107 2 SYNCDELAY; //
108 2 EP6BCH = 0x02;
109 2 SYNCDELAY; //
110 2 EP6BCL = 0x00;
111 2 }
112 1
113 1 // if there is new data in EP4FIFOBUF, then copy it to a temporary buffer
114 1 if(!(EP2468STAT & bmEP4EMPTY))
115 1 {
116 2 APTR1H = MSB( &EP4FIFOBUF );
117 2 APTR1L = LSB( &EP4FIFOBUF );
C51 COMPILER V7.06 BULKSRC 01/02/2001 01:38:00 PAGE 3
118 2
119 2 AUTOPTRH2 = MSB( &myBuffer );
120 2 AUTOPTRL2 = LSB( &myBuffer );
121 2
122 2 myBufferCount = (EP4BCH << 8) + EP4BCL;
123 2
124 2 for( i = 0x0000; i < myBufferCount; i++ )
125 2 {
126 3 EXTAUTODAT2 = EXTAUTODAT1;
127 3 }
128 2
129 2 SYNCDELAY; //
130 2 EP4BCL = 0x80; // re(arm) EP4OUT
131 2 }
132 1
133 1 // if there is room in EP8IN, then copy the contents of the temporarty buffer to it
134 1 if(!(EP2468STAT & bmEP8FULL) && myBufferCount)
135 1 {
136 2 APTR1H = MSB( &myBuffer );
137 2 APTR1L = LSB( &myBuffer );
138 2
139 2 AUTOPTRH2 = MSB( &EP8FIFOBUF );
140 2 AUTOPTRL2 = LSB( &EP8FIFOBUF );
141 2
142 2 for( i = 0x0000; i < myBufferCount; i++ )
143 2 {
144 3 // setup to transfer EP4OUT buffer to EP8IN buffer using AUTOPOINTER(s) in SFR space
145 3 EXTAUTODAT2 = EXTAUTODAT1;
146 3 }
147 2 SYNCDELAY; //
148 2 EP8BCH = MSB(myBufferCount);
149 2 SYNCDELAY; //
150 2 EP8BCL = LSB(myBufferCount); // arm EP8IN
151 2 }
152 1
153 1 }
154
155 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
156 {
157 1 return(TRUE);
158 1 }
159
160 BOOL TD_Resume(void) // Called after the device resumes
161 {
162 1 return(TRUE);
163 1 }
164
165 //-----------------------------------------------------------------------------
166 // Device Request hooks
167 // The following hooks are called by the end point 0 device request parser.
168 //-----------------------------------------------------------------------------
169
170 BOOL DR_GetDescriptor(void)
171 {
172 1 return(TRUE);
173 1 }
174
175 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
176 {
177 1 Configuration = SETUPDAT[2];
178 1 return(TRUE); // Handled by user code
179 1 }
C51 COMPILER V7.06 BULKSRC 01/02/2001 01:38:00 PAGE 4
180
181 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
182 {
183 1 EP0BUF[0] = Configuration;
184 1 EP0BCH = 0;
185 1 EP0BCL = 1;
186 1 return(TRUE); // Handled by user code
187 1 }
188
189 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
190 {
191 1 AlternateSetting = SETUPDAT[2];
192 1 return(TRUE); // Handled by user code
193 1 }
194
195 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
196 {
197 1 EP0BUF[0] = AlternateSetting;
198 1 EP0BCH = 0;
199 1 EP0BCL = 1;
200 1 return(TRUE); // Handled by user code
201 1 }
202
203 BOOL DR_GetStatus(void)
204 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -