diff options
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 4e7e8af..62b90ed 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -425,31 +425,23 @@ static bool USB_SendStringDescriptor(const u8*string_P, u8 string_len, uint8_t f } // Does not timeout or cross fifo boundaries -// Will only work for transfers <= 64 bytes -// Use USB_RecvControlLong for longer transfers int USB_RecvControl(void* d, int len) { - WaitOUT(); - Recv((u8*)d,len); - ClearOUT(); - return len; -} - -// Does not timeout or cross fifo boundaries -int USB_RecvControlLong(void* d, int len) -{ - auto bytesleft = len; - while(bytesleft > 0) + auto length = len; + while(length) { // Dont receive more than the USB Control EP has to offer // Use fixed 64 because control EP always have 64 bytes even on 16u2. - auto recvLength = bytesleft; + auto recvLength = length; if(recvLength > 64){ recvLength = 64; } - // Write data to fit to the beginning of the array - bytesleft -= USB_RecvControl((u8*)d + len - bytesleft, recvLength); + // Write data to fit to the end (not the beginning) of the array + WaitOUT(); + Recv((u8*)d + len - length, recvLength); + ClearOUT(); + length -= recvLength; } return len; } |