2323DEFAULT_HID_DEVICES = 'KEYBOARD,MOUSE,CONSUMER,GAMEPAD'
2424
2525parser = argparse .ArgumentParser (description = 'Generate USB descriptors.' )
26+ parser .add_argument ('--highspeed' , default = False , action = 'store_true' ,
27+ help = 'descriptor for highspeed device' )
2628parser .add_argument ('--manufacturer' , type = str ,
2729 help = 'manufacturer of the device' )
2830parser .add_argument ('--product' , type = str ,
4042parser .add_argument ('--interface_name' , type = str ,
4143 help = 'The name/prefix to use in the interface descriptions' ,
4244 default = DEFAULT_INTERFACE_NAME )
43- parser .add_argument ('--msc_max_packet_size' , type = int , default = 64 ,
44- help = 'Max packet size for MSC' )
4545parser .add_argument ('--no-renumber_endpoints' , dest = 'renumber_endpoints' , action = 'store_false' ,
4646 help = 'use to not renumber endpoint' )
4747parser .add_argument ('--cdc_ep_num_notification' , type = int , default = 0 ,
@@ -185,11 +185,15 @@ def strings_in_order(cls):
185185 standard .EndpointDescriptor (
186186 description = "CDC data out" ,
187187 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 ),
189191 standard .EndpointDescriptor (
190192 description = "CDC data in" ,
191193 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 ),
193197 ])
194198
195199cdc_interfaces = [cdc_comm_interface , cdc_data_interface ]
@@ -207,13 +211,13 @@ def strings_in_order(cls):
207211 bEndpointAddress = args .msc_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
208212 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
209213 bInterval = 0 ,
210- wMaxPacketSize = args .msc_max_packet_size ),
214+ wMaxPacketSize = 512 if args .highspeed else 64 ),
211215 standard .EndpointDescriptor (
212216 description = "MSC out" ,
213217 bEndpointAddress = (args .msc_ep_num_out | standard .EndpointDescriptor .DIRECTION_OUT ),
214218 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
215219 bInterval = 0 ,
216- wMaxPacketSize = args .msc_max_packet_size )
220+ wMaxPacketSize = 512 if args .highspeed else 64 ),
217221 ]
218222 )
219223]
@@ -319,13 +323,16 @@ def strings_in_order(cls):
319323 standard .EndpointDescriptor (
320324 description = "MIDI data out to {}" .format (args .interface_name ),
321325 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 ),
323329 midi .DataEndpointDescriptor (baAssocJack = [midi_in_jack_emb ]),
324330 standard .EndpointDescriptor (
325331 description = "MIDI data in from {}" .format (args .interface_name ),
326332 bEndpointAddress = args .midi_ep_num_in | standard .EndpointDescriptor .DIRECTION_IN ,
327333 bmAttributes = standard .EndpointDescriptor .TYPE_BULK ,
328- bInterval = 0x0 ),
334+ bInterval = 0x0 ,
335+ wMaxPacketSize = 512 if args .highspeed else 64 ),
329336 midi .DataEndpointDescriptor (baAssocJack = [midi_out_jack_emb ]),
330337 ])
331338
@@ -540,15 +547,15 @@ def strings_in_order(cls):
540547#include <stdint.h>
541548
542549extern 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}
545550extern const uint8_t usb_desc_cfg[{configuration_length}];
546551extern uint16_t usb_serial_number[{serial_number_length}];
547552extern uint16_t const * const string_desc_arr [{string_descriptor_length}];
548553
549554extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
550555
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}
552559
553560// Vendor name included in Inquiry response, max 8 bytes
554561#define CFG_TUD_MSC_VENDOR "{msc_vendor}"
@@ -563,6 +570,7 @@ def strings_in_order(cls):
563570 max_configuration_length = max (hid_descriptor_length , descriptor_length ),
564571 string_descriptor_length = len (pointers_to_strings ),
565572 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' ,
566574 hid_num_devices = len (args .hid_devices ),
567575 msc_vendor = args .manufacturer [:8 ],
568576 msc_product = args .product [:16 ]))
0 commit comments