diff options
author | NicoHood <NicoHood@users.noreply.github.com> | 2015-12-19 01:49:54 +0100 |
---|---|---|
committer | NicoHood <NicoHood@users.noreply.github.com> | 2015-12-19 01:53:24 +0100 |
commit | 87b4f726a7a996056989ff6fd02280f94ac3cb90 (patch) | |
tree | 5b37c238f162ec03f7895fea9c2843181144688c /cores/arduino/USBCore.cpp | |
parent | 513dbdd6901baba39d74ee28ded8b49d9a820069 (diff) |
Added Long USB RecvControl call for >64 bytes
Diffstat (limited to 'cores/arduino/USBCore.cpp')
-rw-r--r-- | cores/arduino/USBCore.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 3c6610c..4e7e8af 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -426,7 +426,7 @@ 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 +// Use USB_RecvControlLong for longer transfers int USB_RecvControl(void* d, int len) { WaitOUT(); @@ -435,6 +435,25 @@ int USB_RecvControl(void* d, int len) return len; } +// Does not timeout or cross fifo boundaries +int USB_RecvControlLong(void* d, int len) +{ + auto bytesleft = len; + while(bytesleft > 0) + { + // 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; + if(recvLength > 64){ + recvLength = 64; + } + + // Write data to fit to the beginning of the array + bytesleft -= USB_RecvControl((u8*)d + len - bytesleft, recvLength); + } + return len; +} + static u8 SendInterfaces() { u8 interfaces = 0; |