Skip to content

Commit 902a07c

Browse files
committed
STM32H7: import mbed patch for USB FS
1 parent 95b79c9 commit 902a07c

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
From 6f400289478afa47ca6a0b96daa4e2f2e701f959 Mon Sep 17 00:00:00 2001
2+
From: Martino Facchin <m.facchin@arduino.cc>
3+
Date: Thu, 12 Jan 2023 12:07:59 +0100
4+
Subject: [PATCH 196/199] STM32: USBDevice: fix USB_FS on H7
5+
6+
USB_FS IP, despite the name, shares everything with USBOTG_HS, so the properties (like endpoints number) need to be aligned
7+
---
8+
targets/TARGET_STM/USBPhy_STM32.cpp | 30 +++++++++++------------------
9+
1 file changed, 11 insertions(+), 19 deletions(-)
10+
11+
diff --git a/targets/TARGET_STM/USBPhy_STM32.cpp b/targets/TARGET_STM/USBPhy_STM32.cpp
12+
index 40f1044216..9e4c39dc6e 100644
13+
--- a/targets/TARGET_STM/USBPhy_STM32.cpp
14+
+++ b/targets/TARGET_STM/USBPhy_STM32.cpp
15+
@@ -33,15 +33,19 @@
16+
17+
/* endpoint defines */
18+
19+
+#if defined(TARGET_STM32H7)
20+
+#define NUM_ENDPOINTS 6 // should be 8 but this would complicate everything
21+
+#else
22+
+#define NUM_ENDPOINTS 4
23+
+#endif
24+
+
25+
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
26+
27+
-#define NUM_ENDPOINTS 6
28+
#define MAX_PACKET_SIZE_NON_ISO 512
29+
#define MAX_PACKET_SIZE_ISO 1023
30+
31+
#else
32+
33+
-#define NUM_ENDPOINTS 4
34+
#define MAX_PACKET_SIZE_NON_ISO 64
35+
#define MAX_PACKET_SIZE_ISO (256 + 128) // Spec can go up to 1023, only ram for this though
36+
37+
@@ -51,7 +55,7 @@ static const uint32_t tx_ep_sizes[NUM_ENDPOINTS] = {
38+
MAX_PACKET_SIZE_NON_ISO,
39+
MAX_PACKET_SIZE_NON_ISO,
40+
MAX_PACKET_SIZE_NON_ISO,
41+
-#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
42+
+#if defined(TARGET_STM32H7)
43+
MAX_PACKET_SIZE_NON_ISO,
44+
MAX_PACKET_SIZE_NON_ISO,
45+
#endif
46+
@@ -426,7 +430,7 @@ void USBPhyHw::init(USBPhyEvents *events)
47+
total_bytes += fifo_size;
48+
}
49+
50+
-#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
51+
+#if !defined(TARGET_STM32H7)
52+
/* 1.25 kbytes */
53+
MBED_ASSERT(total_bytes <= 1280);
54+
#endif
55+
@@ -536,24 +540,12 @@ const usb_ep_table_t *USBPhyHw::endpoint_table()
56+
{USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
57+
{USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO
58+
{USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO
59+
-#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
60+
+#if defined(TARGET_STM32H7)
61+
+ {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
62+
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
63+
-#endif
64+
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
65+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
66+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
67+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
68+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
69+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
70+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
71+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
72+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
73+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
74+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
75+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
76+
-#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
77+
- {0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}
78+
#endif
79+
+ {USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
80+
}
81+
};
82+
return &table;
83+
--
84+
2.39.0
85+

0 commit comments

Comments
 (0)