Skip to content

Commit 2ad3e12

Browse files
committed
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
1 parent 770813e commit 2ad3e12

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

targets/TARGET_STM/USBPhy_STM32.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@
3333

3434
/* endpoint defines */
3535

36+
#if defined(TARGET_STM32H7)
37+
#define NUM_ENDPOINTS 6 // should be 8 but this would complicate everything
38+
#else
39+
#define NUM_ENDPOINTS 4
40+
#endif
41+
3642
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
3743

38-
#define NUM_ENDPOINTS 6
3944
#define MAX_PACKET_SIZE_NON_ISO 512
4045
#define MAX_PACKET_SIZE_ISO 1023
4146

4247
#else
4348

44-
#define NUM_ENDPOINTS 4
4549
#define MAX_PACKET_SIZE_NON_ISO 64
4650
#define MAX_PACKET_SIZE_ISO (256 + 128) // Spec can go up to 1023, only ram for this though
4751

@@ -51,7 +55,7 @@ static const uint32_t tx_ep_sizes[NUM_ENDPOINTS] = {
5155
MAX_PACKET_SIZE_NON_ISO,
5256
MAX_PACKET_SIZE_NON_ISO,
5357
MAX_PACKET_SIZE_NON_ISO,
54-
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
58+
#if defined(TARGET_STM32H7)
5559
MAX_PACKET_SIZE_NON_ISO,
5660
MAX_PACKET_SIZE_NON_ISO,
5761
#endif
@@ -435,7 +439,7 @@ void USBPhyHw::init(USBPhyEvents *events)
435439
total_bytes += fifo_size;
436440
}
437441

438-
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
442+
#if !defined(TARGET_STM32H7)
439443
/* 1.25 kbytes */
440444
MBED_ASSERT(total_bytes <= 1280);
441445
#endif
@@ -545,24 +549,12 @@ const usb_ep_table_t *USBPhyHw::endpoint_table()
545549
{USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
546550
{USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO
547551
{USB_EP_ATTR_ALLOW_BULK | USB_EP_ATTR_ALLOW_INT | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, // NON ISO
548-
#if (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_HS)
552+
#if defined(TARGET_STM32H7)
553+
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
549554
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
550-
#endif
551555
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
552-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
553-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
554-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
555-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
556-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
557-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
558-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
559-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
560-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
561-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
562-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
563-
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS)
564-
{0 | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}
565556
#endif
557+
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
566558
}
567559
};
568560
return &table;

0 commit comments

Comments
 (0)