Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow retrieving the port a device is connected to #2357

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
9 changes: 9 additions & 0 deletions src/host/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
//--------------------------------------------------------------------+
Expand Down
12 changes: 12 additions & 0 deletions src/host/usbh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//--------------------------------------------------------------------+
Expand Down Expand Up @@ -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
//--------------------------------------------------------------------+
Expand Down
Loading