diff --git a/Makefile.include b/Makefile.include index 4a6ffc7769..a6faea4790 100644 --- a/Makefile.include +++ b/Makefile.include @@ -662,6 +662,23 @@ endif @$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)' @$(COLOR_ECHO) +# Set USB VID/PID via CFLAGS if not being set via Kconfig +ifndef CONFIG_USB_VID + ifdef USB_VID + CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) + endif +else + USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID)) +endif + +ifndef CONFIG_USB_PID + ifdef USB_PID + CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID) + endif +else + USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) +endif + # Exported for the benefit of Kconfig export USB_VID_TESTING = 1209 export USB_PID_TESTING = 7D01 diff --git a/examples/usbus_minimal/Makefile b/examples/usbus_minimal/Makefile index 21f182f584..b9d5dfb4a6 100644 --- a/examples/usbus_minimal/Makefile +++ b/examples/usbus_minimal/Makefile @@ -26,16 +26,3 @@ QUIET ?= 1 SHOULD_RUN_KCONFIG ?= include $(RIOTBASE)/Makefile.include - -# Set USB VID/PID via CFLAGS if not being set via Kconfig -ifndef CONFIG_USB_VID - CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -else - USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID)) -endif - -ifndef CONFIG_USB_PID - CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID) -else - USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID)) -endif diff --git a/tests/usbus/Makefile b/tests/usbus/Makefile index 43abe21364..236d98343c 100644 --- a/tests/usbus/Makefile +++ b/tests/usbus/Makefile @@ -9,6 +9,4 @@ DISABLE_MODULE += auto_init_usbus USB_VID ?= $(USB_VID_TESTING) USB_PID ?= $(USB_PID_TESTING) -CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) - include $(RIOTBASE)/Makefile.include