Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 537c47f

Browse files
committed
Added >64 byte USB_RecvControl() support
1 parent fd8cb46 commit 537c47f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎hardware/arduino/avr/cores/arduino/USBCore.cpp‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,24 @@ static bool USB_SendStringDescriptor(const u8*string_P, u8 string_len, uint8_t f
425425
}
426426

427427
// Does not timeout or cross fifo boundaries
428-
// Will only work for transfers <= 64 bytes
429-
// TODO
430428
int USB_RecvControl(void* d, int len)
431429
{
432-
WaitOUT();
433-
Recv((u8*)d,len);
434-
ClearOUT();
430+
auto length = len;
431+
while(length)
432+
{
433+
// Dont receive more than the USB Control EP has to offer
434+
// Use fixed 64 because control EP always have 64 bytes even on 16u2.
435+
auto recvLength = length;
436+
if(recvLength > 64){
437+
recvLength = 64;
438+
}
439+
length -= recvLength;
440+
441+
// Write data to fit to the end (not the beginning) of the array
442+
WaitOUT();
443+
Recv((u8*)d + length, recvLength);
444+
ClearOUT();
445+
}
435446
return len;
436447
}
437448

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /