Skip to content

Commit 369d37e

Browse files
committed
Update tinyusb to improve direct USB host
These changes improve direct USB host on RP2350 in particular.
1 parent a3506a7 commit 369d37e

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@
346346
url = https://github.com/adafruit/Adafruit_CircuitPython_Wave.git
347347
[submodule "ports/raspberrypi/lib/Pico-PIO-USB"]
348348
path = ports/raspberrypi/lib/Pico-PIO-USB
349-
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
350-
branch = main
349+
url = https://github.com/hathach/Pico-PIO-USB.git
350+
branch = fix-lowspeed-turraround
351351
[submodule "lib/micropython-lib"]
352352
path = lib/micropython-lib
353353
url = https://github.com/micropython/micropython-lib.git

lib/tinyusb

Submodule tinyusb updated 97 files

shared-module/usb/core/Device.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,33 +154,42 @@ mp_obj_t common_hal_usb_core_device_get_manufacturer(usb_core_device_obj_t *self
154154

155155

156156
mp_int_t common_hal_usb_core_device_get_bus(usb_core_device_obj_t *self) {
157-
hcd_devtree_info_t devtree;
158-
hcd_devtree_get_info(self->device_address, &devtree);
159-
return devtree.rhport;
157+
tuh_bus_info_t bus_info;
158+
if (!tuh_bus_info_get(self->device_address, &bus_info)) {
159+
return 0;
160+
}
161+
return bus_info.rhport;
160162
}
161163

162164
mp_obj_t common_hal_usb_core_device_get_port_numbers(usb_core_device_obj_t *self) {
163-
hcd_devtree_info_t devtree;
164-
hcd_devtree_get_info(self->device_address, &devtree);
165-
if (devtree.hub_addr == 0) {
165+
tuh_bus_info_t bus_info;
166+
if (!tuh_bus_info_get(self->device_address, &bus_info)) {
167+
return mp_const_none;
168+
}
169+
if (bus_info.hub_addr == 0) {
166170
return mp_const_none;
167171
}
168172
// USB allows for 5 hubs deep chaining. So we're at most 5 ports deep.
169173
mp_obj_t ports[5];
170174
size_t port_count = 0;
171-
while (devtree.hub_addr != 0 && port_count < MP_ARRAY_SIZE(ports)) {
175+
tuh_bus_info_t current_bus_info = bus_info;
176+
while (current_bus_info.hub_addr != 0 && port_count < MP_ARRAY_SIZE(ports)) {
172177
// Reverse the order of the ports so most downstream comes last.
173-
ports[MP_ARRAY_SIZE(ports) - 1 - port_count] = MP_OBJ_NEW_SMALL_INT(devtree.hub_port);
178+
ports[MP_ARRAY_SIZE(ports) - 1 - port_count] = MP_OBJ_NEW_SMALL_INT(current_bus_info.hub_port);
174179
port_count++;
175-
hcd_devtree_get_info(devtree.hub_addr, &devtree);
180+
if (!tuh_bus_info_get(current_bus_info.hub_addr, &current_bus_info)) {
181+
break;
182+
}
176183
}
177184
return mp_obj_new_tuple(port_count, ports + (MP_ARRAY_SIZE(ports) - port_count));
178185
}
179186

180187
mp_int_t common_hal_usb_core_device_get_speed(usb_core_device_obj_t *self) {
181-
hcd_devtree_info_t devtree;
182-
hcd_devtree_get_info(self->device_address, &devtree);
183-
switch (devtree.speed) {
188+
tuh_bus_info_t bus_info;
189+
if (!tuh_bus_info_get(self->device_address, &bus_info)) {
190+
return 0;
191+
}
192+
switch (bus_info.speed) {
184193
case TUSB_SPEED_HIGH:
185194
return PYUSB_SPEED_HIGH;
186195
case TUSB_SPEED_FULL:

0 commit comments

Comments
 (0)