composite devices in config

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

composite devices in config

Post by ulao » Wed May 04, 2011 3:26 am

Ok after some digging around I found in order to use a mass-storgae with a gamepad I need to do a composite of the two devices in my config.

Currently I use an in and out int. for my game pad ( force feed back and gamepad data). I'm trying to modify my config to support the mass-storage. My guess is my length of data returned being wrong. Before adding the other device its :
18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 /** USB_CFG_HAVE_INTRIN_ENDPOINT3 + 7*/ + 9, 0,

I did change my number of interfaces and gave the MS a new index of 1, but I get enumeration errors. I tried many way to set the length but I'm not getting any where. Did I miss something?

Also , I just made a guess here but would both devices use the same endpoints, or do I need to have two sets? Both devices needs an in and an out.

Code: Select all

/**************************************************************************
//USB configuration descriptor//
**************************************************************************/
   9,                  // sizeof(usbDescriptorConfiguration): length of descriptor in bytes
   USBDESCR_CONFIG,       // descriptor type
      

   // I have tried 8+ I have tried 16+ I have tried doubling the interrupts and even tried 1 through 32 each time getting enumeration errors.
    //7 * 1/* two more inturupts MS*/ +7 + 9 /* MS device */ +
   //tried 1-32 no luck
   //18 + (7 * 2) +
   //18 + (7 * 2) + 7 +
   //9 +


   18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 /** USB_CFG_HAVE_INTRIN_ENDPOINT3 + 7*/ + 9, 0, // total length of data returned (including inlined descriptors)           
   2,                  //number of interfaces in this configuration
   1,                  // index of this configuration
   0,                  // configuration name string index
   USB_CFG_IS_SELF_POWERED,// attributes
   USB_CFG_MAX_BUS_POWER/2,// max USB current in 2mA units

   /**************************************************************************
   about the device ( HID gamepad and mouse )
   **************************************************************************/
   9,                   // sizeof(usbDescrInterface): length of descriptor in bytes
   USBDESCR_INTERFACE,    //descriptor type
   0,                   // index of this interface
   0,                   // alternate setting for this interface
   1 + USB_CFG_HAVE_INTRIN_ENDPOINT,
   /* + USB_CFG_HAVE_INTRIN_ENDPOINT3, */
   USB_CFG_INTERFACE_CLASS,
   USB_CFG_INTERFACE_SUBCLASS,
   USB_CFG_INTERFACE_PROTOCOL,
   0,                  // string index for interface
   /**************************************************************************
   //about the device ( mass storage )
   **************************************************************************/
   0x09,            // sizeof(usbDescrInterface): length of descriptor in bytes
   0x04,            // descriptor type
   0x01,            // index of this interface
   0x00,             // alternate setting for this interface
   2,               // bNumEndpoints
   0x08,            // bInterfaceClass: MASS STORAGE Class
   0x06,            // bInterfaceSubClass : SCSI transparent
   0x50,            // nInterfaceProtocol
   4,               // string index for interface
   /**************************************************************************
   about the report descriptor
   **************************************************************************/
   9,                // sizeof(usbDescrHID): length of descriptor in bytes
   USBDESCR_HID,        // descriptor type: HID
   0x10, 0x01,       // BCD representation of HID version
   0x00,             // target country code
   0x01,             // number of HID Report (or other HID class) Descriptor infos to follow
   0x22,             // descriptor type: report
   USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0,  // total length of report descriptor
   /**************************************************************************
   interupts
   **************************************************************************/
   #if USB_CFG_HAVE_INTRIN_ENDPOINT    //endpoint descriptor for endpoint 1
   //in put
      7,             //sizeof(usbDescrEndpoint)
      USBDESCR_ENDPOINT,// descriptor type = endpoint
      0x81,          // bulk IN endpoint number 1
      0x03,          // attrib: Interrupt endpoint
      8, 0,          // maximum packet size
      0x04, // in ms

   //output.
      7,             // sizeof(usbDescrEndpoint)
      5,           // descriptor type = endpoint
      0x02,         // out endpoint number 2
      0x03,          // attrib: Interrupt endpoint
      8, 0,            // maximum packet size
      USB_CFG_INTR_POLL_INTERVAL, // in ms
   #endif

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: composite devices in config

Post by ulao » Wed May 04, 2011 7:55 pm

