📄 fw.lst
字号:
193 2 if (Sleep)
194 2 {
195 3 if(TD_Suspend())
196 3 {
197 4 Sleep = FALSE; // Clear the "go to sleep" flag. Do it here to prevent any race condition
-between wakeup and the next sleep.
198 4 do
199 4 {
200 5 EZUSB_Susp(); // Place processor in idle mode.
201 5 }
202 4 while(!Rwuen && EZUSB_EXTWAKEUP());
203 4 // above. Must continue to go back into suspend if the host has disabled remote wakeup
204 4 // *and* the wakeup was caused by the external wakeup pin.
205 4
206 4 // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
207 4 EZUSB_Resume(); // If source is the Wakeup# pin, signal the host to Resume.
208 4 TD_Resume();
209 4 }
210 3 }
211 2
212 2 }
213 1 }
214
215 BOOL HighSpeedCapable()
216 {
217 1 // this function determines if the chip is high-speed capable.
218 1 // FX2 and FX2LP are high-speed capable. FX1 is not - it does
219 1 // not have a high-speed transceiver.
220 1
221 1 if (GPCR2 & bmFULLSPEEDONLY)
222 1 return FALSE;
223 1 else
224 1 return TRUE;
225 1
226 1 #endif
227 1 }
228
229 // Device request parser
230 void SetupCommand(void)
231 {
232 1 void *dscr_ptr;
233 1
234 1 switch(SETUPDAT[1])
235 1 {
236 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
237 2 if(DR_GetDescriptor())
238 2 switch(SETUPDAT[3])
239 2 {
240 3 case GD_DEVICE: // Device
C51 COMPILER V7.50 FW 09/10/2007 10:17:59 PAGE 5
241 3 SUDPTRH = MSB(pDeviceDscr);
242 3 SUDPTRL = LSB(pDeviceDscr);
243 3 break;
244 3 case GD_DEVICE_QUALIFIER: // Device Qualifier
245 3 // only retuen a device qualifier if this is a high speed
246 3 // capable chip.
247 3 if (HighSpeedCapable())
248 3 {
249 4 SUDPTRH = MSB(pDeviceQualDscr);
250 4 SUDPTRL = LSB(pDeviceQualDscr);
251 4 }
252 3 else
253 3 {
254 4 EZUSB_STALL_EP0();
255 4 }
256 3 break;
257 3 case GD_CONFIGURATION: // Configuration
258 3 SUDPTRH = MSB(pConfigDscr);
259 3 SUDPTRL = LSB(pConfigDscr);
260 3 break;
261 3 case GD_OTHER_SPEED_CONFIGURATION: // Other Speed Configuration
262 3 SUDPTRH = MSB(pOtherConfigDscr);
263 3 SUDPTRL = LSB(pOtherConfigDscr);
264 3 break;
265 3 case GD_STRING: // String
266 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
267 3 {
268 4 SUDPTRH = MSB(dscr_ptr);
269 4 SUDPTRL = LSB(dscr_ptr);
270 4 }
271 3 else
272 3 EZUSB_STALL_EP0(); // Stall End Point 0
273 3 break;
274 3 default: // Invalid request
275 3 EZUSB_STALL_EP0(); // Stall End Point 0
276 3 }
277 2 break;
278 2 case SC_GET_INTERFACE: // *** Get Interface
279 2 DR_GetInterface();
280 2 break;
281 2 case SC_SET_INTERFACE: // *** Set Interface
282 2 DR_SetInterface();
283 2 break;
284 2 case SC_SET_CONFIGURATION: // *** Set Configuration
285 2 DR_SetConfiguration();
286 2 break;
287 2 case SC_GET_CONFIGURATION: // *** Get Configuration
288 2 DR_GetConfiguration();
289 2 break;
290 2 case SC_GET_STATUS: // *** Get Status
291 2 if(DR_GetStatus())
292 2 switch(SETUPDAT[0])
293 2 {
294 3 case GS_DEVICE: // Device
295 3 EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
296 3 EP0BUF[1] = 0;
297 3 EP0BCH = 0;
298 3 EP0BCL = 2;
299 3 break;
300 3 case GS_INTERFACE: // Interface
301 3 EP0BUF[0] = 0;
302 3 EP0BUF[1] = 0;
C51 COMPILER V7.50 FW 09/10/2007 10:17:59 PAGE 6
303 3 EP0BCH = 0;
304 3 EP0BCL = 2;
305 3 break;
306 3 case GS_ENDPOINT: // End Point
307 3 EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
308 3 EP0BUF[1] = 0;
309 3 EP0BCH = 0;
310 3 EP0BCL = 2;
311 3 break;
312 3 default: // Invalid Command
313 3 EZUSB_STALL_EP0(); // Stall End Point 0
314 3 }
315 2 break;
316 2 case SC_CLEAR_FEATURE: // *** Clear Feature
317 2 if(DR_ClearFeature())
318 2 switch(SETUPDAT[0])
319 2 {
320 3 case FT_DEVICE: // Device
321 3 if(SETUPDAT[2] == 1)
322 3 Rwuen = FALSE; // Disable Remote Wakeup
323 3 else
324 3 EZUSB_STALL_EP0(); // Stall End Point 0
325 3 break;
326 3 case FT_ENDPOINT: // End Point
327 3 if(SETUPDAT[2] == 0)
328 3 {
329 4 *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
330 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
331 4 }
332 3 else
333 3 EZUSB_STALL_EP0(); // Stall End Point 0
334 3 break;
335 3 }
336 2 break;
337 2 case SC_SET_FEATURE: // *** Set Feature
338 2 if(DR_SetFeature())
339 2 switch(SETUPDAT[0])
340 2 {
341 3 case FT_DEVICE: // Device
342 3 if(SETUPDAT[2] == 1)
343 3 Rwuen = TRUE; // Enable Remote Wakeup
344 3 else if(SETUPDAT[2] == 2)
345 3 // Set Feature Test Mode. The core handles this request. However, it is
346 3 // necessary for the firmware to complete the handshake phase of the
347 3 // control transfer before the chip will enter test mode. It is also
348 3 // necessary for FX2 to be physically disconnected (D+ and D-)
349 3 // from the host before it will enter test mode.
350 3 break;
351 3 else
352 3 EZUSB_STALL_EP0(); // Stall End Point 0
353 3 break;
354 3 case FT_ENDPOINT: // End Point
355 3 *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
356 3 break;
357 3 default:
358 3 EZUSB_STALL_EP0(); // Stall End Point 0
359 3 }
360 2 break;
361 2 default: // *** Invalid Command
362 2 if(DR_VendorCmnd())
363 2 EZUSB_STALL_EP0(); // Stall End Point 0
364 2 }
C51 COMPILER V7.50 FW 09/10/2007 10:17:59 PAGE 7
365 1
366 1 // Acknowledge handshake phase of device request
367 1 EP0CS |= bmHSNAK;
368 1 }
369
370 // Wake-up interrupt handler
371 void resume_isr(void) interrupt WKUP_VECT
372 {
373 1 EZUSB_CLEAR_RSMIRQ();
374 1 }
375
376
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1070 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 14 16
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -