From 81cf8a5eec6b563a59048650157af1a2c8cc74d7 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Tue, 7 Mar 2023 23:40:02 +0100 Subject: [PATCH] cpu/gd32v: add periph_usbdev support --- cpu/gd32v/Kconfig | 1 + cpu/gd32v/Makefile.dep | 4 ++++ cpu/gd32v/include/periph_cpu.h | 3 ++- cpu/gd32v/include/vendor/usbdev_gd32v.h | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cpu/gd32v/Kconfig b/cpu/gd32v/Kconfig index 43714dc786..02e8c2a6d4 100644 --- a/cpu/gd32v/Kconfig +++ b/cpu/gd32v/Kconfig @@ -30,6 +30,7 @@ config CPU_FAM_GD32V select MODULE_PERIPH_CLIC if TEST_KCONFIG select MODULE_PERIPH_WDT if MODULE_PERIPH_PM && HAS_PERIPH_WDT + select MODULE_USBDEV_SYNOPSYS_DWC2 if MODULE_PERIPH_USBDEV select ZTIMER_USEC if MODULE_PERIPH_I2C select PACKAGE_NMSIS_SDK diff --git a/cpu/gd32v/Makefile.dep b/cpu/gd32v/Makefile.dep index 21499ed618..dea7d86970 100644 --- a/cpu/gd32v/Makefile.dep +++ b/cpu/gd32v/Makefile.dep @@ -11,4 +11,8 @@ ifneq (,$(filter periph_i2c,$(USEMODULE))) USEMODULE += ztimer_usec endif +ifneq (,$(filter periph_usbdev,$(USEMODULE))) + USEMODULE += usbdev_synopsys_dwc2 +endif + include $(RIOTCPU)/riscv_common/Makefile.dep diff --git a/cpu/gd32v/include/periph_cpu.h b/cpu/gd32v/include/periph_cpu.h index 8fed2b6977..17431ea199 100644 --- a/cpu/gd32v/include/periph_cpu.h +++ b/cpu/gd32v/include/periph_cpu.h @@ -462,7 +462,8 @@ typedef struct { * @name USB device definitions * @{ */ -#define USBDEV_NUM_ENDPOINTS 4 /**< Number of USB OTG FS endpoints including EP0 */ +#define USBDEV_SET_ADDR_AFTER_STATUS 0 /**< Set device address after SETUP stage */ +#define USBDEV_NUM_ENDPOINTS 4 /**< Number of USB OTG FS endpoints including EP0 */ /** @} */ /** diff --git a/cpu/gd32v/include/vendor/usbdev_gd32v.h b/cpu/gd32v/include/vendor/usbdev_gd32v.h index db81063ad5..6e3f1ccc52 100644 --- a/cpu/gd32v/include/vendor/usbdev_gd32v.h +++ b/cpu/gd32v/include/vendor/usbdev_gd32v.h @@ -70,7 +70,7 @@ #endif /** - * @brief Total size of the FIFO + * @brief Total size of the FIFO in bytes */ #define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE (1280)