summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-08-19 16:47:20 -0500
committerJeff Epler <jepler@gmail.com>2020-08-19 16:47:40 -0500
commit23aefe9509f7c58acd53d96b5d26a90b7b5b15db (patch)
tree6e3e2715cb72e97faa21e46e390a6075f35a8d14 /tools
parent837abd6da072a55f3c46d62b013690a12e0ee262 (diff)
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 ```
Diffstat (limited to 'tools')
-rw-r--r--tools/gen_usb_descriptor.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index fb91fd334..baee8cad7 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -62,6 +62,8 @@ parser.add_argument('--midi_ep_num_out', type=int, default=0,
help='endpoint number of MIDI OUT')
parser.add_argument('--midi_ep_num_in', type=int, default=0,
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_h_file', type=argparse.FileType('w', encoding='UTF-8'), required=True)
@@ -376,6 +378,15 @@ if 'AUDIO' in args.devices:
# interface cross-references.
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.
cdc_union.bMasterInterface = cdc_comm_interface.bInterfaceNumber