23
23
DEFAULT_HID_DEVICES = 'KEYBOARD,MOUSE,CONSUMER,GAMEPAD'
24
24
25
25
parser = argparse .ArgumentParser (description = 'Generate USB descriptors.' )
26
+ parser .add_argument ('--highspeed' , default = False , action = 'store_true' ,
27
+ help = 'descriptor for highspeed device' )
26
28
parser .add_argument ('--manufacturer' , type = str ,
27
29
help = 'manufacturer of the device' )
28
30
parser .add_argument ('--product' , type = str ,
40
42
parser .add_argument ('--interface_name' , type = str ,
41
43
help = 'The name/prefix to use in the interface descriptions' ,
42
44
default = DEFAULT_INTERFACE_NAME )
43
- parser .add_argument ('--msc_max_packet_size' , type = int , default = 64 ,
44
- help = 'Max packet size for MSC' )
45
45
parser .add_argument ('--no-renumber_endpoints' , dest = 'renumber_endpoints' , action = 'store_false' ,
46
46
help = 'use to not renumber endpoint' )
47
47
parser .add_argument ('--cdc_ep_num_notification' , type = int , default = 0 ,
@@ -185,11 +185,15 @@ def strings_in_order(cls):
185
185
standard .EndpointDescriptor (
186
186
description = "CDC data out" ,
187
187
bEndpointAddress = args .cdc_ep_num_data_out | standard .EndpointDescriptor .DIRECTION_OUT ,
188
- bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
188
+ bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
189
+ bInterval = 0 ,
190
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
189
191
standard .EndpointDescriptor (
190
192
description = "CDC data in" ,
191
193
bEndpointAddress = args .cdc_ep_num_data_in | standard .EndpointDescriptor .DIRECTION_IN ,
192
- bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
194
+ bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
195
+ bInterval = 0 ,
196
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
193
197
])
194
198
195
199
cdc_interfaces = [cdc_comm_interface , cdc_data_interface ]
@@ -207,13 +211,13 @@ def strings_in_order(cls):
207
211
bEndpointAddress = args .msc_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
208
212
bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
209
213
bInterval = 0 ,
210
- wMaxPacketSize = args .msc_max_packet_size ),
214
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
211
215
standard .EndpointDescriptor (
212
216
description = "MSC out" ,
213
217
bEndpointAddress = (args .msc_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ),
214
218
bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
215
219
bInterval = 0 ,
216
- wMaxPacketSize = args .msc_max_packet_size )
220
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
217
221
]
218
222
)
219
223
]
@@ -319,13 +323,16 @@ def strings_in_order(cls):
319
323
standard .EndpointDescriptor (
320
324
description = "MIDI data out to {}" .format (args .interface_name ),
321
325
bEndpointAddress = args .midi_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ,
322
- bmAttributes = standard .EndpointDescriptor .TYPE_BULK ),
326
+ bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
327
+ bInterval = 0 ,
328
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
323
329
midi .DataEndpointDescriptor (baAssocJack = [midi_in_jack_emb ]),
324
330
standard .EndpointDescriptor (
325
331
description = "MIDI data in from {}" .format (args .interface_name ),
326
332
bEndpointAddress = args .midi_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
327
333
bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
328
- bInterval = 0x0 ),
334
+ bInterval = 0x0 ,
335
+ wMaxPacketSize = 512 if args .highspeed else 64 ),
329
336
midi .DataEndpointDescriptor (baAssocJack = [midi_out_jack_emb ]),
330
337
])
331
338
@@ -540,15 +547,15 @@ def strings_in_order(cls):
540
547
#include <stdint.h>
541
548
542
549
extern const uint8_t usb_desc_dev[{device_length}];
543
- // Make sure the control buffer is big enough to fit the descriptor.
544
- #define CFG_TUD_ENUM_BUFFER_SIZE {max_configuration_length}
545
550
extern const uint8_t usb_desc_cfg[{configuration_length}];
546
551
extern uint16_t usb_serial_number[{serial_number_length}];
547
552
extern uint16_t const * const string_desc_arr [{string_descriptor_length}];
548
553
549
554
extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
550
555
551
- #define USB_HID_NUM_DEVICES {hid_num_devices}
556
+ #define CFG_TUSB_RHPORT0_MODE ({rhport0_mode})
557
+
558
+ #define USB_HID_NUM_DEVICES {hid_num_devices}
552
559
553
560
// Vendor name included in Inquiry response, max 8 bytes
554
561
#define CFG_TUD_MSC_VENDOR "{msc_vendor}"
@@ -563,6 +570,7 @@ def strings_in_order(cls):
563
570
max_configuration_length = max (hid_descriptor_length , descriptor_length ),
564
571
string_descriptor_length = len (pointers_to_strings ),
565
572
hid_report_descriptor_length = len (bytes (combined_hid_report_descriptor )),
573
+ rhport0_mode = 'OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED' if args .highspeed else 'OPT_MODE_DEVICE' ,
566
574
hid_num_devices = len (args .hid_devices ),
567
575
msc_vendor = args .manufacturer [:8 ],
568
576
msc_product = args .product [:16 ]))
0 commit comments