Skip to content

Commit 8054bb6

Browse files
committed
[USBP] Fixed the correct number of endpoints
1 parent ad36833 commit 8054bb6

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

Diff for: hardware/arduino/avr/cores/arduino/PluggableUSB.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#if defined(USBCON)
2424
#ifdef PLUGGABLE_USB_ENABLED
2525

26-
// TODO: set correct value for different CPUs
27-
#define MAX_EP 6
28-
2926
extern uint8_t _initEndpoints[];
3027

3128
PluggableUSB_ PluggableUSB;
@@ -64,7 +61,7 @@ bool PluggableUSB_::setup(USBSetup& setup, uint8_t j)
6461

6562
bool PluggableUSB_::plug(PUSBListNode *node)
6663
{
67-
if ((lastEp + node->numEndpoints) >= MAX_EP) {
64+
if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) {
6865
return false;
6966
}
7067

Diff for: hardware/arduino/avr/cores/arduino/USBCore.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -308,20 +308,15 @@ int USB_Send(u8 ep, const void* d, int len)
308308
return r;
309309
}
310310

311-
u8 _initEndpoints[] =
311+
u8 _initEndpoints[USB_ENDPOINTS] =
312312
{
313-
0,
313+
0, // Control Endpoint
314314

315-
EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
316-
EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
317-
EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
315+
EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
316+
EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
317+
EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
318318

319-
#ifdef PLUGGABLE_USB_ENABLED
320-
//allocate 3 endpoints and remove const so they can be changed by the user
321-
0,
322-
0,
323-
0,
324-
#endif
319+
// Following endpoints are automatically initialized to 0
325320
};
326321

327322
#define EP_SINGLE_64 0x32 // EP0

Diff for: hardware/arduino/avr/cores/arduino/USBDesc.h

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
#define PLUGGABLE_USB_ENABLED
2020

21+
#if defined(EPRST6)
22+
#define USB_ENDPOINTS 7 // AtMegaxxU4
23+
#else
24+
#define USB_ENDPOINTS 5 // AtMegaxxU2
25+
#endif
2126

2227
#define CDC_INTERFACE_COUNT 2
2328
#define CDC_ENPOINT_COUNT 3

0 commit comments

Comments
 (0)