forked from espressif/esp-idf
refactor(usb/examples): Depend on new esp_driver_gpio
This will exclude unneeded drivers from the build.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS "tusb_hid_example_main.c"
|
SRCS "tusb_hid_example_main.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES driver
|
PRIV_REQUIRES esp_driver_gpio
|
||||||
)
|
)
|
||||||
|
@ -3,5 +3,3 @@ idf_component_register(
|
|||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES usb
|
PRIV_REQUIRES usb
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-missing-field-initializers")
|
|
||||||
|
@ -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: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -109,10 +109,9 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
// Install USB Host driver. Should only be called once in entire application
|
// Install USB Host driver. Should only be called once in entire application
|
||||||
ESP_LOGI(TAG, "Installing USB Host");
|
ESP_LOGI(TAG, "Installing USB Host");
|
||||||
const usb_host_config_t host_config = {
|
usb_host_config_t host_config = {};
|
||||||
.skip_phy_setup = false,
|
host_config.skip_phy_setup = false;
|
||||||
.intr_flags = ESP_INTR_FLAG_LEVEL1,
|
host_config.intr_flags = ESP_INTR_FLAG_LEVEL1;
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK(usb_host_install(&host_config));
|
ESP_ERROR_CHECK(usb_host_install(&host_config));
|
||||||
|
|
||||||
// Create a task that will handle USB library events
|
// Create a task that will handle USB library events
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
idf_component_register(SRCS "hid_host_example.c"
|
idf_component_register(SRCS "hid_host_example.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES usb driver
|
PRIV_REQUIRES usb esp_driver_gpio
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
idf_component_register(SRCS "msc_example_main.c"
|
idf_component_register(SRCS "msc_example_main.c"
|
||||||
INCLUDE_DIRS ""
|
INCLUDE_DIRS ""
|
||||||
PRIV_REQUIRES usb fatfs driver esp_timer
|
PRIV_REQUIRES usb fatfs esp_driver_gpio esp_timer
|
||||||
)
|
)
|
||||||
|
@ -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
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -217,17 +217,19 @@ static void usb_task(void *args)
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(msc_host_install(&msc_config));
|
ESP_ERROR_CHECK(msc_host_install(&msc_config));
|
||||||
|
|
||||||
|
bool has_clients = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
uint32_t event_flags;
|
uint32_t event_flags;
|
||||||
usb_host_lib_handle_events(portMAX_DELAY, &event_flags);
|
usb_host_lib_handle_events(portMAX_DELAY, &event_flags);
|
||||||
|
|
||||||
// Release devices once all clients has deregistered
|
// Release devices once all clients has deregistered
|
||||||
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_NO_CLIENTS) {
|
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_NO_CLIENTS) {
|
||||||
|
has_clients = false;
|
||||||
if (usb_host_device_free_all() == ESP_OK) {
|
if (usb_host_device_free_all() == ESP_OK) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_ALL_FREE) {
|
if (event_flags & USB_HOST_LIB_EVENT_FLAGS_ALL_FREE && !has_clients) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
idf_component_register(SRCS "usb_host_lib_main.c" "class_driver.c"
|
idf_component_register(SRCS "usb_host_lib_main.c" "class_driver.c"
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
PRIV_REQUIRES usb driver
|
PRIV_REQUIRES usb esp_driver_gpio
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user