📄 fw.lst
字号:
235 1 CPUCS |=0x02;//保证时钟输出48M
236 1 CPUCS &=0xE7;//时钟分频12M
237 1 //CPUCS &=0xEF;//时钟分频12M
238 1 //CPUCS &=0xF7;//时钟分频48M
239 1 // CPUCS |=0x1A;//时钟分频48M
240 1
241 1
C51 COMPILER V7.09 FW 04/03/2007 16:19:12 PAGE 5
242 1
243 1
244 1 ///////////////////////////////////////////
245 1
246 1 CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)
247 1
248 1 // clear the Sleep flag.
249 1 Sleep = FALSE;
250 1 memset(DispBuf,16,4);//无显示数据
251 1 // Task Dispatcher
252 1 while(TRUE) // Main Loop
253 1 {
254 2 //////////////////////////////////////////////////////////
255 2 //OEB=0x00;
256 2
257 2 /* OEA=0xFF;
258 2 OEC=0xFF;
259 2 PORTACFG=0x00;
260 2 IOA=0xFF;
261 2 IOC=0xFF;
262 2 */
263 2 ///////////////////////////////////////////////////////////
264 2
265 2
266 2 if(GotSUD) // Wait for SUDAV
267 2 {
268 3 SetupCommand(); // Implement setup command
269 3 GotSUD = FALSE; // Clear SUDAV flag
270 3 }
271 2 //如果GotSUD为一表示SETUP数据到了,程序调用SetupCommand()。
272 2 // Poll User Device
273 2 // NOTE: Idle mode stops the processor clock. There are only two
274 2 // ways out of idle mode, the WAKEUP pin, and detection of the USB
275 2 // resume state on the USB bus. The timers will stop and the
276 2 // processor will not wake up on any other interrupts.
277 2 if (Sleep)
278 2 {
279 3 if(TD_Suspend())
280 3 {
281 4 Sleep = FALSE; // Clear the "go to sleep" flag. Do it here to prevent any race c
-ondition between wakeup and the next sleep.
282 4 do
283 4 {
284 5 EZUSB_Susp(); // Place processor in idle mode.
285 5 }
286 4 while(!Rwuen && EZUSB_EXTWAKEUP());
287 4 // Must continue to go back into suspend if the host has disabled remote wakeup
288 4 // *and* the wakeup was caused by the external wakeup pin.
289 4
290 4 // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
291 4 EZUSB_Resume(); // If source is the Wakeup# pin, signal the host to Resume.
292 4 TD_Resume();
293 4 }
294 3 }
295 2 TD_Poll();//设备停滞时调用
296 2 Led_Display();//LED的显示不停调用
297 2 temp_data = OKey_RP_Scan();//输出按钮的值
298 2 //----------------------------------------
299 2 ad0809();
300 2 //*************************************************************************//
301 2
302 2 // AD0809= ad0809();
C51 COMPILER V7.09 FW 04/03/2007 16:19:12 PAGE 6
303 2
304 2
305 2 //*************************************************************************//
306 2 //----------------------------------------
307 2 if(temp_data != 0xFF)
308 2 {
309 3 OKey_Value = temp_data;
310 3 }
311 2 }
312 1 }
313
314 // Device request parser
315 //实现控制传输的数据和状态阶段
316 void SetupCommand(void)
317 {
318 1 void *dscr_ptr;
319 1
320 1 switch(SETUPDAT[1]) //判断,既是第一个字段,表示不同的请求!
321 1 {
322 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor取描述符号//-------06
323 2 if(DR_GetDescriptor())
324 2 switch(SETUPDAT[3]) //看wValuel的值是多少
325 2 {
326 3 case GD_DEVICE: // Device如果是设备描述符号?01
327 3 SUDPTRH = MSB(pDeviceDscr);//SUDPTRH是什么意思?
328 3 SUDPTRL = LSB(pDeviceDscr);
329 3 break;
330 3 case GD_DEVICE_QUALIFIER: // Device Qualifier设备限定06
331 3 SUDPTRH = MSB(pDeviceQualDscr);
332 3 SUDPTRL = LSB(pDeviceQualDscr);
333 3 break;
334 3 case GD_CONFIGURATION: // Configuration配置02
335 3 SUDPTRH = MSB(pConfigDscr);
336 3 SUDPTRL = LSB(pConfigDscr);
337 3 break;
338 3 case GD_OTHER_SPEED_CONFIGURATION: // Other Speed Configuration其他速度配置07
339 3 SUDPTRH = MSB(pOtherConfigDscr);
340 3 SUDPTRL = LSB(pOtherConfigDscr);
341 3 break;
342 3 case GD_STRING: // String字符串03
343 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
344 3 {
345 4 SUDPTRH = MSB(dscr_ptr);
346 4 SUDPTRL = LSB(dscr_ptr);
347 4 }
348 3 else
349 3 EZUSB_STALL_EP0(); // Stall End Point 0
350 3 break;
351 3 default: // Invalid request
352 3 EZUSB_STALL_EP0(); // Stall End Point 0
353 3 }
354 2 break;
355 2 //-------------------------------------------------以上程序获取描述符号
356 2 case SC_GET_INTERFACE: // *** Get Interface-----0A
357 2 DR_GetInterface();
358 2 break;
359 2 //-------------------------------------------------获取接口---------
360 2 case SC_SET_INTERFACE: // *** Set Interface
361 2 DR_SetInterface();
362 2 break;
363 2 //-------------------------------------------------设置接口---------
364 2 case SC_SET_CONFIGURATION: // *** Set Configuration
C51 COMPILER V7.09 FW 04/03/2007 16:19:12 PAGE 7
365 2 DR_SetConfiguration();
366 2 break;
367 2 //-------------------------------------------------------------------
368 2 case SC_GET_CONFIGURATION: // *** Get Configuration--08
369 2 DR_GetConfiguration();
370 2 break;
371 2 //-------------------------------------------------------------------
372 2 case SC_GET_STATUS: // *** Get Status获取状态
373 2 if(DR_GetStatus())
374 2 switch(SETUPDAT[0]) //第一位
375 2 {
376 3 case GS_DEVICE: // Device----80
377 3 EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
378 3 EP0BUF[1] = 0;
379 3 EP0BCH = 0;
380 3 EP0BCL = 2;
381 3 break;
382 3 case GS_INTERFACE: // Interface----81
383 3 EP0BUF[0] = 0;
384 3 EP0BUF[1] = 0;
385 3 EP0BCH = 0;
386 3 EP0BCL = 2;
387 3 break;
388 3 case GS_ENDPOINT: // End Point-----82
389 3 EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
390 3 EP0BUF[1] = 0;
391 3 EP0BCH = 0;
392 3 EP0BCL = 2;
393 3 break;
394 3 default: // Invalid Command
395 3 EZUSB_STALL_EP0(); // Stall End Point 0
396 3 }
397 2 break;
398 2 //--------------------------------------------------------------------------
399 2 case SC_CLEAR_FEATURE: // *** Clear Feature清除特征
400 2 if(DR_ClearFeature())
401 2 switch(SETUPDAT[0]) //
402 2 {
403 3 case FT_DEVICE: // Device-----清除设备特征
404 3 if(SETUPDAT[2] == 1)
405 3 Rwuen = FALSE; // Disable Remote Wakeup
406 3 else
407 3 EZUSB_STALL_EP0(); // Stall End Point 0
408 3 break;
409 3 case FT_ENDPOINT: // End Point-----02清除端点特征
410 3 if(SETUPDAT[2] == 0)
411 3 {
412 4 *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
413 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
414 4 }
415 3 else
416 3 EZUSB_STALL_EP0(); // Stall End Point 0
417 3 break;
418 3 }
419 2 break;
420 2 //---------------------------------------------------------------------------
421 2 case SC_SET_FEATURE: // *** Set Feature-----03
422 2 if(DR_SetFeature())
423 2 switch(SETUPDAT[0])
424 2 {
425 3 case FT_DEVICE: // Device--00
426 3 if(SETUPDAT[2] == 1)
C51 COMPILER V7.09 FW 04/03/2007 16:19:12 PAGE 8
427 3 Rwuen = TRUE; // Enable Remote Wakeup
428 3 else if(SETUPDAT[2] == 2)
429 3 // Set Feature Test Mode. The core handles this request. However, it is
430 3 // necessary for the firmware to complete the handshake phase of the
431 3 // control transfer before the chip will enter test mode. It is also
432 3 // necessary for FX2 to be physically disconnected (D+ and D-)
433 3 // from the host before it will enter test mode.
434 3 break;
435 3 else
436 3 EZUSB_STALL_EP0(); // Stall End Point 0
437 3 break;
438 3 case FT_ENDPOINT: // End Point---02
439 3 *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
440 3 break;
441 3 }
442 2 break;
443 2 default: // *** Invalid Command
444 2 if(DR_VendorCmnd())
445 2 EZUSB_STALL_EP0(); // Stall End Point 0
446 2 }
447 1
448 1 // Acknowledge handshake phase of device request
449 1 EP0CS |= bmHSNAK;
450 1
451 1 }
452
453 // Wake-up interrupt handler
454 void resume_isr(void) interrupt WKUP_VECT
455 {
456 1 EZUSB_CLEAR_RSMIRQ();
457 1 }
458
459
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1043 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 14 17
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 + -