Ok changed my mind I now feel I need two sets of interrupts ( based on what I see on the net). So does that mean 2 + a default? So add 7+7+7 and another +9, or another +18. This is driving me nutz! In either case I tried both.

Code: Select all

/**************************************************************************
//USB configuration descriptor//
**************************************************************************/
   9,                  // sizeof(usbDescriptorConfiguration): length of descriptor in bytes
   USBDESCR_CONFIG,       // descriptor type
      //18 + (7 * 2) +
      //18 + (7 * 2) + 7 +
      //9 +
   //total size breakdone.
   18 + // guessing each device
   7 * USB_CFG_HAVE_INTRIN_ENDPOINT +//total interupts ( /** USB_CFG_HAVE_INTRIN_ENDPOINT3 + 7*/ )
   7 +// the one defult inturupt
   9, // I think this is for the header of this descriptor.
   
   0, // not sure what this parm is form
   2,                  //number of interfaces in this configuration
   1,                  // index of this configuration
   0,                  // configuration name string index
   USB_CFG_IS_SELF_POWERED,// attributes
   USB_CFG_MAX_BUS_POWER/2,// max USB current in 2mA units

   /**************************************************************************
   about the device ( HID gamepad and mouse )
   **************************************************************************/
   9,                   // sizeof(usbDescrInterface): length of descriptor in bytes
   USBDESCR_INTERFACE,    //descriptor type
   0,                   // index of this interface
   0,                   // alternate setting for this interface
   1 + USB_CFG_HAVE_INTRIN_ENDPOINT,
   /* + USB_CFG_HAVE_INTRIN_ENDPOINT3, */
   USB_CFG_INTERFACE_CLASS,
   USB_CFG_INTERFACE_SUBCLASS,
   USB_CFG_INTERFACE_PROTOCOL,
   0,                  // string index for interface
   /**************************************************************************
   about the report descriptor
   **************************************************************************/
   9,                // sizeof(usbDescrHID): length of descriptor in bytes
   USBDESCR_HID,        // descriptor type: HID
   0x10, 0x01,       // BCD representation of HID version
   0x00,             // target country code
   0x01,             // number of HID Report (or other HID class) Descriptor infos to follow
   0x22,             // descriptor type: report
   USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0,  // total length of report descriptor
   /**************************************************************************
   interupts for index 0
   **************************************************************************/
   #if USB_CFG_HAVE_INTRIN_ENDPOINT    //endpoint descriptor for endpoint 1
   //in put
      7,             //sizeof(usbDescrEndpoint)
      USBDESCR_ENDPOINT,// descriptor type = endpoint
      0x81,          // bulk IN endpoint number 1
      0x03,          // attrib: Interrupt endpoint
      8, 0,          // maximum packet size
      0x04, // in ms

   //output.
      7,             // sizeof(usbDescrEndpoint)
      5,           // descriptor type = endpoint
      0x02,         // out endpoint number 2
      0x03,          // attrib: Interrupt endpoint
      8, 0,            // maximum packet size
      USB_CFG_INTR_POLL_INTERVAL, // in ms
   #endif
   /**************************************************************************
   //about the device ( mass storage )
   **************************************************************************/
   0x09,            // sizeof(usbDescrInterface): length of descriptor in bytes
   0x04,            // descriptor type
   0x01,            // index of this interface
   0x00,             // alternate setting for this interface
   2,               // bNumEndpoints
   0x08,            // bInterfaceClass: MASS STORAGE Class
   0x06,            // bInterfaceSubClass : SCSI transparent
   0x50,            // nInterfaceProtocol
   4,               // string index for interface
   /**************************************************************************
   interupts for index 1
   **************************************************************************/
   //in put
   7,             //sizeof(usbDescrEndpoint)
   5,// descriptor type = endpoint
   0x81,          // bulk IN endpoint number 1
   0x02,          // attrib: Interrupt endpoint
   0x40, 0,          // maximum packet size
   0x00, // in ms

   //output.
   7,             // sizeof(usbDescrEndpoint)
   5,           // descriptor type = endpoint
   0x02,         // out endpoint number 2
   0x02,          // attrib: Interrupt endpoint
   0x40, 0,         // maximum packet size
   0, // in ms

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: composite devices in config

Post by ulao » Fri May 06, 2011 5:46 pm

Ok I had overlapping interrupts but still no luck

Code: Select all

/**************************************************************************  
  USB configuration descriptor
  **************************************************************************/ 
     9,                  // sizeof(usbDescriptorConfiguration): length of descriptor in bytes   
     USBDESCR_CONFIG,       // descriptor type   
     //total size breakdown, LSB of wTotalLength
     9  +                 // config descriptor
     9 + 9 + 7 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + //  descriptors on HID interface
     9 + 7 + 7,          //    descriptors on MSC
     0, // MSB of wTotalLength
     2,                  //number of interfaces in this configuration   
     1,                  // index of this configuration   
     0,                  // configuration name string index   
     USB_CFG_IS_SELF_POWERED,// attributes   
     USB_CFG_MAX_BUS_POWER/2,// max USB current in 2mA units   
 
/************************************************************************** 
 about the device ( HID gamepad and mouse ) 
 **************************************************************************/ 
     9,                   // sizeof(usbDescrInterface): length of descriptor in bytes   
     USBDESCR_INTERFACE,    //descriptor type   
     0,                   // index of this interface   
     0,                   // alternate setting for this interface   
     1 + USB_CFG_HAVE_INTRIN_ENDPOINT, 
     USB_CFG_INTERFACE_CLASS, 
     USB_CFG_INTERFACE_SUBCLASS, 
     USB_CFG_INTERFACE_PROTOCOL, 
     0,                  // string index for interface   
/************************************************************************** 
 about the report descriptor 
 **************************************************************************/ 
     9,                // sizeof(usbDescrHID): length of descriptor in bytes   
     USBDESCR_HID,        // descriptor type: HID   
     0x10, 0x01,       // BCD representation of HID version   
     0x00,             // target country code   
     0x01,             // number of HID Report (or other HID class) Descriptor infos to follow   
     0x22,             // descriptor type: report   
     USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0,  // total length of report descriptor   
/************************************************************************** 
interupts for index 0 
 **************************************************************************/ 
     //in put 
        7,             //sizeof(usbDescrEndpoint)   
        USBDESCR_ENDPOINT,// descriptor type = endpoint   
        0x81,          // bulk IN endpoint number 1   
        0x03,          // attrib: Interrupt endpoint 
        8, 0,          // maximum packet size   
        0x04, // in ms   
 
     #if USB_CFG_HAVE_INTRIN_ENDPOINT    //optional interrupt OUT endpoint 
     //output. 
        7,             // sizeof(usbDescrEndpoint) 
        USBDESCR_ENDPOINT,           // descriptor type = endpoint 
        0x01,         // out endpoint number 2   
        0x03,          // attrib: Interrupt endpoint   
        8, 0,            // maximum packet size   
        USB_CFG_INTR_POLL_INTERVAL, // in ms   
     #endif 
/************************************************************************** 
about the device ( mass storage ) 
**************************************************************************/ 
     0x09,            // sizeof(usbDescrInterface): length of descriptor in bytes   
     USBDESCR_INTERFACE,  // descriptor type   
     0x01,            // index of this interface   
     0x00,             // alternate setting for this interface   
     2,               // bNumEndpoints 
     0x08,            // bInterfaceClass: MASS STORAGE Class   
     0x06,            // bInterfaceSubClass : SCSI transparent 
     0x50,            // nInterfaceProtocol   
     0,               // string index for interface 
/************************************************************************** 
interupts for index 1 
 **************************************************************************/ 
     //in put 
     7,             //sizeof(usbDescrEndpoint)   
     USBDESCR_ENDPOINT,// descriptor type = endpoint   
     0x82,          // bulk IN endpoint number 1
     0x02,          // attrib: bulk endpoint 
     0x40, 0,          // maximum packet size   
     0x00, // in ms   
 
     //output. 
     7,             // sizeof(usbDescrEndpoint) 
     USBDESCR_ENDPOINT, // descriptor type = endpoint 
     0x02,         // out endpoint number 2   
     0x02,          // attrib: bulk endpoint   
     0x40, 0,         // maximum packet size   
     0, // in ms   



What about my config?

#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
#define USB_CFG_EP3_NUMBER 2
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1
#define USB_CFG_IMPLEMENT_HALT 0

Guessing my EP3 is going to be a 2, what about the two out endpoints? Do I need to tell the config I have two?

Post Reply