Ejemplo n.º 1
0
    descriptor_list.extend(cdc_interfaces)

if 'MSC' in args.devices:
    descriptor_list.extend(msc_interfaces)

if 'AUDIO' in args.devices:
    # Only add the control interface because other audio interfaces are managed by it to ensure the
    # correct ordering.
    descriptor_list.append(audio_control_interface)

if 'HID' in args.devices:
    descriptor_list.extend(hid_interfaces)

configuration = standard.ConfigurationDescriptor(
    description="Composite configuration",
    wTotalLength=(standard.ConfigurationDescriptor.bLength +
                  sum([len(bytes(x)) for x in descriptor_list])),
    bNumInterfaces=len(interfaces))
descriptor_list.insert(0, configuration)

string_descriptors = [standard.StringDescriptor(string) for string in StringIndex.strings_in_order()]
serial_number_descriptor = string_descriptors[SERIAL_NUMBER_INDEX]

c_file = args.output_c_file
h_file = args.output_h_file


c_file.write("""\
#include <stdint.h>

#include "py/objtuple.h"
                bmAttributes=standard.EndpointDescriptor.TYPE_BULK)
        ])
]

interfaces = util.join_interfaces(cdc_interfaces, msc_interfaces)

cdc_function = standard.InterfaceAssociationDescriptor(
    bFirstInterface=interfaces.index(cdc_interfaces[0]),
    bInterfaceCount=len(cdc_interfaces),
    bFunctionClass=0x2,  # Communications Device Class
    bFunctionSubClass=0x2,  # Abstract control model
    bFunctionProtocol=0x1)  # Common AT Commands

configuration = standard.ConfigurationDescriptor(
    wTotalLength=(standard.ConfigurationDescriptor.bLength +
                  cdc_function.bLength +
                  sum([len(bytes(x)) for x in interfaces])),
    bNumInterfaces=len(interfaces))

descriptor_list = [device, configuration, cdc_function]
descriptor_list.extend(interfaces)
descriptor_list.extend(strings)

output_file = args.output_file

output_file.write("#include <stdint.h>\n\n")
output_file.write("#include \"tools/autogen_usb_descriptor.h\"\n\n")
output_file.write("uint8_t usb_descriptors[] = {\n")
descriptor_length = 0
serial_number_offset = None
for descriptor in descriptor_list: