diff --git a/src/host/usbh.c b/src/host/usbh.c index 8c488aaa29..5fd34f26e3 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -334,6 +334,15 @@ bool tuh_rhport_reset_bus(uint8_t rhport, bool active) { return true; } +void tuh_devtree_get_info(uint8_t dev_addr, tuh_devtree_info_t* devtree_info) { + hcd_devtree_info_t dt; + hcd_devtree_get_info(dev_addr, &dt); + devtree_info->rhport = dt.rhport; + devtree_info->hub_addr = dt.hub_addr; + devtree_info->hub_port = dt.hub_port; + devtree_info->speed = dt.speed; +} + //--------------------------------------------------------------------+ // PUBLIC API (Parameter Verification is required) //--------------------------------------------------------------------+ diff --git a/src/host/usbh.h b/src/host/usbh.h index 359684169e..ac347073e6 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -92,6 +92,15 @@ typedef union { tuh_configure_max3421_t max3421; } tuh_configure_param_t; +// Return data for tuh_devtree_get_info() +typedef struct +{ + uint8_t rhport; + uint8_t hub_addr; + uint8_t hub_port; + uint8_t speed; +} tuh_devtree_info_t; + //--------------------------------------------------------------------+ // APPLICATION CALLBACK //--------------------------------------------------------------------+ @@ -162,6 +171,9 @@ bool tuh_rhport_is_active(uint8_t rhport); // Assert/de-assert Bus Reset signal to roothub port. USB specs: it should last 10-50ms bool tuh_rhport_reset_bus(uint8_t rhport, bool active); +// Retrieve devtree info like port of hub a device is connected to and speed. +void tuh_devtree_get_info(uint8_t dev_addr, tuh_devtree_info_t* devtree_info); + //--------------------------------------------------------------------+ // Device API //--------------------------------------------------------------------+