Skip to content

Commit e6c4c78

Browse files
committed
- Fixed USB endpoint descriptor problems. All USB classes should now be usable. - Had to adjust some shared modules to account for MAX32 devices not supporting IN/OUT endpoints on the same EP #
1 parent 1c1d199 commit e6c4c78

6 files changed

Lines changed: 26 additions & 10 deletions

File tree

ports/analog/boards/APARD/mpconfigboard.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ USB_VID=0x0456
1818
USB_PID=0x003C
1919
USB_MANUFACTURER="Analog Devices, Inc."
2020
USB_PRODUCT="MAX32690 APARD"
21-
USB_NUM_ENDPOINT_PAIRS=12
2221
USB_HIGHSPEED=1
22+
23+
# NOTE: MAX32 devices do not support IN/OUT pairs on the same EP
24+
USB_NUM_ENDPOINT_PAIRS=12
2325
###
2426

2527
# define UID len for memory safety (buffer gets passed as a raw ptr)

ports/analog/mpconfigport.mk

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,9 @@ INTERNAL_FLASH_FILESYSTEM = 1
1717
SPI_FLASH_FILESYSTEM = 0
1818
QSPI_FLASH_FILESYSTEM = 0
1919

20-
# TODO: Test/Debug fs once USB-MSC is ready
20+
# TODO: Test/Debug FS
2121
DISABLE_FILESYSTEM = 0
2222

23-
# TODO: Test/Debug TinyUSB!
24-
# CIRCUITPY_TINYUSB = 1
25-
# CIRCUITPY_USB_DEVICE ?= 1
26-
# CIRCUITPY_USB_CDC ?= 1
27-
# CIRCUITPY_USB_VENDOR ?=1
28-
# CIRCUITPY_USB_HID ?= 0
29-
# CIRCUITPY_USB_MIDI ?= 0
30-
3123
####################################################################################
3224
# Suggested config for first-time porting
3325
####################################################################################

shared-module/storage/__init__.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ size_t storage_usb_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *
9292
descriptor_buf[MSC_IN_ENDPOINT_INDEX] =
9393
0x80 | (USB_MSC_EP_NUM_IN ? USB_MSC_EP_NUM_IN : descriptor_counts->current_endpoint);
9494
descriptor_counts->num_in_endpoints++;
95+
// Some TinyUSB devices have issues with bi-directional endpoints
96+
#ifdef TUD_ENDPOINT_ONE_DIRECTION_ONLY
97+
descriptor_counts->current_endpoint++;
98+
#endif
99+
95100
descriptor_buf[MSC_OUT_ENDPOINT_INDEX] =
96101
USB_MSC_EP_NUM_OUT ? USB_MSC_EP_NUM_OUT : descriptor_counts->current_endpoint;
97102
descriptor_counts->num_out_endpoints++;

shared-module/usb_cdc/__init__.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *desc
192192
? (USB_CDC_EP_NUM_DATA_IN ? USB_CDC_EP_NUM_DATA_IN : descriptor_counts->current_endpoint)
193193
: (USB_CDC2_EP_NUM_DATA_IN ? USB_CDC2_EP_NUM_DATA_IN : descriptor_counts->current_endpoint));
194194
descriptor_counts->num_in_endpoints++;
195+
// Some TinyUSB devices have issues with bi-directional endpoints
196+
#ifdef TUD_ENDPOINT_ONE_DIRECTION_ONLY
197+
descriptor_counts->current_endpoint++;
198+
#endif
199+
195200
descriptor_buf[CDC_DATA_OUT_ENDPOINT_INDEX] =
196201
console
197202
? (USB_CDC_EP_NUM_DATA_OUT ? USB_CDC_EP_NUM_DATA_OUT : descriptor_counts->current_endpoint)

shared-module/usb_hid/__init__.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *desc
172172
descriptor_buf[HID_IN_ENDPOINT_INDEX] =
173173
0x80 | (USB_HID_EP_NUM_IN ? USB_HID_EP_NUM_IN : descriptor_counts->current_endpoint);
174174
descriptor_counts->num_in_endpoints++;
175+
176+
// Some TinyUSB devices have issues with bi-directional endpoints
177+
#ifdef TUD_ENDPOINT_ONE_DIRECTION_ONLY
178+
descriptor_counts->current_endpoint++;
179+
#endif
180+
175181
descriptor_buf[HID_OUT_ENDPOINT_INDEX] =
176182
USB_HID_EP_NUM_OUT ? USB_HID_EP_NUM_OUT : descriptor_counts->current_endpoint;
177183
descriptor_counts->num_out_endpoints++;

shared-module/usb_midi/__init__.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ size_t usb_midi_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *des
176176
descriptor_buf[MIDI_STREAMING_IN_ENDPOINT_INDEX] =
177177
0x80 | (USB_MIDI_EP_NUM_IN ? USB_MIDI_EP_NUM_IN : descriptor_counts->current_endpoint);
178178
descriptor_counts->num_in_endpoints++;
179+
180+
// Some TinyUSB devices have issues with bi-directional endpoints
181+
#ifdef TUD_ENDPOINT_ONE_DIRECTION_ONLY
182+
descriptor_counts->current_endpoint++;
183+
#endif
184+
179185
descriptor_buf[MIDI_STREAMING_OUT_ENDPOINT_INDEX] =
180186
USB_MIDI_EP_NUM_OUT ? USB_MIDI_EP_NUM_OUT : descriptor_counts->current_endpoint;
181187
descriptor_counts->num_out_endpoints++;

0 commit comments

Comments
 (0)