AnsweredAssumed Answered


Question asked by brown.geoffrey.001 on Nov 14, 2016
Latest reply on Dec 12, 2016 by brown.geoffrey.001
I needed to make a basic bulk device, so the natural starting point appeared to be a CubeMX generated CDC project.   Really, I was stunned by the number of custom files generated:

usb_device.h          usbd_desc.h

usbd_cdc_if.h           usbd_conf.h
usbd_cdc_if.c              usbd_conf.c
usb_device.c            usbd_cdc_if.c

After much effort, I finally achieved the result I wanted, but I really think this templating thing has gone too far.     Furthermore,  some of the generated files are virtually empty while others have a lot of stuff that needn't be customized.  Consider usbd_conf.c -- 536 lines of code.  There are only a few procedures in this that need to be customized --

LL_Driver_Init (where the endpoints are created -- btw, in the generated code these are hardwired constants rather that the defined names created in the header files), USBD_static_malloc and USBD_static_free.   

Could you please reconsider this architecture ?  It should be enough to touch a few relatively clean files to create a custom USB configuration.  Obviously the descriptors and endpoints, but most of the rest should be pretty much common.   

As things stand, I wouldn't recommend using the CubeMX generated code as a starting point for USB devices.