3232 help = 'devices to include in descriptor (AUDIO includes MIDI support)' )
3333parser .add_argument ('--hid_devices' , type = lambda l : tuple (l .split (',' )), default = DEFAULT_HID_DEVICES ,
3434 help = 'HID devices to include in HID report descriptor' )
35- parser .add_argument ('--msc_num_endpoint_pairs' , type = int , default = 1 ,
36- help = 'Use 1 or 2 endpoint pairs for MSC (1 bidirectional, or 1 input + 1 output (required by SAMD21))' )
35+ parser .add_argument ('--relative_ep_num' , type = int , default = 1 ,
36+ help = 'use relative(1) or absolute(0) endpoint number' )
37+ parser .add_argument ('--cdc_ep_num_notification' , type = int , default = 0 ,
38+ help = 'endpoint number of CDC NOTIFICATION' )
39+ parser .add_argument ('--cdc_ep_num_data_out' , type = int , default = 0 ,
40+ help = 'endpoint number of CDC DATA OUT' )
41+ parser .add_argument ('--cdc_ep_num_data_in' , type = int , default = 0 ,
42+ help = 'endpoint number of CDC DATA IN' )
43+ parser .add_argument ('--msc_ep_num_out' , type = int , default = 0 ,
44+ help = 'endpoint number of MSC OUT' )
45+ parser .add_argument ('--msc_ep_num_in' , type = int , default = 0 ,
46+ help = 'endpoint number of MSC IN' )
47+ parser .add_argument ('--hid_ep_num_in' , type = int , default = 0 ,
48+ help = 'endpoint number of HID IN' )
49+ parser .add_argument ('--midi_ep_num_out' , type = int , default = 0 ,
50+ help = 'endpoint number of MIDI OUT' )
51+ parser .add_argument ('--midi_ep_num_in' , type = int , default = 0 ,
52+ help = 'endpoint number of MIDI IN' )
3753parser .add_argument ('--output_c_file' , type = argparse .FileType ('w' ), required = True )
3854parser .add_argument ('--output_h_file' , type = argparse .FileType ('w' ), required = True )
3955
4763if unknown_hid_devices :
4864 raise ValueError ("Unknown HID devices(s)" , unknown_hid_devices )
4965
50- if args .msc_num_endpoint_pairs not in (1 , 2 ):
51- raise ValueError ("--msc_num_endpoint_pairs must be 1 or 2" )
52-
53-
5466class StringIndex :
5567 """Assign a monotonically increasing index to each unique string. Start with 0."""
5668 string_to_index = {}
@@ -120,7 +132,7 @@ def strings_in_order(cls):
120132 cdc_union ,
121133 standard .EndpointDescriptor (
122134 description = "CDC comm in" ,
123- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_IN ,
135+ bEndpointAddress = args . cdc_ep_num_notification | standard .EndpointDescriptor .DIRECTION_IN ,
124136 bmAttributes = standard .EndpointDescriptor .TYPE_INTERRUPT ,
125137 wMaxPacketSize = 0x0040 ,
126138 bInterval = 0x10 )
@@ -133,11 +145,11 @@ def strings_in_order(cls):
133145 subdescriptors = [
134146 standard .EndpointDescriptor (
135147 description = "CDC data out" ,
136- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_OUT ,
148+ bEndpointAddress = args . cdc_ep_num_data_out | standard .EndpointDescriptor .DIRECTION_OUT ,
137149 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
138150 standard .EndpointDescriptor (
139151 description = "CDC data in" ,
140- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_IN ,
152+ bEndpointAddress = args . cdc_ep_num_data_in | standard .EndpointDescriptor .DIRECTION_IN ,
141153 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
142154 ])
143155
@@ -153,14 +165,12 @@ def strings_in_order(cls):
153165 subdescriptors = [
154166 standard .EndpointDescriptor (
155167 description = "MSC in" ,
156- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_IN ,
168+ bEndpointAddress = args . msc_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
157169 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
158170 bInterval = 0 ),
159171 standard .EndpointDescriptor (
160172 description = "MSC out" ,
161- # SAMD21 needs to use a separate pair of endpoints for MSC.
162- bEndpointAddress = ((0x1 if args .msc_num_endpoint_pairs == 2 else 0x0 ) |
163- standard .EndpointDescriptor .DIRECTION_OUT ),
173+ bEndpointAddress = (args .msc_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ),
164174 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
165175 bInterval = 0 )
166176 ]
@@ -197,7 +207,7 @@ def strings_in_order(cls):
197207# and will fail (possibly silently) if both are not supplied.
198208hid_endpoint_in_descriptor = standard .EndpointDescriptor (
199209 description = "HID in" ,
200- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_IN ,
210+ bEndpointAddress = args . hid_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
201211 bmAttributes = standard .EndpointDescriptor .TYPE_INTERRUPT ,
202212 bInterval = 8 )
203213
@@ -267,12 +277,12 @@ def strings_in_order(cls):
267277 ),
268278 standard .EndpointDescriptor (
269279 description = "MIDI data out to CircuitPython" ,
270- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_OUT ,
280+ bEndpointAddress = args . midi_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ,
271281 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
272282 midi .DataEndpointDescriptor (baAssocJack = [midi_in_jack_emb ]),
273283 standard .EndpointDescriptor (
274284 description = "MIDI data in from CircuitPython" ,
275- bEndpointAddress = 0x0 | standard .EndpointDescriptor .DIRECTION_IN ,
285+ bEndpointAddress = args . midi_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
276286 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
277287 bInterval = 0x0 ),
278288 midi .DataEndpointDescriptor (baAssocJack = [midi_out_jack_emb ]),
@@ -313,10 +323,15 @@ def strings_in_order(cls):
313323if 'AUDIO' in args .devices :
314324 interfaces_to_join .append (audio_interfaces )
315325
316- # util.join_interfaces() will renumber the endpoints to make them unique across descriptors,
317- # and renumber the interfaces in order. But we still need to fix up certain
318- # interface cross-references.
319- interfaces = util .join_interfaces (* interfaces_to_join )
326+ if args .relative_ep_num :
327+ # util.join_interfaces() will renumber the endpoints to make them unique across descriptors,
328+ # and renumber the interfaces in order. But we still need to fix up certain
329+ # interface cross-references.
330+ interfaces = util .join_interfaces (* interfaces_to_join )
331+ else :
332+ # util.renumbers_interfaces() will renumber the interfaces in order. But we still need to
333+ # fix up certain interface cross-references.
334+ interfaces = util .renumbers_interfaces (* interfaces_to_join )
320335
321336# Now adjust the CDC interface cross-references.
322337
0 commit comments