Skip to content

Commit

Permalink
Merge branch 'fix/usb_msc_disconnect_v5.2' into 'release/v5.2'
Browse files Browse the repository at this point in the history
fix(usb/host): Fixed crash on MSC disk disconnection

See merge request espressif/esp-idf!29507
  • Loading branch information
suda-morris committed Mar 11, 2024
2 parents 64cbabf + 6f46cd3 commit c7d2134
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/peripherals/usb/host/msc/main/msc_example_main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
Expand Down Expand Up @@ -217,17 +217,19 @@ static void usb_task(void *args)
};
ESP_ERROR_CHECK(msc_host_install(&msc_config));

bool has_clients = true;
while (true) {
uint32_t event_flags;
usb_host_lib_handle_events(portMAX_DELAY, &event_flags);

// Release devices once all clients has deregistered
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_NO_CLIENTS) {
has_clients = false;
if (usb_host_device_free_all() == ESP_OK) {
break;
};
}
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_ALL_FREE) {
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_ALL_FREE && !has_clients) {
break;
}
}
Expand Down

0 comments on commit c7d2134

Please sign in to comment.