From 71c88b6f8e0da338b3413699b74e57c11773f6f6 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 7 Nov 2015 19:20:50 +0100 Subject: [PATCH 1/2] Added >64 byte USB_RecvControl() support --- .../arduino/avr/cores/arduino/USBCore.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/USBCore.cpp b/hardware/arduino/avr/cores/arduino/USBCore.cpp index 3c6610cd6f6..62b90ed47d6 100644 --- a/hardware/arduino/avr/cores/arduino/USBCore.cpp +++ b/hardware/arduino/avr/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; } From 9b66f5d348c33846de431b961226505c090114e2 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 7 Nov 2015 22:24:35 +0100 Subject: [PATCH 2/2] Added HID_REPORT_TYPE definitions --- hardware/arduino/avr/libraries/HID/HID.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hardware/arduino/avr/libraries/HID/HID.h b/hardware/arduino/avr/libraries/HID/HID.h index a9b3f58f2c6..93c4bd5b4ee 100644 --- a/hardware/arduino/avr/libraries/HID/HID.h +++ b/hardware/arduino/avr/libraries/HID/HID.h @@ -54,6 +54,11 @@ #define HID_BOOT_PROTOCOL 0 #define HID_REPORT_PROTOCOL 1 +// HID Request Type HID1.11 Page 51 7.2.1 Get_Report Request +#define HID_REPORT_TYPE_INPUT 1 +#define HID_REPORT_TYPE_OUTPUT 2 +#define HID_REPORT_TYPE_FEATURE 3 + typedef struct { uint8_t len; // 9