Skip to content

Commit 3b71f12

Browse files
authored
Merge pull request #10472 from c1728p9/ep0_fix
Fix USB control transfers using small size
2 parents a5862df + 3a891f9 commit 3b71f12

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

usb/device/USBDevice/USBDevice.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define ENDPOINT_ENABLED (1 << 0)
4949
#define ENDPOINT_STALLED (1 << 1)
5050

51+
/* The maximum wMaxPacketSize for endpoint 0 */
5152
#if defined(MAX_PACKET_SIZE_EP0)
5253
#undef MAX_PACKET_SIZE_EP0
5354
#endif
@@ -663,7 +664,7 @@ void USBDevice::_control_setup()
663664
/* Control transfer setup stage */
664665
uint8_t buffer[MAX_PACKET_SIZE_EP0];
665666

666-
_phy->ep0_setup_read_result(buffer, MAX_PACKET_SIZE_EP0);
667+
_phy->ep0_setup_read_result(buffer, _max_packet_size_ep0);
667668

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

0 commit comments

Comments
 (0)