Submission: USB_CUSTOM to usb_desc.h (Now allows custom USB configs/vendors without editing core usb_desc.h)

GDouglas

Active member
I would like to contribute an open source change for usb_desc.h

1. Change line 114 from:

Code:
#if defined(USB_SERIAL)

into

Code:
#if defined(USB_CUSTOM)
  /*
  For advanced users experienced with USB configuration:
  This is a custom USB configuration
  - You no longer need to edit this system include centrally.
  - You can do non-standard configurations (e.g. HID+HID, RawHID+RawHID, RawHID+Serial+Serial)
  - This gives you more fine grained control than USB_EVERYTHING
  - You can easily define custom manufacturer/product strings.
  INSTRUCTIONS: (Example for CDC Serial + Raw HID)
     1. Copy this file to your sketch folder (Arduino IDE or PlatformIO).
     2. Custom modify this section with your custom USB configuration.
     3. Configure your compiler and linker to be aware of what to include.
        Example Arduino IDE instructions: Edit platform.txt
           compiler.cpp.flags=-include ./usb_desc.h -D USB_CUSTOM -D USB_SERIAL -D USB_RAWHID
        Example PlatformIO IDE instructions: Edit platformio.ini
           -include ${PROJECT_DIR}/src/usb_desc.h
           -D USB_CUSTOM
           -D USB_SERIAL
           -D USB_RAWHID
         This will recompile and link Arduino's existing libraries with your custom stuff.
  */
#elif defined(USB_SERIAL)

I tried not to modify the system file but I still had to, in order for things like custom USB vendor to show. So I have two near-identical copies of usb_desc.h -- except the one copied to my project has the custom config replacing this comment.

This makes it easier to just recompile stock libraries without editing the stock files. Less headache.

It must be at the very top, since you're relying on the ability to activate multiple USB functions simultaneously.
 
Last edited:
Back
Top