diff options
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/PluggableUSB.cpp | 5 | ||||
-rw-r--r-- | cores/arduino/USBCore.cpp | 17 | ||||
-rw-r--r-- | cores/arduino/USBDesc.h | 5 |
3 files changed, 12 insertions, 15 deletions
diff --git a/cores/arduino/PluggableUSB.cpp b/cores/arduino/PluggableUSB.cpp index 5a53eb1..50fd798 100644 --- a/cores/arduino/PluggableUSB.cpp +++ b/cores/arduino/PluggableUSB.cpp @@ -23,9 +23,6 @@ #if defined(USBCON) #ifdef PLUGGABLE_USB_ENABLED -// TODO: set correct value for different CPUs -#define MAX_EP 6 - extern uint8_t _initEndpoints[]; PluggableUSB_ PluggableUSB; @@ -64,7 +61,7 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j) bool PluggableUSB_::plug(PUSBListNode *node) { - if ((lastEp + node->numEndpoints) >= MAX_EP) { + if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) { return false; } diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index f96ff27..ebdce36 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -308,20 +308,15 @@ int USB_Send(u8 ep, const void* d, int len) return r; } -u8 _initEndpoints[] = +u8 _initEndpoints[USB_ENDPOINTS] = { - 0, + 0, // Control Endpoint - EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM - EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT - EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN + EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM + EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT + EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN -#ifdef PLUGGABLE_USB_ENABLED - //allocate 3 endpoints and remove const so they can be changed by the user - 0, - 0, - 0, -#endif + // Following endpoints are automatically initialized to 0 }; #define EP_SINGLE_64 0x32 // EP0 diff --git a/cores/arduino/USBDesc.h b/cores/arduino/USBDesc.h index 1962727..528a7fd 100644 --- a/cores/arduino/USBDesc.h +++ b/cores/arduino/USBDesc.h @@ -18,6 +18,11 @@ #define PLUGGABLE_USB_ENABLED +#if defined(EPRST6) +#define USB_ENDPOINTS 7 // AtMegaxxU4 +#else +#define USB_ENDPOINTS 5 // AtMegaxxU2 +#endif #define CDC_INTERFACE_COUNT 2 #define CDC_ENPOINT_COUNT 3 |