Skip to content

Fix USB control transfers using small size #10472

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

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions usb/device/USBDevice/USBDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define ENDPOINT_ENABLED (1 << 0)
#define ENDPOINT_STALLED (1 << 1)

/* The maximum wMaxPacketSize for endpoint 0 */
#if defined(MAX_PACKET_SIZE_EP0)
#undef MAX_PACKET_SIZE_EP0
#endif
Expand Down Expand Up @@ -663,7 +664,7 @@ void USBDevice::_control_setup()
/* Control transfer setup stage */
uint8_t buffer[MAX_PACKET_SIZE_EP0];

_phy->ep0_setup_read_result(buffer, MAX_PACKET_SIZE_EP0);
_phy->ep0_setup_read_result(buffer, _max_packet_size_ep0);

/* Initialise control transfer state */
_decode_setup_packet(buffer, &_transfer.setup);
Expand Down Expand Up @@ -805,7 +806,7 @@ void USBDevice::_control_setup_continue()
/* the end of this transfer */
if (_transfer.setup.wLength > _transfer.remaining) {
/* Device wishes to transfer less than host requested */
if ((_transfer.remaining % MAX_PACKET_SIZE_EP0) == 0) {
if ((_transfer.remaining % _max_packet_size_ep0) == 0) {
/* Transfer is a multiple of EP0 max packet size */
_transfer.zlp = true;
}
Expand Down