From 902a07c74f6619a22a6d07a526ba83c98ae85c65 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 12 Jan 2023 12:16:27 +0100 Subject: [PATCH] STM32H7: import mbed patch for USB FS --- ...196-STM32-USBDevice-fix-USB_FS-on-H7.patch | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 patches/0196-STM32-USBDevice-fix-USB_FS-on-H7.patch diff --git a/patches/0196-STM32-USBDevice-fix-USB_FS-on-H7.patch b/patches/0196-STM32-USBDevice-fix-USB_FS-on-H7.patch new file mode 100644 index 000000000..d45d66fb1 --- /dev/null +++ b/patches/0196-STM32-USBDevice-fix-USB_FS-on-H7.patch @@ -0,0 +1,85 @@ +From 6f400289478afa47ca6a0b96daa4e2f2e701f959 Mon Sep 17 00:00:00 2001 +From: Martino Facchin +Date: Thu, 12 Jan 2023 12:07:59 +0100 +Subject: [PATCH 196/199] STM32: USBDevice: fix USB_FS on H7 + +USB_FS IP, despite the name, shares everything with USBOTG_HS, so the properties (like endpoints number) need to be aligned +--- + targets/TARGET_STM/USBPhy_STM32.cpp | 30 +++++++++++------------------ + 1 file changed, 11 insertions(+), 19 deletions(-) + +diff --git a/targets/TARGET_STM/USBPhy_STM32.cpp b/targets/TARGET_STM/USBPhy_STM32.cpp +index 40f1044216..9e4c39dc6e 100644 +--- a/targets/TARGET_STM/USBPhy_STM32.cpp ++++ b/targets/TARGET_STM/USBPhy_STM32.cpp +@@ -33,15 +33,19 @@ + + /* endpoint defines */ + ++#if defined(TARGET_STM32H7) ++#define NUM_ENDPOINTS 6 // should be 8 but this would complicate everything ++#else ++#define NUM_ENDPOINTS 4 ++#endif ++ + #if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS) + +-#define NUM_ENDPOINTS 6 + #define MAX_PACKET_SIZE_NON_ISO 512 + #define MAX_PACKET_SIZE_ISO 1023 + + #else + +-#define NUM_ENDPOINTS 4 + #define MAX_PACKET_SIZE_NON_ISO 64 + #define MAX_PACKET_SIZE_ISO (256 + 128) // Spec can go up to 1023, only ram for this though + +@@ -51,7 +55,7 @@ static const uint32_t tx_ep_sizes[NUM_ENDPOINTS] = { + MAX_PACKET_SIZE_NON_ISO, + MAX_PACKET_SIZE_NON_ISO, + MAX_PACKET_SIZE_NON_ISO, +-#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS) ++#if defined(TARGET_STM32H7) + MAX_PACKET_SIZE_NON_ISO, + MAX_PACKET_SIZE_NON_ISO, + #endif +@@ -426,7 +430,7 @@ void USBPhyHw::init(USBPhyEvents *events) + total_bytes += fifo_size; + } + +-#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS) ++#if !defined(TARGET_STM32H7) + /* 1.25 kbytes */ + MBED_ASSERT(total_bytes <= 1280); + #endif +@@ -536,24 +540,12 @@ const usb_ep_table_t *USBPhyHw::endpoint_table() + {USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, + {USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO + {USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO +-#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS) ++#if defined(TARGET_STM32H7) ++ {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, + {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +-#endif + {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, +-#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS) +- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0} + #endif ++ {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, + } + }; + return &table; +-- +2.39.0 +