LPCOpen USB Host detecting the type of device connected to the USB Host port and Virtual Com Host

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCOpen USB Host detecting the type of device connected to the USB Host port and Virtual Com Host

298 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micronpn on Wed Jul 16 04:08:54 MST 2014
I need to detect what type of device is connected to the USB Host port initially on a LPC1769 so that I could switch to call the right event functions related to the right devices.

Actually I put "in the middle" genric EVENT callback functions that inside should be able to detect the right device.

The first trial was done with a USB memory key and a Virtual Com device with this simple code:

void EVENT_USB_Host_DeviceEnumerationComplete(const uint8_t corenum)
{
   uint16_t ConfigDescriptorSize;
   uint8_t ConfigDescriptorData[512], bRet;

   if((bRet = USB_Host_GetDeviceConfigDescriptor(corenum, 1, &ConfigDescriptorSize, ConfigDescriptorData, sizeof(ConfigDescriptorData))) != HOST_GETCONFIG_Successful)
   {
      DEBUGOUT("Error Retrieving Configuration Descriptor.\r\n");
      return;
   }
   int iRet = USB_MS_Enumerated(corenum, &ConfigDescriptorSize, ConfigDescriptorData);
   if(iRet == -1)
   {
      int iRet = USB_CDC_Enumerated(corenum, &ConfigDescriptorSize, ConfigDescriptorData);
      if(iRet == -1)
      {
         DEBUGOUT("Unsupported or unknown attached device!!!\r\n");
         return;
      }
   }
}

but in practice if I don't put the USB memory key in the USB host connector the code loops for ever in USB_MS_Enumerated(..) without exiting so that the next instructions are not executed at all.

I suppose that there is a function that should be able to return the type of the device connected to the USB host port. Am I wrong?

Kind regards,
Massimo
Labels (1)
0 Kudos
0 Replies