📄 fw.lst
字号:
156 TD_Poll();
157 }
158 }
159
160 // Device request parser
161 void SetupCommand(void)
162 {
163 void *dscr_ptr;
164 DWORD i;
165
166 switch(SETUPDAT[1])
167 {
168 case SC_GET_DESCRIPTOR: // *** Get Descriptor
169 if(DR_GetDescriptor())
170 switch(SETUPDAT[3])
171 {
172 case GD_DEVICE: // Device
173 SUDPTRH = MSB(pDeviceDscr);
174 SUDPTRL = LSB(pDeviceDscr);
C51 COMPILER V6.10 FW 09/04/2002 22:22:08 PAGE 4
175 break;
176 case GD_CONFIGURATION: // Configuration
177 if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
178 {
179 SUDPTRH = MSB(dscr_ptr);
180 SUDPTRL = LSB(dscr_ptr);
181 }
182 else
183 EZUSB_STALL_EP0(); // Stall End Point 0
184 break;
185 case GD_STRING: // String
186 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
187 {
188 // Workaround for rev D errata number 8
189 // If you're certain that you will never run on rev D,
190 // you can just do this:
191 // SUDPTRH = MSB(dscr_ptr);
192 // SUDPTRL = LSB(dscr_ptr);
193 STRINGDSCR *sdp;
194 BYTE len;
195
196 sdp = dscr_ptr;
197
198 len = sdp->length;
199 if (len > SETUPDAT[6])
200 len = SETUPDAT[6]; //limit to the requested length
201
202 while (len)
203 {
204 for(i=0; i<min(len,64); i++)
205 *(IN0BUF+i) = *((BYTE xdata *)sdp+i);
206
207 //set length and arm Endpoint
208 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));
209 len -= min(len,64);
210 (BYTE *)sdp += 64;
211
212 // Wait for it to go out (Rev C and above)
213 while(EP0CS & 0x04)
214 ;
215 }
216
217 // Arm a 0 length packet just in case. There was some reflector traffic about
218 // Apple hosts asking for too much data. This will keep them happy and will
219 // not hurt valid hosts because the next SETUP will clear this.
220 EZUSB_SET_EP_BYTES(IN0BUF_ID,0);
221 // Clear the HS-nak bit
222 EP0CS = bmHS;
223 }
224 else
225 EZUSB_STALL_EP0(); // Stall End Point 0
226 break;
227 default: // Invalid request
228 EZUSB_STALL_EP0(); // Stall End Point 0
229 }
230 break;
231 case SC_GET_INTERFACE: // *** Get Interface
232 DR_GetInterface();
233 break;
234 case SC_SET_INTERFACE: // *** Set Interface
235 DR_SetInterface();
236 break;
C51 COMPILER V6.10 FW 09/04/2002 22:22:08 PAGE 5
237 case SC_SET_CONFIGURATION: // *** Set Configuration
238 DR_SetConfiguration();
239 break;
240 case SC_GET_CONFIGURATION: // *** Get Configuration
241 DR_GetConfiguration();
242 break;
243 case SC_GET_STATUS: // *** Get Status
244 if(DR_GetStatus())
245 switch(SETUPDAT[0])
246 {
247 case GS_DEVICE: // Device
248 IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
249 IN0BUF[1] = 0;
250 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
251 break;
252 case GS_INTERFACE: // Interface
253 IN0BUF[0] = 0;
254 IN0BUF[1] = 0;
255 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
256 break;
257 case GS_ENDPOINT: // End Point
258 IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
259 IN0BUF[1] = 0;
260 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
261 break;
262 default: // Invalid Command
263 EZUSB_STALL_EP0(); // Stall End Point 0
264 }
265 break;
266 case SC_CLEAR_FEATURE: // *** Clear Feature
267 if(DR_ClearFeature())
268 switch(SETUPDAT[0])
269 {
270 case FT_DEVICE: // Device
271 if(SETUPDAT[2] == 1)
272 Rwuen = FALSE; // Disable Remote Wakeup
273 else
274 EZUSB_STALL_EP0(); // Stall End Point 0
275 break;
276 case FT_ENDPOINT: // End Point
277 if(SETUPDAT[2] == 0)
278 {
279 EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
280 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
281 }
282 else
283 EZUSB_STALL_EP0(); // Stall End Point 0
284 break;
285 }
286 break;
287 case SC_SET_FEATURE: // *** Set Feature
288 if(DR_SetFeature())
289 switch(SETUPDAT[0])
290 {
291 case FT_DEVICE: // Device
292 if(SETUPDAT[2] == 1)
293 Rwuen = TRUE; // Enable Remote Wakeup
294 else
295 EZUSB_STALL_EP0(); // Stall End Point 0
296 break;
297 case FT_ENDPOINT: // End Point
298 if(SETUPDAT[2] == 0)
C51 COMPILER V6.10 FW 09/04/2002 22:22:08 PAGE 6
299 EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
300 else
301 EZUSB_STALL_EP0(); // Stall End Point 0
302 break;
303 }
304 break;
305 default: // *** Invalid Command
306 if(DR_VendorCmnd())
307 EZUSB_STALL_EP0(); // Stall End Point 0
308 }
309
310 // Acknowledge handshake phase of device request
311 // Required for rev C does not effect rev B
312 EP0CS |= bmBIT1;
313 }
314
315 // Wake-up interrupt handler
316 void resume_isr(void) interrupt WKUP_VECT
317 {
318 EZUSB_CLEAR_RSMIRQ();
319 }
C51 COMPILATION COMPLETE. 0 WARNING(S), 3 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -