mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
refactor(ext_hub): Device release (allows to run usb_host test with ext hub)
754d357frefactor(ext_hub): Fixed device release, optimized the order of closing usbh devicefc61875arefactor(ext_hub): Pospone the device release, if device is not IDLE3fd17b8brefactor(hub): Applied new ext_hub api, refactor func names3003362brefactor(usb_host): Cancel hub porpagation to the user, rename non-critical func19ce9ed6refactor(test_usb_host_async): Added host_lib_task finish notificationf238d75brefactor(ext_port): Remove the error verification, as error will be handled in ext hub driver Co-authored-by: Roman Leonov <roman.leonov@espressif.com>
This commit is contained in:
+12
-10
@@ -221,7 +221,7 @@ static bool _unblock_lib(bool in_isr)
|
||||
return yield;
|
||||
}
|
||||
|
||||
static inline bool _is_internal_client(void *client)
|
||||
static inline bool is_internal_client(void *client)
|
||||
{
|
||||
if (p_host_lib_obj->constant.enum_client && (client == p_host_lib_obj->constant.enum_client)) {
|
||||
return true;
|
||||
@@ -295,7 +295,7 @@ static void usbh_event_callback(usbh_event_data_t *event_data, void *arg)
|
||||
assert(event_data->ctrl_xfer_data.urb != NULL);
|
||||
assert(event_data->ctrl_xfer_data.urb->usb_host_client != NULL);
|
||||
// Redistribute completed control transfers to the clients that submitted them
|
||||
if (_is_internal_client(event_data->ctrl_xfer_data.urb->usb_host_client)) {
|
||||
if (is_internal_client(event_data->ctrl_xfer_data.urb->usb_host_client)) {
|
||||
// Simply call the transfer callback
|
||||
event_data->ctrl_xfer_data.urb->transfer.callback(&event_data->ctrl_xfer_data.urb->transfer);
|
||||
} else {
|
||||
@@ -309,10 +309,11 @@ static void usbh_event_callback(usbh_event_data_t *event_data, void *arg)
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_NEW_DEV: {
|
||||
// Internal client
|
||||
hub_notify_new_dev(event_data->new_dev_data.dev_addr);
|
||||
// External clients
|
||||
// Prepare a NEW_DEV client event message, the send it to all clients
|
||||
if (hub_dev_new(event_data->new_dev_data.dev_addr) == ESP_OK) {
|
||||
// Device is a hub, we do not need to propagate the event to the clients
|
||||
break;
|
||||
}
|
||||
// Prepare a NEW_DEV client event message, and send it to all clients
|
||||
usb_host_client_event_msg_t event_msg = {
|
||||
.event = USB_HOST_CLIENT_EVENT_NEW_DEV,
|
||||
.new_dev.address = event_data->new_dev_data.dev_addr,
|
||||
@@ -321,10 +322,11 @@ static void usbh_event_callback(usbh_event_data_t *event_data, void *arg)
|
||||
break;
|
||||
}
|
||||
case USBH_EVENT_DEV_GONE: {
|
||||
// Internal client
|
||||
hub_notify_dev_gone(event_data->new_dev_data.dev_addr);
|
||||
// External clients
|
||||
// Prepare event msg, send only to clients that have opened the device
|
||||
if (hub_dev_gone(event_data->new_dev_data.dev_addr) == ESP_OK) {
|
||||
// Device is a hub, we do not need to propagate the event to the clients
|
||||
break;
|
||||
}
|
||||
// Prepare a DEV GONE event, send only to clients that have opened the device
|
||||
usb_host_client_event_msg_t event_msg = {
|
||||
.event = USB_HOST_CLIENT_EVENT_DEV_GONE,
|
||||
.dev_gone.dev_hdl = event_data->dev_gone_data.dev_hdl,
|
||||
|
||||
Reference in New Issue
Block a user