summaryrefslogtreecommitdiffstats
path: root/common_features.mk
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-02-15 08:56:13 +1100
committerGitHub <noreply@github.com>2021-02-15 08:56:13 +1100
commitf53e41ac81662a560a299a23c7863dd2f618a1f8 (patch)
treefcdaf9afd383e537571cc53ef644ba9504e274ec /common_features.mk
parentc27a778281824423a324d04276d291f06b49b1ae (diff)
Add support for analog USBPD on STM32G4xx. (#11824)
* Add support for analog USBPD on STM32G4xx. * Split up to a list of driver types, allow for custom.
Diffstat (limited to 'common_features.mk')
-rw-r--r--common_features.mk24
1 files changed, 24 insertions, 0 deletions
diff --git a/common_features.mk b/common_features.mk
index ecb4f5576b..8338ce4080 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -631,3 +631,27 @@ endif
ifeq ($(strip $(JOYSTICK_ENABLE)), digital)
OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
endif
+
+USBPD_ENABLE ?= no
+VALID_USBPD_DRIVER_TYPES = custom vendor
+USBPD_DRIVER ?= vendor
+ifeq ($(strip $(USBPD_ENABLE)), yes)
+ ifeq ($(filter $(strip $(USBPD_DRIVER)),$(VALID_USBPD_DRIVER_TYPES)),)
+ $(error USBPD_DRIVER="$(USBPD_DRIVER)" is not a valid USBPD driver)
+ else
+ OPT_DEFS += -DUSBPD_ENABLE
+ ifeq ($(strip $(USBPD_DRIVER)), vendor)
+ # Vendor-specific implementations
+ OPT_DEFS += -DUSBPD_VENDOR
+ ifeq ($(strip $(MCU_SERIES)), STM32G4xx)
+ OPT_DEFS += -DUSBPD_STM32G4
+ SRC += usbpd_stm32g4.c
+ else
+ $(error There is no vendor-provided USBPD driver available)
+ endif
+ else ifeq ($(strip $(USBPD_DRIVER)), custom)
+ OPT_DEFS += -DUSBPD_CUSTOM
+ # Board designers can add their own driver to $(SRC)
+ endif
+ endif
+endif \ No newline at end of file