Skip to content

Commit 9650157

Browse files
authored
Merge pull request #443 from BrentK-ADI/endpoint-onedirection
Support Devices with One Direction Endpoints
2 parents e618fc4 + dac7578 commit 9650157

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/usb_descriptors.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,33 @@ uint8_t const* tud_descriptor_device_cb(void) {
8989
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN + \
9090
CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_VENDOR*TUD_VENDOR_DESC_LEN)
9191

92-
// MSC is mandatory, use endpoint 1
93-
#define EPNUM_MSC_OUT 0x01
94-
#define EPNUM_MSC_IN 0x81
92+
// MSC is mandatory
93+
#if defined(TUD_ENDPOINT_ONE_DIRECTION_ONLY)
94+
// MCUs that don't support a same endpoint number with different direction
95+
#define EPNUM_MSC_OUT 0x01
96+
#define EPNUM_MSC_IN 0x82
97+
#else
98+
// Use endpoint 1 for most devices
99+
#define EPNUM_MSC_OUT 0x01
100+
#define EPNUM_MSC_IN 0x81
101+
#endif
95102

96103
// Board/Port can force CDC endpoint numbering
97104
#if defined(BOARD_EPNUM_CDC_OUT) && defined(BOARD_EPNUM_CDC_IN) && defined(BOARD_EPNUM_CDC_NOTIF)
98105
#define EPNUM_CDC_NOTIF BOARD_EPNUM_CDC_NOTIF
99106
#define EPNUM_CDC_OUT BOARD_EPNUM_CDC_OUT
100107
#define EPNUM_CDC_IN BOARD_EPNUM_CDC_IN
101108
#else
102-
#define EPNUM_CDC_NOTIF 0x82
103-
#define EPNUM_CDC_OUT 0x03
104-
#define EPNUM_CDC_IN 0x83
109+
#if defined(TUD_ENDPOINT_ONE_DIRECTION_ONLY)
110+
// MCUs that don't support a same endpoint number with different direction
111+
#define EPNUM_CDC_NOTIF 0x83
112+
#define EPNUM_CDC_OUT 0x04
113+
#define EPNUM_CDC_IN 0x85
114+
#else
115+
#define EPNUM_CDC_NOTIF 0x82
116+
#define EPNUM_CDC_OUT 0x03
117+
#define EPNUM_CDC_IN 0x83
118+
#endif
105119
#endif
106120

107121
uint8_t TINYUF2_CONST desc_configuration[] = {

0 commit comments

Comments
 (0)