void FTDI::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
        ErrorMessage<uint8_t > (PSTR("Conf.Val"), conf);
        ErrorMessage<uint8_t > (PSTR("Iface Num"), iface);
        ErrorMessage<uint8_t > (PSTR("Alt.Set"), alt);

        bConfNum = conf;

        uint8_t index;

        if ((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80)
                index = epInterruptInIndex;
        else
                if ((pep->bmAttributes & 0x02) == 2)
                index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
        else
                return;

        // Fill in the endpoint info structure
        epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);
        epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize;
        epInfo[index].epAttribs = 0;

        bNumEP++;

        PrintEndpointDescriptor(pep);
}
Beispiel #2
0
/* Extracts interrupt-IN, bulk-IN, bulk-OUT endpoint information from config descriptor */
void BTD::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
	//ErrorMessage<uint8_t>(PSTR("Conf.Val"),conf);
	//ErrorMessage<uint8_t>(PSTR("Iface Num"),iface);
	//ErrorMessage<uint8_t>(PSTR("Alt.Set"),alt);
	
	if(alt) // wrong interface - by BT spec, no alt setting 
        return;
    
    bConfNum = conf;    
	uint8_t index;
    
    if ((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) // Interrupt In endpoint found
		index = BTD_EVENT_PIPE;
    
    else {
        if ((pep->bmAttributes & 0x02) == 2) // bulk endpoint found 
			index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE;
        else
            return;
    }
    
    // Fill the rest of endpoint data structure  
    epInfo[index].epAddr		= (pep->bEndpointAddress & 0x0F);
    epInfo[index].maxPktSize	= (uint8_t)pep->wMaxPacketSize;  
#ifdef EXTRADEBUG
    PrintEndpointDescriptor(pep);    
#endif
    if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints
        pollInterval = pep->bInterval;   
    bNumEP++;
}
void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) 
{
	// If the first configuration satisfies, the others are not concidered.
	if (bNumEP > 1 && conf != bConfNum)
		return;

	ErrorMessage<uint8_t>(PSTR("\r\nConf.Val"), conf);
	ErrorMessage<uint8_t>(PSTR("Iface Num"), iface);
	ErrorMessage<uint8_t>(PSTR("Alt.Set"), alt);

	bConfNum = conf;

	uint8_t			index	= 0;
	HIDInterface	*piface = FindInterface(iface, alt, proto);
	
	// Fill in interface structure in case of new interface 
	if (!piface)
	{
		piface				= hidInterfaces + bNumIface;
		piface->bmInterface = iface;
		piface->bmAltSet	= alt;
		piface->bmProtocol	= proto;
		bNumIface ++;
	}

	if ((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80)
	{
		USBTRACE("I8\r\n");
		index = epInterruptInIndex;
	}
	else
	{
		USBTRACE("I0\r\n");
		index = epInterruptOutIndex;
	}

	if (index)
	{
		USBTRACE2("Ind:", index);

		// Fill in the endpoint info structure
		epInfo[bNumEP].epAddr		= (pep->bEndpointAddress & 0x0F);
		epInfo[bNumEP].maxPktSize	= (uint8_t)pep->wMaxPacketSize;
		epInfo[bNumEP].epAttribs	= 0;

		// Fill in the endpoint index list
		piface->epIndex[index] = bNumEP;			//(pep->bEndpointAddress & 0x0F);

		bNumEP ++;
	}
	PrintEndpointDescriptor(pep);
}
Beispiel #4
0
/* get and parse config descriptor */
void GLUCODUINO::parseConfigDescr( byte addr, byte conf )
{
  uint8_t buf[ DESC_BUFF_SIZE ];
  uint8_t* buf_ptr = buf;
  byte rcode;
  byte descr_length;
  byte descr_type;
  unsigned int total_length;
  USB_ENDPOINT_DESCRIPTOR *epDesc;
  boolean isMidi = false;

  // get configuration descriptor (get descriptor size only)
  rcode = pUsb->getConfDescr( addr, 0, 4, conf, buf );
  if( rcode ){
    return;
  }  
  total_length = buf[2] | ((int)buf[3] << 8);
  if( total_length > DESC_BUFF_SIZE ) {    //check if total length is larger than buffer
    total_length = DESC_BUFF_SIZE;
  }

  // get configuration descriptor (all)
  rcode = pUsb->getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
  if( rcode ){
    return;
  }  

  //parsing descriptors
  while( buf_ptr < buf + total_length ) {  
    descr_length = *( buf_ptr );
    descr_type   = *( buf_ptr + 1 );
    switch( descr_type ) {
      case USB_DESCRIPTOR_CONFIGURATION :
        bConfNum = buf_ptr[5];
        break;
      case  USB_DESCRIPTOR_INTERFACE :
        if( buf_ptr[5] == USB_CLASS_AUDIO && buf_ptr[6] == USB_SUBCLASS_MIDISTREAMING ) {  //p[5]; bInterfaceClass = 1(Audio), p[6]; bInterfaceSubClass = 3(MIDI Streaming)
          isMidiFound = true; //MIDI device found.
          isMidi      = true;
        }else{
#ifdef DEBUG
          //Serial.print("No MIDI Device\n");
#endif
//          buf_ptr += total_length + 1;
//          bConfNum = 0;
            isMidi = false;
        }
        break;
      case USB_DESCRIPTOR_ENDPOINT :
        epDesc = (USB_ENDPOINT_DESCRIPTOR *)buf_ptr;
        if ((epDesc->bmAttributes & 0x02) == 2) {//bulk
          uint8_t index;
          if( isMidi )
              index = ((epDesc->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex;
          else
              index = ((epDesc->bEndpointAddress & 0x80) == 0x80) ? epDataInIndexVSP : epDataOutIndexVSP;
          epInfo[index].epAddr		= (epDesc->bEndpointAddress & 0x0F);
          epInfo[index].maxPktSize	= (uint8_t)epDesc->wMaxPacketSize;
          bNumEP ++;
#ifdef DEBUG
          PrintEndpointDescriptor(epDesc);
#endif
        }
        break;
      default:
        break;
    }//switch( descr_type  
    buf_ptr += descr_length;    //advance buffer pointer
  }//while( buf_ptr <=...
}