Skip to content

Commit a49200d

Browse files
committed
tools: Switch to using separate usb_descriptor repo.
1 parent 7b393bc commit a49200d

File tree

5 files changed

+33
-270
lines changed

5 files changed

+33
-270
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@
3737
path = ports/atmel-samd/asf4
3838
url = https://github.com/adafruit/asf4.git
3939
branch = circuitpython
40+
[submodule "tools/usb_descriptor"]
41+
path = tools/usb_descriptor
42+
url = https://github.com/adafruit/usb_descriptor.git

ports/atmel-samd/tools/gen_usb_descriptor.py

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import sys
55

66
# path hacking
7-
sys.path.append("../../tools")
7+
sys.path.append("../../tools/usb_descriptor")
88

9-
from usb_descriptor import core
10-
from usb_descriptor import cdc
9+
from adafruit_usb_descriptor import cdc, standard, util
1110

1211
parser = argparse.ArgumentParser(description='Generate USB descriptors.')
1312
parser.add_argument('--manufacturer', type=str,
@@ -24,16 +23,16 @@
2423

2524
args = parser.parse_args()
2625

27-
langid = core.StringDescriptor("\u0409")
28-
manufacturer = core.StringDescriptor(args.manufacturer)
29-
product = core.StringDescriptor(args.product)
30-
serial_number = core.StringDescriptor("serial number. you should fill in a unique serial number here."[:args.serial_number_length])
26+
langid = standard.StringDescriptor("\u0409")
27+
manufacturer = standard.StringDescriptor(args.manufacturer)
28+
product = standard.StringDescriptor(args.product)
29+
serial_number = standard.StringDescriptor("serial number. you should fill in a unique serial number here."[:args.serial_number_length])
3130
strings = [langid, manufacturer, product, serial_number]
3231

3332
# vid = 0x239A
3433
# pid = 0x8021
3534

36-
device = core.DeviceDescriptor(
35+
device = standard.DeviceDescriptor(
3736
idVendor=args.vid,
3837
idProduct=args.pid,
3938
iManufacturer=strings.index(manufacturer),
@@ -43,7 +42,7 @@
4342
# Interface numbers are interface set local and endpoints are interface local
4443
# until core.join_interfaces renumbers them.
4544
cdc_interfaces = [
46-
core.InterfaceDescriptor(
45+
standard.InterfaceDescriptor(
4746
bInterfaceClass=0x2, # Communications Device Class
4847
bInterfaceSubClass=0x02, # Abstract control model
4948
bInterfaceProtocol=0x01, # Common AT Commands
@@ -59,53 +58,53 @@
5958
cdc.AbstractControlManagement(bmCapabilities=0x02),
6059
cdc.Union(bMasterInterface=0x00,
6160
bSlaveInterface=[0x01]),
62-
core.EndpointDescriptor(
63-
bEndpointAddress=0x0 | core.EndpointDescriptor.DIRECTION_IN,
64-
bmAttributes=core.EndpointDescriptor.TYPE_INTERRUPT,
61+
standard.EndpointDescriptor(
62+
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_IN,
63+
bmAttributes=standard.EndpointDescriptor.TYPE_INTERRUPT,
6564
wMaxPacketSize=0x8,
6665
bInterval=10)
6766
]
6867
),
69-
core.InterfaceDescriptor(
68+
standard.InterfaceDescriptor(
7069
bInterfaceClass=0x0a,
7170
subdescriptors=[
72-
core.EndpointDescriptor(
73-
bEndpointAddress=0x0 | core.EndpointDescriptor.DIRECTION_IN,
74-
bmAttributes=core.EndpointDescriptor.TYPE_BULK),
75-
core.EndpointDescriptor(
76-
bEndpointAddress=0x0 | core.EndpointDescriptor.DIRECTION_OUT,
77-
bmAttributes=core.EndpointDescriptor.TYPE_BULK)
71+
standard.EndpointDescriptor(
72+
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_IN,
73+
bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
74+
standard.EndpointDescriptor(
75+
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_OUT,
76+
bmAttributes=standard.EndpointDescriptor.TYPE_BULK)
7877
]
7978
)
8079
]
8180

8281
msc_interfaces = [
83-
core.InterfaceDescriptor(
82+
standard.InterfaceDescriptor(
8483
bInterfaceClass=0x08,
8584
bInterfaceSubClass=0x06,
8685
bInterfaceProtocol=0x50,
8786
subdescriptors=[
88-
core.EndpointDescriptor(
89-
bEndpointAddress=0x0 | core.EndpointDescriptor.DIRECTION_IN,
90-
bmAttributes=core.EndpointDescriptor.TYPE_BULK),
91-
core.EndpointDescriptor(
92-
bEndpointAddress=0x1 | core.EndpointDescriptor.DIRECTION_OUT,
93-
bmAttributes=core.EndpointDescriptor.TYPE_BULK)
87+
standard.EndpointDescriptor(
88+
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_IN,
89+
bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
90+
standard.EndpointDescriptor(
91+
bEndpointAddress=0x1 | standard.EndpointDescriptor.DIRECTION_OUT,
92+
bmAttributes=standard.EndpointDescriptor.TYPE_BULK)
9493
]
9594
)
9695
]
9796

98-
interfaces = core.join_interfaces(cdc_interfaces, msc_interfaces)
97+
interfaces = util.join_interfaces(cdc_interfaces, msc_interfaces)
9998

100-
cdc_function = core.InterfaceAssociationDescriptor(
99+
cdc_function = standard.InterfaceAssociationDescriptor(
101100
bFirstInterface=interfaces.index(cdc_interfaces[0]),
102101
bInterfaceCount=len(cdc_interfaces),
103102
bFunctionClass=0x2, # Communications Device Class
104103
bFunctionSubClass=0x2, # Abstract control model
105104
bFunctionProtocol=0x1) # Common AT Commands
106105

107-
configuration = core.ConfigurationDescriptor(
108-
wTotalLength=(core.ConfigurationDescriptor.bLength +
106+
configuration = standard.ConfigurationDescriptor(
107+
wTotalLength=(standard.ConfigurationDescriptor.bLength +
109108
cdc_function.bLength +
110109
sum([len(bytes(x)) for x in interfaces])),
111110
bNumInterfaces=len(interfaces))

tools/usb_descriptor

Submodule usb_descriptor added at a043411

tools/usb_descriptor/cdc.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

tools/usb_descriptor/core.py

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)