@@ -154,33 +154,42 @@ mp_obj_t common_hal_usb_core_device_get_manufacturer(usb_core_device_obj_t *self
154154
155155
156156mp_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
162164mp_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
180187mp_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