From 4433b9bc7a02da65e8956cca4e8c5ec68509a36b Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 8 Apr 2020 18:15:09 +0200 Subject: [PATCH] tests/usbus_cdc_ecm: Check if USB parameters are set via Kconfig This also avoids running Kconfig by default, given that there is a Kconfig file in the application folder. --- tests/usbus_cdc_ecm/Kconfig | 5 +++++ tests/usbus_cdc_ecm/Makefile | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/usbus_cdc_ecm/Kconfig diff --git a/tests/usbus_cdc_ecm/Kconfig b/tests/usbus_cdc_ecm/Kconfig new file mode 100644 index 0000000000..a31bf18547 --- /dev/null +++ b/tests/usbus_cdc_ecm/Kconfig @@ -0,0 +1,5 @@ +config USB_VID + default 0x$(DEFAULT_VID) if KCONFIG_USB + +config USB_PID + default 0x$(DEFAULT_PID) if KCONFIG_USB diff --git a/tests/usbus_cdc_ecm/Makefile b/tests/usbus_cdc_ecm/Makefile index 2f5ab03d1e..346b8cb0c3 100644 --- a/tests/usbus_cdc_ecm/Makefile +++ b/tests/usbus_cdc_ecm/Makefile @@ -11,15 +11,29 @@ USEMODULE += ps # USB device vendor and product ID # pid.codes test VID/PID, not globally unique -DEFAULT_VID = 1209 -DEFAULT_PID = 7D00 +export DEFAULT_VID = 1209 +export DEFAULT_PID = 7D00 USB_VID ?= $(DEFAULT_VID) USB_PID ?= $(DEFAULT_PID) -CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) - 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 + +# There is a Kconfig in the app folder, we need to indicate not to run it by default +SHOULD_RUN_KCONFIG ?= + .PHONY: usb_id_check usb_id_check: @if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \