hub check status before get 1st device descriptor
This commit is contained in:
4
.idea/cmake.xml
generated
4
.idea/cmake.xml
generated
@@ -6,9 +6,9 @@
|
||||
<configuration PROFILE_NAME="raspberrypi_zero2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_zero2 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberrypi_cm4" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberrypi_cm4 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico2_riscv" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2_riscv -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico-pio_host" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico -DLOG=1 -DCFLAGS_CLI="-DCFG_TUH_RPI_PIO_USB=1"" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico2" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="raspberry_pi_pico2-pio_host" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=raspberry_pi_pico2 -DLOG=1 -DCFLAGS_CLI="-DCFG_TUH_RPI_PIO_USB=1"" />
|
||||
<configuration PROFILE_NAME="feather_rp2040" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=pico_sdk -DPICO_BOARD=adafruit_feather_rp2040 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="feather_rp2040_max3421" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=feather_rp2040_max3421 -DLOG=1" />
|
||||
<configuration PROFILE_NAME="metro_rp2040" ENABLED="false" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DBOARD=pico_sdk -DPICO_BOARD=adafruit_metro_rp2040 -DLOG=1 -DMAX3421_HOST=1" />
|
||||
|
@@ -1370,6 +1370,7 @@ enum {
|
||||
ENUM_HUB_RERSET,
|
||||
ENUM_HUB_GET_STATUS_AFTER_RESET,
|
||||
ENUM_HUB_CLEAR_RESET,
|
||||
ENUM_HUB_CLEAR_RESET_COMPLETE,
|
||||
|
||||
ENUM_ADDR0_DEVICE_DESC,
|
||||
ENUM_SET_ADDR,
|
||||
@@ -1511,19 +1512,33 @@ static void process_enumeration(tuh_xfer_t* xfer) {
|
||||
case ENUM_HUB_CLEAR_RESET: {
|
||||
hub_port_status_response_t port_status;
|
||||
hub_port_get_status_local(dev0_bus->hub_addr, dev0_bus->hub_port, &port_status);
|
||||
dev0_bus->speed = (port_status.status.high_speed) ? TUSB_SPEED_HIGH :
|
||||
(port_status.status.low_speed) ? TUSB_SPEED_LOW : TUSB_SPEED_FULL;
|
||||
|
||||
if (port_status.change.reset) {
|
||||
// Acknowledge Port Reset Change
|
||||
TU_ASSERT(hub_port_clear_reset_change(dev0_bus->hub_addr, dev0_bus->hub_port, process_enumeration, ENUM_ADDR0_DEVICE_DESC),);
|
||||
TU_ASSERT(hub_port_clear_reset_change(dev0_bus->hub_addr, dev0_bus->hub_port, process_enumeration, ENUM_HUB_CLEAR_RESET_COMPLETE),);
|
||||
} else {
|
||||
// maybe retry if reset change not set but we need timeout to prevent infinite loop
|
||||
// TU_ASSERT(hub_port_get_status(dev0_bus->hub_addr, dev0_bus->hub_port, NULL, process_enumeration, ENUM_HUB_CLEAR_RESET),);
|
||||
// TU_ASSERT(hub_port_get_status(dev0_bus->hub_addr, dev0_bus->hub_port, NULL, process_enumeration, ENUM_HUB_CLEAR_RESET_COMPLETE),);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ENUM_HUB_CLEAR_RESET_COMPLETE: {
|
||||
hub_port_status_response_t port_status;
|
||||
hub_port_get_status_local(dev0_bus->hub_addr, dev0_bus->hub_port, &port_status);
|
||||
|
||||
if (!port_status.status.connection) {
|
||||
TU_LOG_USBH("Device unplugged from hub (not addressed yet)\r\n");
|
||||
enum_full_complete();
|
||||
return;
|
||||
}
|
||||
|
||||
dev0_bus->speed = (port_status.status.high_speed) ? TUSB_SPEED_HIGH :
|
||||
(port_status.status.low_speed) ? TUSB_SPEED_LOW : TUSB_SPEED_FULL;
|
||||
|
||||
TU_ATTR_FALLTHROUGH;
|
||||
}
|
||||
#endif
|
||||
|
||||
case ENUM_ADDR0_DEVICE_DESC: {
|
||||
|
Reference in New Issue
Block a user