use only one endpoint pair for MSC except on SAMD21

crypto-aes
Dan Halbert 3 years ago
parent 95a5a57f94
commit 195de97c67
  1. 3
      ports/atmel-samd/mpconfigport.mk
  2. 10
      supervisor/supervisor.mk
  3. 9
      tools/gen_usb_descriptor.py

@ -19,6 +19,9 @@ ifeq ($(CHIP_FAMILY),samd21)
# frequencyio not yet verified as working on SAMD21.
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_TOUCHIO_USE_NATIVE = 1
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
USB_MSC_NUM_ENDPOINT_PAIRS = 2
endif
# Put samd51-only choices here.

@ -89,6 +89,11 @@ ifndef USB_HID_DEVICES
USB_HID_DEVICES = "KEYBOARD,MOUSE,CONSUMER,GAMEPAD"
endif
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
ifndef USB_MSC_NUM_ENDPOINT_PAIRS
USB_MSC_NUM_ENDPOINT_PAIRS = 1
endif
SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) $(BUILD)/autogen_display_resources.o
$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h
@ -106,8 +111,9 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile
--vid $(USB_VID)\
--pid $(USB_PID)\
--serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\
--devices $(USB_DEVICES) \
--hid_devices $(USB_HID_DEVICES) \
--devices $(USB_DEVICES)\
--hid_devices $(USB_HID_DEVICES)\
--msc_num_endpoint_pairs $(USB_MSC_NUM_ENDPOINT_PAIRS)\
--output_c_file $(BUILD)/autogen_usb_descriptor.c\
--output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h

@ -32,6 +32,8 @@ parser.add_argument('--devices', type=lambda l: tuple(l.split(',')), default=DEF
help='devices to include in descriptor (AUDIO includes MIDI support)')
parser.add_argument('--hid_devices', type=lambda l: tuple(l.split(',')), default=DEFAULT_HID_DEVICES,
help='HID devices to include in HID report descriptor')
parser.add_argument('--msc_num_endpoint_pairs', type=int, default=1,
help='Use 1 or 2 endpoint pairs for MSC (1 bidirectional, or 1 input + 1 output (required by SAMD21))')
parser.add_argument('--output_c_file', type=argparse.FileType('w'), required=True)
parser.add_argument('--output_h_file', type=argparse.FileType('w'), required=True)
@ -45,6 +47,9 @@ unknown_hid_devices = list(frozenset(args.hid_devices) - ALL_HID_DEVICES_SET)
if unknown_hid_devices:
raise ValueError("Unknown HID devices(s)", unknown_hid_devices)
if args.msc_num_endpoint_pairs not in (1, 2):
raise ValueError("--msc_num_endpoint_pairs must be 1 or 2")
class StringIndex:
"""Assign a monotonically increasing index to each unique string. Start with 0."""
@ -153,7 +158,9 @@ msc_interfaces = [
bInterval=0),
standard.EndpointDescriptor(
description="MSC out",
bEndpointAddress=0x1 | standard.EndpointDescriptor.DIRECTION_OUT,
# SAMD21 needs to use a separate pair of endpoints for MSC.
bEndpointAddress=((0x1 if args.msc_num_endpoint_pairs == 2 else 0x0) |
standard.EndpointDescriptor.DIRECTION_OUT),
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
bInterval=0)
]

Loading…
Cancel
Save