/************************************************************************ * Function Name : handleInsRmvIntr * * This function handles the insertion or removal of device on SL811HS. * It resets the controller and updates the port status * * Input: hci = data structure for the host controller * * Return: none ***********************************************************************/ void handleInsRmvIntr (hci_t * hci) { hcipriv_t *hp = &hci->hp; USBReset (hci); /* Changes in connection status */ hp->RHportStatus->portChange |= PORT_CONNECT_CHANGE; /* Port Enable or Disable */ if (hp->RHportStatus->portStatus & PORT_CONNECT_STAT) { /* device is connected to the port: * 1) Enable port * 2) Resume ?? */ // hp->RHportStatus->portChange |= PORT_ENABLE_CHANGE; /* Over Current is not supported by the SL811 HW ?? */ /* How about the Port Power ?? */ } else { /* Device has disconnect: * 1) Disable port */ hp->RHportStatus->portStatus &= ~(PORT_ENABLE_STAT); hp->RHportStatus->portChange |= PORT_ENABLE_CHANGE; } }
/***************************************************************** * * Function Name: hc_reset * * This function does register test and resets the SL811HS * controller. * * Input: hci = data structure for the host controller * * Return value : 0 * *****************************************************************/ static int hc_reset (hci_t * hci) { int attachFlag = 0; DBGFUNC ("Enter hc_reset\n"); regTest (hci); attachFlag = USBReset (hci); if (attachFlag) { setPortChange (hci, PORT_CONNECT_CHANGE); } return (0); }
int CALLBACK USBinit() { USBReset(); return 0; }
//***************************************************************************************** // USB Device Enumeration Process // Support 1 confguration and interface #0 and alternate setting #0 only // Support up to 1 control endpoint + 4 data endpoint only //***************************************************************************************** u_int8 EnumUsbDev(u_int8 usbaddr) { u_int8 i; // always reset USB transfer address u_int8 uAddr = 0; // for enumeration to Address #0 u_int8 epLen; // short strLang; pDevDesc pDev; pCfgDesc pCfg; pIntfDesc pIfc; pEPDesc pEnp; //------------------------------------------------ // Reset only Slave device attached directly //------------------------------------------------ uDev.wPayLoad[0] = 64; // default 64-u_int8 payload of Endpoint 0, address #0 if(usbaddr == 1) // bus reset for the device attached to SL811HS only USBReset(); // that will always have the USB address = 0x01 (for a hub) // task_time_sleep(25); pDev =(pDevDesc)DBUF; // ask for 64 u_int8s on Addr #0 usbstack.usbaddr=uAddr; usbstack.setup.wValue=DEVICE; usbstack.setup.wIndex=0; usbstack.setup.wLength=18; //usbstack.setup.wLength=sbstack.setup.wLength); usbstack.buffer=DBUF; if (!GetDesc()) // and determine the wPayload size return FALSE; // get correct wPayload of Endpoint 0 uDev.wPayLoad[0]=pDev->bMaxPacketSize0;// on current non-zero USB address //------------------------------------------------ // Set Slave USB Device Address //------------------------------------------------ if (!SetAddress(usbaddr)) // set to specific USB address return FALSE; // uAddr = usbaddr; // transfer using this new address //------------------------------------------------ // Get USB Device Descriptors on EP0 & Addr X //------------------------------------------------ pDev =(pDevDesc)DBUF; usbstack.usbaddr=uAddr; usbstack.setup.wLength=pDev->bLength; usbstack.setup.wValue=DEVICE; usbstack.setup.wIndex=0; //usbstack.setup.wLength=0x12;//( short)DBUF[0];//pDev->bLength; usbstack.buffer=DBUF; if (!GetDesc()) return FALSE; // For this current device: uDev.wVID = pDev->idVendor; // save VID uDev.wPID = pDev->idProduct; // save PID uDev.iMfg = pDev->iManufacturer; // save Mfg Index uDev.iPdt = pDev->iProduct; // save Product Index //------------------------------------------------ // Get Slave USB Configuration Descriptors //------------------------------------------------ pCfg = (pCfgDesc)DBUF; usbstack.usbaddr=uAddr; usbstack.setup.wValue=CONFIGURATION; usbstack.setup.wIndex=0; usbstack.setup.wLength=64; usbstack.buffer=DBUF; if (!GetDesc()) return FALSE; pIfc = (pIntfDesc)(DBUF + 9); // point to Interface Descp uDev.bClass = pIfc->iClass; // update to class type uDev.bNumOfEPs = (pIfc->bEndPoints <= MAX_EP) ? pIfc->bEndPoints : MAX_EP; if(uDev.bClass==8) //mass storage device bXXGFlags.bMassDevice=TRUE; //------------------------------------------------ // Set configuration (except for HUB device) //------------------------------------------------ usbstack.usbaddr=uAddr; usbstack.setup.wValue=DEVICE; //if (uDev[usbaddr].bClass!=HUBCLASS) // enumerating a FS/LS non-hub device if (!Set_Configuration()) // connected directly to SL811HS return FALSE; //------------------------------------------------ // For each slave endpoints, get its attributes // Excluding endpoint0, only data endpoints //------------------------------------------------ epLen = 0; for (i=1; i<=uDev.bNumOfEPs; i++) // For each data endpoint { pEnp = (pEPDesc)(DBUF + 9 + 9 + epLen); // point to Endpoint Descp(non-HID) uDev.bEPAddr[i] = pEnp->bEPAdd; // Ep address and direction uDev.bAttr[i] = pEnp->bAttr; // Attribute of Endpoint uDev.wPayLoad[i] = (pEnp->wPayLoad); // Payload of Endpoint uDev.bInterval[i] = pEnp->bInterval; // Polling interval uDev.bData1[i] = 0; // init data toggle epLen += 7; ////////////////////////////// if(uDev.bAttr[i]==0x2) { if(uDev.bEPAddr[i]&0x80) usbstack.epbulkin=uDev.bEPAddr[i]; else usbstack.epbulkout=uDev.bEPAddr[i]; } ////////////////////////////// } return TRUE; }