adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
450 stars 120 forks source link

allow override of tusb_option settings in port headers #373

Closed tlyu closed 5 months ago

tlyu commented 5 months ago

Is your feature request related to a problem? Please describe.

It's not possible to easily override tusb_option.h settings such as CFG_TUD_HID by using compile-time options. The header files in the src/arduino/ports directory unconditionally define the option macros. This means that overriding them requires replacing the port header, or at least specifying a custom config header using -DCFG_TUSB_CONFIG_FILE=.

Describe the solution you'd like

The port headers should allow settings such as CFG_TUD_HID to be overridden using compiler flags. tusb_option.h itself uses #ifndef to create defaults that can be overridden. The port headers should also do this.

Describe alternatives you've considered

I've considered the custom config header described above.

Additional context

I have a need for supporting at least 3 HID interfaces on nRF52840, while CFG_TUD_HID defaults to 2.

hathach commented 5 months ago

PR is welcome.