diff options
author | NicoHood <NicoHood@users.noreply.github.com> | 2015-11-07 19:20:50 +0100 |
---|---|---|
committer | Cristian Maglie <c.maglie@arduino.cc> | 2015-12-23 15:31:55 +0100 |
commit | 23696100479e0dca621a0e7fa90d3e487fca2a35 (patch) | |
tree | ee1064b7c3d1d0665d44f093e986f4803d11bce3 | |
parent | 513dbdd6901baba39d74ee28ded8b49d9a820069 (diff) |
Added >64 byte USB_RecvControl() support
-rw-r--r-- | cores/arduino/USBCore.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 3c6610c..62b90ed 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -425,13 +425,24 @@ 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 -// TODO int USB_RecvControl(void* d, int len) { - WaitOUT(); - Recv((u8*)d,len); - ClearOUT(); + 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 = length; + if(recvLength > 64){ + recvLength = 64; + } + + // 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; } |