diff --git a/cpu/esp32/Kconfig.esp32s2 b/cpu/esp32/Kconfig.esp32s2 index 22db166788..045b717459 100644 --- a/cpu/esp32/Kconfig.esp32s2 +++ b/cpu/esp32/Kconfig.esp32s2 @@ -26,7 +26,7 @@ config CPU_FAM_ESP32S2 select MODULE_PS if MODULE_SHELL select MODULE_PTHREAD if MODULE_CPP select MODULE_RTT_RTC if HAS_PERIPH_RTT && MODULE_PERIPH_RTC - select MODULE_USBDEV_SYNOPSYS_DWC2 if HAS_PERIPH_USBDEV && MODULE_PERIPH_USBDEV + select MODULE_USBDEV_SYNOPSYS_DWC2 if MODULE_PERIPH_USBDEV imply MODULE_NEWLIB_NANO config CPU_FAM diff --git a/cpu/esp32/Kconfig.esp32s3 b/cpu/esp32/Kconfig.esp32s3 index c05358024c..6e4ec98344 100644 --- a/cpu/esp32/Kconfig.esp32s3 +++ b/cpu/esp32/Kconfig.esp32s3 @@ -33,7 +33,7 @@ config CPU_FAM_ESP32S3 select MODULE_PS if MODULE_SHELL select MODULE_PTHREAD if MODULE_CPP select MODULE_RTT_RTC if HAS_PERIPH_RTT && MODULE_PERIPH_RTC - select MODULE_USBDEV_SYNOPSYS_DWC2 if HAS_PERIPH_USBDEV && MODULE_PERIPH_USBDEV + select MODULE_USBDEV_SYNOPSYS_DWC2 if MODULE_PERIPH_USBDEV imply MODULE_NEWLIB_NANO config CPU_FAM diff --git a/cpu/esp32/Makefile.dep b/cpu/esp32/Makefile.dep index f46f939e5d..600b94af0a 100644 --- a/cpu/esp32/Makefile.dep +++ b/cpu/esp32/Makefile.dep @@ -160,7 +160,6 @@ endif ifneq (,$(filter periph_usbdev,$(USEMODULE))) USEMODULE += esp_idf_usb USEMODULE += usbdev_synopsys_dwc2 - USEMODULE += ztimer_msec endif ifneq (,$(filter shell,$(USEMODULE))) diff --git a/cpu/esp32/include/periph_cpu_esp32s2.h b/cpu/esp32/include/periph_cpu_esp32s2.h index 5f9f6b572e..faf9cce0c4 100644 --- a/cpu/esp32/include/periph_cpu_esp32s2.h +++ b/cpu/esp32/include/periph_cpu_esp32s2.h @@ -264,9 +264,7 @@ extern "C" { /** * @brief Total size of the FIFO */ -#ifndef DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE #define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE (1024U) -#endif /** * @brief Buffers have to be word aligned for DMA diff --git a/cpu/esp32/include/periph_cpu_esp32s3.h b/cpu/esp32/include/periph_cpu_esp32s3.h index 90e5c5b5c0..39d3cc58b0 100644 --- a/cpu/esp32/include/periph_cpu_esp32s3.h +++ b/cpu/esp32/include/periph_cpu_esp32s3.h @@ -265,9 +265,7 @@ extern "C" { /** * @brief Total size of the FIFO */ -#ifndef DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE #define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE (1024U) -#endif /** * @brief Buffers have to be word aligned for DMA diff --git a/cpu/stm32/include/usbdev_stm32.h b/cpu/stm32/include/usbdev_stm32.h index 0a860cf880..02d234e7a2 100644 --- a/cpu/stm32/include/usbdev_stm32.h +++ b/cpu/stm32/include/usbdev_stm32.h @@ -81,7 +81,7 @@ extern "C" { /** * @brief USB OTG FS FIFO reception buffer space in 32-bit words * - * Used as shared FIFO for reception of all OUT transfers + * Used as shared FIFO for reception of all OUT transfers from the host * * @note The application might have to increase this when dealing with large * isochronous transfers @@ -99,6 +99,38 @@ extern "C" { #define DWC2_USB_OTG_HS_RX_FIFO_SIZE (512U) #endif +/** + * @brief USB OTG FS FIFO total size + * + * Some device families (F7 and L4) forgot to define the FS device FIFO size + * in their vendor headers. This define sets it to the value from the + * reference manual. + */ +#ifndef USB_OTG_FS_TOTAL_FIFO_SIZE +#define USB_OTG_FS_TOTAL_FIFO_SIZE (1280U) +#endif + +/** + * @brief USB OTG FS FIFO total size + * + * Some device families (F7 and L4) forgot to define the HS device FIFO size + * in their vendor headers. This define sets it to the value from the + * reference manual. + */ +#ifndef USB_OTG_HS_TOTAL_FIFO_SIZE +#define USB_OTG_HS_TOTAL_FIFO_SIZE (4096U) +#endif + +/** + * @brief USB OTG FS FIFO total size + */ +#define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE USB_OTG_FS_TOTAL_FIFO_SIZE + +/** + * @brief USB OTG HS FIFO total size + */ +#define DWC2_USB_OTG_HS_TOTAL_FIFO_SIZE USB_OTG_HS_TOTAL_FIFO_SIZE + /** * @brief Use the built-in DMA controller of the HS peripheral when possible */ diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index aa73dee94d..a190ffeb82 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -209,6 +209,7 @@ endif ifneq (,$(filter usbdev_synopsys_dwc2,$(USEMODULE))) FEATURES_REQUIRED += periph_usbdev + USEMODULE += ztimer_msec endif ifneq (,$(filter vcnl40%0,$(USEMODULE))) diff --git a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c index ee2e939f9e..92a8220708 100644 --- a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c +++ b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c @@ -93,20 +93,6 @@ #define DWC2_PKTSTS_SETUP_COMP 0x04 /**< Rx fifo setup complete */ #define DWC2_PKTSTS_SETUP_UPDT 0x06 /**< Rx fifo setup update */ -/* Some device families (F7 and L4) forgot to define the FS device FIFO size * - * in their vendor headers. This define sets it to the value from the * - * reference manual */ -#ifndef USB_OTG_FS_TOTAL_FIFO_SIZE -#define USB_OTG_FS_TOTAL_FIFO_SIZE (1280U) -#endif - -/* Some device families (F7 and L4) forgot to define the HS device FIFO size * - * in their vendor headers. This define sets it to the value from the * - * reference manual */ -#ifndef USB_OTG_HS_TOTAL_FIFO_SIZE -#define USB_OTG_HS_TOTAL_FIFO_SIZE (4096U) -#endif - /* minimum depth of an individual transmit FIFO */ #define DWC2_USB_OTG_FIFO_MIN_WORD_SIZE (16U) /* Offset for OUT endpoints in a shared IN/OUT endpoint bit flag register */ @@ -472,14 +458,14 @@ static size_t _total_fifo_size(const dwc2_usb_otg_fshs_config_t *conf) { if (conf->type == DWC2_USB_OTG_FS) { #ifdef DWC2_USB_OTG_FS_ENABLED - return USB_OTG_FS_TOTAL_FIFO_SIZE; + return DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE; #else return 0; #endif /* DWC2_USB_OTG_FS_ENABLED */ } else { #ifdef DWC2_USB_OTG_HS_ENABLED - return USB_OTG_HS_TOTAL_FIFO_SIZE; + return DWC2_USB_OTG_HS_TOTAL_FIFO_SIZE; #else return 0; #endif /* DWC2_USB_OTG_HS_ENABLED */