📄 sl811.lst
字号:
527 1 usbstack.setup.wValue=STRING;
528 1 usbstack.setup.wIndex=0;
529 1 usbstack.setup.wLength=4;
530 1 usbstack.buffer=DBUF;
531 1
532 1 if (!GetDesc()) // Get string language
533 1 return FALSE;
534 1
535 1 strLang = pStr->wLang;
536 1
537 1 usbstack.usbaddr=uAddr;
538 1 usbstack.setup.wValue=(unsigned short)(uDev.iMfg<<8)|STRING;
539 1 usbstack.setup.wIndex=strLang;
540 1 usbstack.setup.wLength=4;
541 1 usbstack.buffer=DBUF;
542 1 // get iManufacturer String length
543 1 if (!GetDesc())
544 1 return FALSE;
545 1
546 1 usbstack.usbaddr=uAddr;
547 1 usbstack.setup.wValue=(unsigned short)(uDev.iMfg<<8)|STRING;
548 1 usbstack.setup.wIndex=strLang;
549 1 usbstack.setup.wLength=pStr->bLength;
550 1 //usbstack.buffer=DBUF;
C51 COMPILER V7.06 SL811 01/14/2008 22:33:40 PAGE 10
551 1 // get iManufacturer String descriptors
552 1 if (!GetDesc())
553 1 return FALSE;
554 1 */
555 1 //------------------------------------------------
556 1 // Get Slave USB Configuration Descriptors
557 1 //------------------------------------------------
558 1
559 1 pCfg = (pCfgDesc)DBUF;
560 1
561 1 usbstack.usbaddr=uAddr;
562 1 usbstack.setup.wValue=CONFIGURATION;
563 1 usbstack.setup.wIndex=0;
564 1 usbstack.setup.wLength=64;
565 1 usbstack.buffer=DBUF;
566 1 if (!GetDesc())
567 1 return FALSE;
568 1 /*
569 1 usbstack.usbaddr=uAddr;
570 1 usbstack.setup.wValue=CONFIGURATION;
571 1 usbstack.setup.wIndex=0;
572 1 usbstack.setup.wLength=WordSwap(pCfg->wLength);
573 1
574 1 usbstack.buffer=DBUF;
575 1 if (!GetDesc())
576 1 return FALSE;
577 1 */
578 1
579 1 pIfc = (pIntfDesc)(DBUF + 9); // point to Interface Descp
580 1 uDev.bClass = pIfc->iClass; // update to class type
581 1 uDev.bNumOfEPs = (pIfc->bEndPoints <= MAX_EP) ? pIfc->bEndPoints : MAX_EP;
582 1
583 1 if(uDev.bClass==8) //mass storage device
584 1 bXXGFlags.bits.bMassDevice=TRUE;
585 1 //------------------------------------------------
586 1 // Set configuration (except for HUB device)
587 1 //------------------------------------------------
588 1 usbstack.usbaddr=uAddr;
589 1 usbstack.setup.wValue=DEVICE;
590 1 //if (uDev[usbaddr].bClass!=HUBCLASS) // enumerating a FS/LS non-hub device
591 1 if (!Set_Configuration()) // connected directly to SL811HS
592 1 return FALSE;
593 1
594 1 //------------------------------------------------
595 1 // For each slave endpoints, get its attributes
596 1 // Excluding endpoint0, only data endpoints
597 1 //------------------------------------------------
598 1
599 1 epLen = 0;
600 1 for (i=1; i<=uDev.bNumOfEPs; i++) // For each data endpoint
601 1 {
602 2 pEnp = (pEPDesc)(DBUF + 9 + 9 + epLen); // point to Endpoint Descp(non-HID)
603 2 //if(pIfc->iClass == HIDCLASS)
604 2 // pEnp = (pEPDesc)(DBUF + 9 + 9 + 9 + epLen); // update pointer to Endpoint(HID)
605 2 uDev.bEPAddr[i] = pEnp->bEPAdd; // Ep address and direction
606 2 uDev.bAttr[i] = pEnp->bAttr; // Attribute of Endpoint
607 2 uDev.wPayLoad[i] = WordSwap(pEnp->wPayLoad); // Payload of Endpoint
608 2 uDev.bInterval[i] = pEnp->bInterval; // Polling interval
609 2 uDev.bData1[i] = 0; // init data toggle
610 2 epLen += 7;
611 2 //////////////////////////////
612 2 if(uDev.bAttr[i]==0x2)
C51 COMPILER V7.06 SL811 01/14/2008 22:33:40 PAGE 11
613 2 {
614 3 if(uDev.bEPAddr[i]&0x80)
615 3 usbstack.epbulkin=uDev.bEPAddr[i];
616 3 else
617 3 usbstack.epbulkout=uDev.bEPAddr[i];
618 3 }
619 2 //////////////////////////////
620 2 }
621 1
622 1 return TRUE;
623 1 }
624
625 //*****************************************************************************************
626 // Full-speed and low-speed detect - Device atttached directly to SL811HS
627 //*****************************************************************************************
628 /*
629 void speed_detect(void)
630 {
631 //pNumPort = 0; // zero no. of downstream ports
632 bXXGFlags.bits.SLAVE_FOUND = FALSE; // Clear USB device found flag
633 //bXXGFlags.bits.FULL_SPEED = TRUE; // Assume full speed device
634 //HUB_DEVICE = FALSE; // not HUB device
635 bXXGFlags.bits.DATA_STOP = FALSE; //
636
637 SL811Write(cSOFcnt,0xAE); // Set SOF high counter, no change D+/D-, host mode
638 SL811Write(CtrlReg,0x08); // Reset USB engine, full-speed setup, suspend disable
639 DelayMs(10); // Delay for HW stablize
640 SL811Write(CtrlReg,0x00); // Set to normal operation
641 SL811Write(IntEna,0x61); // USB-A, Insert/Remove, USB_Resume.
642 SL811Write(IntStatus,INT_CLEAR); // Clear Interrupt enable status
643 DelayMs(10); // Delay for HW stablize
644
645 if(SL811Read(IntStatus)&USB_RESET)
646 { // test for USB reset
647 SL811Write(IntStatus,INT_CLEAR);// Clear Interrupt enable status
648 DelayMs(30); // Blink LED - waiting for slave USB plug-in
649 //OUTB ^= ACTIVE_BLINK; // Blink Active LED
650 //OUTA |= PORTX_LED; // clear debug LEDs
651 return ; // exit speed_detect()
652 }
653
654 //if((SL811Read(IntStatus)&USB_DPLUS)==0) // Checking full or low speed
655 //{ // ** Low Speed is detected ** //
656 // SL811Write(cSOFcnt,0xEE); // Set up host and low speed direct and SOF cnt
657 // SL811Write(cDATASet,0xE0); // SOF Counter Low = 0xE0; 1ms interval
658 // SL811Write(CtrlReg,0x21); // Setup 6MHz and EOP enable
659 //uHub.bPortSpeed[1] = 1; // low speed for Device #1
660 // bXXGFlags.bits.FULL_SPEED = FALSE; // low speed device flag
661 //}
662 //else
663 { // ** Full Speed is detected ** //
664 SL811Write(cSOFcnt,0xAE); // Set up host & full speed direct and SOF cnt
665 SL811Write(cDATASet,0xE0); // SOF Counter Low = 0xE0; 1ms interval
666 SL811Write(CtrlReg,0x05); // Setup 48MHz and SOF enable
667 //uHub.bPortSpeed[1] = 0; // full speed for Device #1
668 }
669
670 //OUTB |= ACTIVE_BLINK; // clear Active LED
671 //bXXGFlags.bits.SLAVE_FOUND = TRUE; // Set USB device found flag
672 bXXGFlags.bits.SLAVE_ENUMERATED = FALSE; // no slave device enumeration
673
674 SL811Write(EP0Status,0x50); // Setup SOF Token, EP0
C51 COMPILER V7.06 SL811 01/14/2008 22:33:40 PAGE 12
675 SL811Write(EP0Counter,0x00); // reset to zero count
676 SL811Write(EP0Control,0x01); // start generate SOF or EOP
677
678 DelayMs(25); // Hub required approx. 24.1mS
679 SL811Write(IntStatus,INT_CLEAR); // Clear Interrupt status
680 //return 0; // exit speed_detect();
681 }
682 */
683 //*****************************************************************************************
684 // Detect USB Device
685 //*****************************************************************************************
686 /*
687 void slave_detect(void)
688 {
689 //int retDataRW = FALSE;
690
691 //-------------------------------------------------------------------------
692 // Wait for EZUSB enumeration
693 //-------------------------------------------------------------------------
694 //if(!CONFIG_DONE) // start SL811H after EZ-USB is configured
695 // return;
696
697 //-------------------------------------------------------------------------
698 // Wait for SL811HS enumeration
699 //-------------------------------------------------------------------------
700 if(!bXXGFlags.bits.SLAVE_ENUMERATED) // only if slave is not configured
701 {
702 speed_detect(); // wait for an USB device to be inserted to
703 if(bXXGFlags.bits.SLAVE_FOUND) // the SL811HST host
704 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -