Ejemplo n.º 1
0
        internal unsafe CyUSBEndPoint(IntPtr h, USB_ENDPOINT_DESCRIPTOR *EndPtDescriptor, USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *SSEndPtDescriptor)
        {
            _hDevice = h;

            if (EndPtDescriptor != (USB_ENDPOINT_DESCRIPTOR *)0)
            {
                int pkts = (EndPtDescriptor->wMaxPacketSize & 0x1800) >> 11;
                pkts++;

                _dscLen     = EndPtDescriptor->bLength;
                _dscType    = EndPtDescriptor->bDescriptorType;
                _address    = EndPtDescriptor->bEndpointAddress;
                _attributes = EndPtDescriptor->bmAttributes;
                _maxPktSize = (EndPtDescriptor->wMaxPacketSize & 0x7ff) * pkts;
                _interval   = EndPtDescriptor->bInterval;
                _bIn        = (Address & 0x80) > 0;
            }
            if (SSEndPtDescriptor != (USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *)0)
            {
                _ssdscLen      = SSEndPtDescriptor->bLength;
                _ssdscType     = SSEndPtDescriptor->bDescriptorType;
                _ssmaxburst    = SSEndPtDescriptor->bMaxBurst;
                _maxPktSize   *= (_ssmaxburst + 1);                                // Multiply the Maxpacket size with Max burst
                _ssbmAttribute = SSEndPtDescriptor->bmAttributes;
                if ((_attributes & 0x03) == 1)                                     // MULT is valid for Isochronous transfer only
                {
                    _maxPktSize *= ((SSEndPtDescriptor->bmAttributes & 0x03) + 1); // Adding the MULT fields.
                }
                _ssbytesperinterval = SSEndPtDescriptor->bBytesPerInterval;
            }
        }
Ejemplo n.º 2
0
 unsafe internal CyIsocEndPoint(IntPtr h, USB_ENDPOINT_DESCRIPTOR *EndPtDescriptor, USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *SSEndPtDescriptor) : base(h, EndPtDescriptor, SSEndPtDescriptor)
 {
 }
Ejemplo n.º 3
0
        unsafe internal CyUSBInterface(IntPtr handle, byte *DescrData, CyControlEndPoint ctlEndPt, byte usb30dummy)
        {
            USB_INTERFACE_DESCRIPTOR *pIntfcDescriptor = (USB_INTERFACE_DESCRIPTOR *)DescrData;


            _bLength            = pIntfcDescriptor->bLength;
            _bDescriptorType    = pIntfcDescriptor->bDescriptorType;
            _bInterfaceNumber   = pIntfcDescriptor->bInterfaceNumber;
            _bAlternateSetting  = pIntfcDescriptor->bAlternateSetting;
            _bNumEndpoints      = pIntfcDescriptor->bNumEndpoints;
            _bInterfaceClass    = pIntfcDescriptor->bInterfaceClass;
            _bInterfaceSubClass = pIntfcDescriptor->bInterfaceSubClass;
            _bInterfaceProtocol = pIntfcDescriptor->bInterfaceProtocol;
            _iInterface         = pIntfcDescriptor->iInterface;

            _bAltSettings = 0;
            _wTotalLength = bLength;

            byte *desc = (byte *)(DescrData + pIntfcDescriptor->bLength);

            int i;
            int unexpected = 0;

            EndPoints    = new CyUSBEndPoint[bNumEndpoints + 1];
            EndPoints[0] = ctlEndPt;

            for (i = 1; i <= bNumEndpoints; i++)
            {
                bool bSSDec = false;
                USB_ENDPOINT_DESCRIPTOR *endPtDesc = (USB_ENDPOINT_DESCRIPTOR *)desc;
                desc += endPtDesc->bLength;
                USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *ssendPtDesc = (USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR *)desc;
                _wTotalLength += endPtDesc->bLength;

                if (ssendPtDesc != null)
                {
                    bSSDec = (ssendPtDesc->bDescriptorType == CyConst.USB_SUPERSPEED_ENDPOINT_COMPANION);
                }


                if ((endPtDesc->bDescriptorType == CyConst.USB_ENDPOINT_DESCRIPTOR_TYPE) && bSSDec)
                {
                    switch (endPtDesc->bmAttributes)
                    {
                    case 0:
                        EndPoints[i] = ctlEndPt;
                        break;

                    case 1:
                        EndPoints[i] = new CyIsocEndPoint(handle, endPtDesc, ssendPtDesc);
                        break;

                    case 2:
                        EndPoints[i] = new CyBulkEndPoint(handle, endPtDesc, ssendPtDesc);
                        break;

                    case 3:
                        EndPoints[i] = new CyInterruptEndPoint(handle, endPtDesc, ssendPtDesc);
                        break;
                    }
                    _wTotalLength += ssendPtDesc->bLength;
                    desc          += ssendPtDesc->bLength;
                }
                else if ((endPtDesc->bDescriptorType == CyConst.USB_ENDPOINT_DESCRIPTOR_TYPE))
                {
                    switch (endPtDesc->bmAttributes)
                    {
                    case 0:
                        EndPoints[i] = ctlEndPt;
                        break;

                    case 1:
                        EndPoints[i] = new CyIsocEndPoint(handle, endPtDesc);
                        break;

                    case 2:
                        EndPoints[i] = new CyBulkEndPoint(handle, endPtDesc);
                        break;

                    case 3:
                        EndPoints[i] = new CyInterruptEndPoint(handle, endPtDesc);
                        break;
                    }
                }
                else
                {
                    unexpected++;
                    if (unexpected < 12)
                    {  // Sanity check - prevent infinite loop
                        // This may have been a class-specific descriptor (like HID).  Skip it.
                        desc += endPtDesc->bLength;

                        // Stay in the loop, grabbing the next descriptor
                        i--;
                    }
                }
            }
        }