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