-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32: allow HS USB endpoints and increase USB OTG_HS endpoints number #13816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,29 @@ | |
#define IDX_TO_EP(idx) (((idx) >> 1)|((idx) & 1) << 7) | ||
|
||
/* endpoint defines */ | ||
#define NUM_ENDPOINTS 4 | ||
|
||
#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 | ||
|
||
#endif | ||
|
||
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) | ||
MAX_PACKET_SIZE_NON_ISO, | ||
MAX_PACKET_SIZE_NON_ISO, | ||
#endif | ||
MAX_PACKET_SIZE_ISO | ||
}; | ||
|
||
|
@@ -333,8 +348,11 @@ void USBPhyHw::init(USBPhyEvents *events) | |
total_bytes += fifo_size; | ||
} | ||
|
||
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS) | ||
/* 1.25 kbytes */ | ||
MBED_ASSERT(total_bytes <= 1280); | ||
#endif | ||
|
||
#endif | ||
|
||
// Configure interrupt vector | ||
|
@@ -424,11 +442,18 @@ void USBPhyHw::remote_wakeup() | |
const usb_ep_table_t *USBPhyHw::endpoint_table() | ||
{ | ||
static const usb_ep_table_t table = { | ||
#if (MBED_CONF_TARGET_USB_SPEED != USE_USB_OTG_HS) | ||
1280, // 1.25K for endpoint buffers but space is allocated up front | ||
#else | ||
4096, | ||
#endif | ||
{ | ||
{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) | ||
{USB_EP_ATTR_ALLOW_ALL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0}, | ||
#endif | ||
Comment on lines
+454
to
+456
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this change can be the default configuration for all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but I don't have enough hardware variety to test it 🙂 |
||
{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}, | ||
|
@@ -441,7 +466,9 @@ const usb_ep_table_t *USBPhyHw::endpoint_table() | |
{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 | ||
} | ||
}; | ||
return &table; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this total_bytes calculation is really useful...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it can be avoided, there are a lot of other sanity checks in the endpoint creation phase