Skip to content

Commit

Permalink
STM32H7: import mbed patch for USB FS
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm committed Jan 12, 2023
1 parent 95b79c9 commit 902a07c
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions patches/0196-STM32-USBDevice-fix-USB_FS-on-H7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
From 6f400289478afa47ca6a0b96daa4e2f2e701f959 Mon Sep 17 00:00:00 2001
From: Martino Facchin <[email protected]>
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

0 comments on commit 902a07c

Please sign in to comment.