Add usb-endpoint-count checking
.. however, the number of endpoints is only set for SAMD (8). Other ports need to set the value. Otherwise, the build will show the message ``` Unable to check whether maximum number of endpoints is respected ```
This commit is contained in:
parent
837abd6da0
commit
23aefe9509
@ -91,3 +91,5 @@ endif # samd51
|
|||||||
INTERNAL_LIBM = 1
|
INTERNAL_LIBM = 1
|
||||||
|
|
||||||
USB_SERIAL_NUMBER_LENGTH = 32
|
USB_SERIAL_NUMBER_LENGTH = 32
|
||||||
|
|
||||||
|
USB_NUM_EP = 8
|
||||||
|
@ -171,6 +171,10 @@ ifndef USB_MIDI_EP_NUM_IN
|
|||||||
USB_MIDI_EP_NUM_IN = 0
|
USB_MIDI_EP_NUM_IN = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef USB_NUM_EP
|
||||||
|
USB_NUM_EP = 0
|
||||||
|
endif
|
||||||
|
|
||||||
USB_DESCRIPTOR_ARGS = \
|
USB_DESCRIPTOR_ARGS = \
|
||||||
--manufacturer $(USB_MANUFACTURER)\
|
--manufacturer $(USB_MANUFACTURER)\
|
||||||
--product $(USB_PRODUCT)\
|
--product $(USB_PRODUCT)\
|
||||||
@ -180,6 +184,7 @@ USB_DESCRIPTOR_ARGS = \
|
|||||||
--interface_name $(USB_INTERFACE_NAME)\
|
--interface_name $(USB_INTERFACE_NAME)\
|
||||||
--devices $(USB_DEVICES)\
|
--devices $(USB_DEVICES)\
|
||||||
--hid_devices $(USB_HID_DEVICES)\
|
--hid_devices $(USB_HID_DEVICES)\
|
||||||
|
--max_ep $(USB_NUM_EP) \
|
||||||
--cdc_ep_num_notification $(USB_CDC_EP_NUM_NOTIFICATION)\
|
--cdc_ep_num_notification $(USB_CDC_EP_NUM_NOTIFICATION)\
|
||||||
--cdc_ep_num_data_out $(USB_CDC_EP_NUM_DATA_OUT)\
|
--cdc_ep_num_data_out $(USB_CDC_EP_NUM_DATA_OUT)\
|
||||||
--cdc_ep_num_data_in $(USB_CDC_EP_NUM_DATA_IN)\
|
--cdc_ep_num_data_in $(USB_CDC_EP_NUM_DATA_IN)\
|
||||||
|
@ -62,6 +62,8 @@ parser.add_argument('--midi_ep_num_out', type=int, default=0,
|
|||||||
help='endpoint number of MIDI OUT')
|
help='endpoint number of MIDI OUT')
|
||||||
parser.add_argument('--midi_ep_num_in', type=int, default=0,
|
parser.add_argument('--midi_ep_num_in', type=int, default=0,
|
||||||
help='endpoint number of MIDI IN')
|
help='endpoint number of MIDI IN')
|
||||||
|
parser.add_argument('--max_ep', type=int, default=0,
|
||||||
|
help='total number of endpoints available')
|
||||||
parser.add_argument('--output_c_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
|
parser.add_argument('--output_c_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
|
||||||
parser.add_argument('--output_h_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
|
parser.add_argument('--output_h_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
|
||||||
|
|
||||||
@ -376,6 +378,15 @@ if 'AUDIO' in args.devices:
|
|||||||
# interface cross-references.
|
# interface cross-references.
|
||||||
interfaces = util.join_interfaces(interfaces_to_join, renumber_endpoints=args.renumber_endpoints)
|
interfaces = util.join_interfaces(interfaces_to_join, renumber_endpoints=args.renumber_endpoints)
|
||||||
|
|
||||||
|
if args.max_ep != 0:
|
||||||
|
for interface in interfaces:
|
||||||
|
for subdescriptor in interface.subdescriptors:
|
||||||
|
endpoint_address = getattr(subdescriptor, 'bEndpointAddress', 0) & 0x7f
|
||||||
|
if endpoint_address > args.max_ep:
|
||||||
|
raise ValueError("Endpoint address %d of %s may not exceed %d" % (endpoint_address & 0x7f, interface.description, args.max_ep))
|
||||||
|
else:
|
||||||
|
print("Unable to check whether maximum number of endpoints is respected", file=sys.stderr)
|
||||||
|
|
||||||
# Now adjust the CDC interface cross-references.
|
# Now adjust the CDC interface cross-references.
|
||||||
|
|
||||||
cdc_union.bMasterInterface = cdc_comm_interface.bInterfaceNumber
|
cdc_union.bMasterInterface = cdc_comm_interface.bInterfaceNumber
|
||||||
|
Loading…
Reference in New Issue
Block a user