@@ -426,7 +426,7 @@ static bool USB_SendStringDescriptor(const u8*string_P, u8 string_len, uint8_t f
426
426
427
427
// Does not timeout or cross fifo boundaries
428
428
// Will only work for transfers <= 64 bytes
429
- // TODO
429
+ // Use USB_RecvControlLong for longer transfers
430
430
int USB_RecvControl (void * d, int len)
431
431
{
432
432
WaitOUT ();
@@ -435,6 +435,25 @@ int USB_RecvControl(void* d, int len)
435
435
return len;
436
436
}
437
437
438
+ // Does not timeout or cross fifo boundaries
439
+ int USB_RecvControlLong (void * d, int len)
440
+ {
441
+ auto bytesleft = len;
442
+ while (bytesleft > 0 )
443
+ {
444
+ // Dont receive more than the USB Control EP has to offer
445
+ // Use fixed 64 because control EP always have 64 bytes even on 16u2.
446
+ auto recvLength = bytesleft;
447
+ if (recvLength > 64 ){
448
+ recvLength = 64 ;
449
+ }
450
+
451
+ // Write data to fit to the beginning of the array
452
+ bytesleft -= USB_RecvControl ((u8 *)d + len - bytesleft, recvLength);
453
+ }
454
+ return len;
455
+ }
456
+
438
457
static u8 SendInterfaces ()
439
458
{
440
459
u8 interfaces = 0 ;
0 commit comments