Composite USB Device with more than one instance of Class type

Showing results for 
Search instead for 
Did you mean: 

Composite USB Device with more than one instance of Class type

Contributor I

I am constructing a composite USB device on a frdmk22f dev board, containing 3 class instances (1 USB_CLASS_MASS_STORAGE and 2 USB_CLASS_HID). My 2 USB_CLASS_HID's are a HID keyboard and a HID Generic.


I have not seen any examples for configuring the stack when multiple instances of the same class type are included in the composite USB device. When configuring the USB stack with the USB_Composite_Init() call it appears that multiple instances of a class type need to be treated differently than instances of different class types. The "Composite Device Users's Guide" indicates the  count element of the composite_config_struct_t represents the number of classes (rather than the number of class instances?) in the composite device.


Should this count value be the number of class types or number of class instances in the composite device? Thanks for any pointers.



// usb_class_composite.h

typedef struct _composite_config_struct


     uint8_t                                    count;               /*!< Number of class support */  

     class_config_struct_t*            class_app_callback;  /*!< Array of Endpoints Structures */




// composite initialization call

USB_Composite_Init(CONTROLLER_ID, &g_composite_device.composite_device_config_callback, &g_composite_device.composite_device);



// My USB Stack Configuration Macro Modifications



    #define MAX_HID_DEVICE                    (0x02) ... was (0x01)

    #define MAX_HID_CLASS_EP_NUM              (2)    ... was (1)



    #define CONFIG_MAX 3 ... was 2



    #define USBCFG_DEV_MAX_CLASS_OBJECT       (2) ... was (1)

    #define USBCFG_DEV_MAX_ENDPOINTS          (7) ... was (6)

Labels (1)
0 Kudos
1 Reply

Specialist V

Hi Steve

For KSDK issues you may have more luck posting in the KSDK forum rather than the Kinetis microcontrollers one.

I can't help with the KSDK USB stack because it is too complicated for me to follow but if you are still experimenting and would prefer a proven solution for your requirements without development/porting investment needs you can take a look at the uTasker project for K22:

It allows composites to be simply configured - the following gives a quick overview:

As example I have attached a FRDM-K22F binary that I just configured to have one MSD, one keyboard and one USB HID (raw, which I think is what you need for generic); the composite link also explains how to test the keyboard since it will allow queued writes at 1000 strokes per second. The complete solution can also be simulated to avoid any guess-work.

The USB-MSD shows up as a disk drive called DATADISK 1 and uses the emulated FAT method in the uTasker project (rather than the SD card, which is usually not available on the FRD-K22F without soldering on a socket) -

The files that appear on the disk are virtual files with the content of the internal flash, internal RAM and some other types.

In addition, if you need to solve the existing base, I have attached a USB enumeration recording (the *.ufo file) of this connecting and operating - you can download the appropriate viewer from Ellisys ( - visual USB) so that you can then check all details and tune up your stack/descriptors etc. to match in case there are obvious deviations.

Finally, also the USB descriptor configuration that I used (allowing mouse, keypad, raw HID and audio class to be stacked on top of MSD) in case it gives any ideas.



0 Kudos