📄 f34x_usb_standard_requests.lst
字号:
404 3 Force_Stall();
405 3 }
406 2 break;
407 2
408 2 default:
409 2 Force_Stall(); // Send Stall if unsupported request
410 2 break;
411 2 }
412 1
413 1 if (Setup.wValue.c[MSB] == DSC_DEVICE || // Verify that the requested descriptor is
414 1 Setup.wValue.c[MSB] == DSC_CONFIG || // valid
415 1 Setup.wValue.c[MSB] == DSC_STRING ||
416 1 Setup.wValue.c[MSB] == DSC_INTERFACE ||
417 1 Setup.wValue.c[MSB] == DSC_ENDPOINT)
418 1 {
419 2 if ((Setup.wLength.c[LSB] < DataSize) &&
420 2 (Setup.wLength.c[MSB] == 0))
421 2 {
422 3 DataSize = Setup.wLength.i; // Send only requested amount of data
423 3 }
424 2 }
425 1 if (Ep_Status[0] != EP_STALL) // Make sure endpoint not in stall mode
426 1 {
427 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Service Setup Packet
C51 COMPILER V7.50 F34X_USB_STANDARD_REQUESTS 08/01/2007 13:13:23 PAGE 8
428 2 Ep_Status[0] = EP_TX; // Put endpoint in transmit mode
429 2 DataSent = 0; // Reset Data Sent counter
430 2 }
431 1 }
432
433 //-----------------------------------------------------------------------------
434 // Get_Configuration
435 //-----------------------------------------------------------------------------
436 //
437 // Return Value : None
438 // Parameters : None
439 //
440 // This routine returns current configuration value
441 //
442 //-----------------------------------------------------------------------------
443
444 void Get_Configuration(void)
445 {
446 1 if ((Setup.bmRequestType != OUT_DEVICE) ||// This request must be directed to the device
447 1 Setup.wValue.c[MSB] || Setup.wValue.c[LSB]||// with value word set to zero
448 1 Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB]||// and index set to zero
449 1 Setup.wLength.c[MSB] || (Setup.wLength.c[LSB] != 1))// and setup length set to one
450 1 {
451 2 Force_Stall(); // Otherwise send a stall to host
452 2 }
453 1
454 1 else
455 1 {
456 2 if (USB_State == DEV_CONFIGURED) // If the device is configured, then return value 0x01
457 2 { // since this software only supports one configuration
458 3 DataPtr = (BYTE*)&ONES_PACKET;
459 3 DataSize = 1;
460 3 }
461 2 if (USB_State == DEV_ADDRESS) // If the device is in address state, it is not
462 2 { // configured, so return 0x00
463 3 DataPtr = (BYTE*)&ZERO_PACKET;
464 3 DataSize = 1;
465 3 }
466 2 }
467 1 if (Ep_Status[0] != EP_STALL)
468 1 {
469 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Set Serviced Out Packet bit
470 2 Ep_Status[0] = EP_TX; // Put endpoint into transmit mode
471 2 DataSent = 0; // Reset Data Sent counter to zero
472 2 }
473 1 }
474
475 //-----------------------------------------------------------------------------
476 // Set_Configuration
477 //-----------------------------------------------------------------------------
478 //
479 // Return Value : None
480 // Parameters : None
481 //
482 // This routine allows host to change current device configuration value
483 //
484 //-----------------------------------------------------------------------------
485
486 void Set_Configuration(void)
487 {
488 1
489 1 if ((USB_State == DEV_DEFAULT) ||// Device must be addressed before configured
C51 COMPILER V7.50 F34X_USB_STANDARD_REQUESTS 08/01/2007 13:13:23 PAGE 9
490 1 (Setup.bmRequestType != IN_DEVICE) ||// and request recipient must be the device
491 1 Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB]||// the index and length words must be zero
492 1 Setup.wLength.c[MSB] || Setup.wLength.c[LSB] ||
493 1 Setup.wValue.c[MSB] || (Setup.wValue.c[LSB] > 1))// This software only supports config = 0,1
494 1 {
495 2 Force_Stall(); // Send stall if setup data is invalid
496 2 }
497 1
498 1 else
499 1 {
500 2 if (Setup.wValue.c[LSB] > 0) // Any positive configuration request
501 2 { // results in configuration being set to 1
502 3 USB_State = DEV_CONFIGURED;
503 3 Ep_Status[1] = EP_IDLE; // Set endpoint status to idle (enabled)
504 3 Ep_Status[2] = EP_IDLE;
505 3 POLL_WRITE_BYTE(INDEX, 1); // Change index to endpoint 1
506 3 POLL_WRITE_BYTE(EINCSR2, rbInDIRSEL); // Set DIRSEL to indicate endpoint 1 is IN
507 3 Handle_In1(); // Put first data packet on fifo
508 3 POLL_WRITE_BYTE(INDEX, 0); // Set index back to endpoint 0
509 3 }
510 2 else
511 2 {
512 3 USB_State = DEV_ADDRESS; // Unconfigures device by setting state to
513 3 Ep_Status[1] = EP_HALT; // address, and changing endpoint 1 and 2
514 3 Ep_Status[2] = EP_HALT; // status to halt
515 3 }
516 2 }
517 1 if (Ep_Status[0] != EP_STALL)
518 1 {
519 2 // Indicate setup packet has been serviced
520 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
521 2 }
522 1 }
523
524 //-----------------------------------------------------------------------------
525 // Get_Interface
526 //-----------------------------------------------------------------------------
527 //
528 // Return Value : None
529 // Parameters : None
530 //
531 // This routine returns 0x00, since only one interface is supported by
532 // this firmware
533 //
534 //-----------------------------------------------------------------------------
535
536 void Get_Interface(void)
537 {
538 1
539 1 if ((USB_State != DEV_CONFIGURED) || // If device is not configured
540 1 (Setup.bmRequestType != OUT_INTERFACE) || // or recipient is not an interface
541 1 Setup.wValue.c[MSB] ||Setup.wValue.c[LSB] ||// or non-zero value or index fields
542 1 Setup.wIndex.c[MSB] ||Setup.wIndex.c[LSB] ||// or data length not equal to one
543 1 Setup.wLength.c[MSB] ||(Setup.wLength.c[LSB] != 1))
544 1 {
545 2 Force_Stall(); // Then return stall due to invalid request
546 2 }
547 1
548 1 else
549 1 {
550 2 DataPtr = (BYTE*)&ZERO_PACKET; // Otherwise, return 0x00 to host
551 2 DataSize = 1;
C51 COMPILER V7.50 F34X_USB_STANDARD_REQUESTS 08/01/2007 13:13:23 PAGE 10
552 2 }
553 1 if (Ep_Status[0] != EP_STALL)
554 1 {
555 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Set Serviced Setup packet, put endpoint in transmit
556 2 Ep_Status[0] = EP_TX; // mode and reset Data sent counter
557 2 DataSent = 0;
558 2 }
559 1 }
560
561 //-----------------------------------------------------------------------------
562 // Set_Interface
563 //-----------------------------------------------------------------------------
564 //
565 // Return Value : None
566 // Parameters : None
567 //
568 // This routine allows host to change current device configuration value
569 //
570 //-----------------------------------------------------------------------------
571
572 void Set_Interface(void)
573 {
574 1 // Make sure request is directed at interface and all other packet values
575 1 // are set to zero
576 1
577 1 if ((Setup.bmRequestType != IN_INTERFACE) ||
578 1 Setup.wLength.c[MSB] ||Setup.wLength.c[LSB]||
579 1 Setup.wValue.c[MSB] ||Setup.wValue.c[LSB] ||
580 1 Setup.wIndex.c[MSB] ||Setup.wIndex.c[LSB])
581 1 {
582 2 // Otherwise send a stall to host
583 2 Force_Stall();
584 2 }
585 1 if (Ep_Status[0] != EP_STALL)
586 1 {
587 2 // Indicate setup packet has been serviced
588 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
589 2 }
590 1 }
591
592 //-----------------------------------------------------------------------------
593 // End Of File
594 //-----------------------------------------------------------------------------
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1134 ----
CONSTANT SIZE = 4 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -