Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fd6f57d

Browse files
committed
Added 16 byte endpoint support
1 parent a1cf704 commit fd6f57d

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

‎hardware/arduino/avr/cores/arduino/CDC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const CDCDescriptor _cdcInterface =
4949

5050
// CDC data interface
5151
D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
52-
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
53-
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
52+
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0),
53+
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0)
5454
};
5555

5656
int CDC_GetInterface(u8* interfaceNum)

‎hardware/arduino/avr/cores/arduino/USBAPI.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ typedef unsigned long u32;
3232

3333
#include "Arduino.h"
3434

35+
// This definitions is usefull if you want to reduce the EP_SIZE to 16
36+
// at the moment only 64 and 16 as EP_SIZE for all EPs are supported except the control endpoint
37+
#ifndef USB_EP_SIZE
38+
#define USB_EP_SIZE 64
39+
#endif
40+
3541
#if defined(USBCON)
3642

3743
#include "USBDesc.h"

‎hardware/arduino/avr/cores/arduino/USBCore.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ u8 USB_SendSpace(u8 ep)
253253
LockEP lock(ep);
254254
if (!ReadWriteAllowed())
255255
return 0;
256-
return 64 - FifoByteCount();
256+
return USB_EP_SIZE - FifoByteCount();
257257
}
258258

259259
// Blocking Send of data to an endpoint
@@ -326,6 +326,7 @@ u8 _initEndpoints[] =
326326

327327
#define EP_SINGLE_64 0x32 // EP0
328328
#define EP_DOUBLE_64 0x36 // Other endpoints
329+
#define EP_SINGLE_16 0x12
329330

330331
static
331332
void InitEP(u8 index, u8 type, u8 size)
@@ -344,7 +345,13 @@ void InitEndpoints()
344345
UENUM = i;
345346
UECONX = (1<<EPEN);
346347
UECFG0X = _initEndpoints[i];
348+
#if USB_EP_SIZE == 16
349+
UECFG1X = EP_SINGLE_16;
350+
#elif USB_EP_SIZE == 64
347351
UECFG1X = EP_DOUBLE_64;
352+
#else
353+
#error Unsupported value for USB_EP_SIZE
354+
#endif
348355
}
349356
UERST = 0x7E; // And reset them
350357
UERST = 0;

‎hardware/arduino/avr/libraries/HID/HID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int HID_GetInterface(u8* interfaceNum)
5959
{
6060
D_INTERFACE(HID_INTERFACE,1,3,0,0),
6161
D_HIDREPORT(sizeof_hidReportDescriptor),
62-
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
62+
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,USB_EP_SIZE,0x01)
6363
};
6464
return USB_SendControl(0,&_hidInterface,sizeof(_hidInterface));
6565
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /