Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c4b35e

Browse files
me-no-devSuGlider
andauthored
IDF release/v5.1 (#9613)
* IDF release/v5.1 01b912a9e5 * Fix USB OTG Init on new IDF * Delete libraries/TFLiteMicro/examples/micro_speech directory Done in order to fix a CI problem created by an entire folder that was removed in original Library Repository. * IDF release/v5.1 442a798083 * Update esp32-hal-tinyusb.c --------- Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
1 parent e10de73 commit 0c4b35e

21 files changed

+99
-2335
lines changed

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA
288288
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
289289
set(priv_includes cores/esp32/libb64)
290290
set(requires spi_flash esp_partition mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
291-
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES})
291+
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES})
292292

293293
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
294294

‎cores/esp32/esp32-hal-tinyusb.c‎

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include "rom/gpio.h"
2424

25-
#include "hal/usb_hal.h"
2625
#include "hal/gpio_ll.h"
2726
#include "hal/clk_gate_ll.h"
2827

@@ -63,6 +62,10 @@ typedef struct {
6362
bool external_phy;
6463
} tinyusb_config_t;
6564

65+
#if __has_include("hal/usb_hal.h")
66+
67+
#include "hal/usb_hal.h"
68+
6669
static bool usb_otg_deinit(void *busptr) {
6770
// Once USB OTG is initialized, its GPIOs are assigned and it shall never be deinited
6871
// except when S3 swithicng usb from cdc to jtag while resetting to bootrom
@@ -101,10 +104,67 @@ static void configure_pins(usb_hal_context_t *usb) {
101104
}
102105
}
103106

104-
esp_err_t tinyusb_driver_install(consttinyusb_config_t*config) {
105-
usb_hal_context_t hal = {.use_external_phy = config->external_phy};
107+
esp_err_t init_usb_hal(boolexternal_phy) {
108+
usb_hal_context_t hal = {.use_external_phy = external_phy};
106109
usb_hal_init(&hal);
107110
configure_pins(&hal);
111+
return ESP_OK;
112+
}
113+
114+
esp_err_t deinit_usb_hal() {
115+
return ESP_OK;
116+
}
117+
118+
#elif __has_include("esp_private/usb_phy.h")
119+
120+
#include "esp_private/usb_phy.h"
121+
122+
static usb_phy_handle_t phy_handle = NULL;
123+
124+
esp_err_t init_usb_hal(bool external_phy) {
125+
esp_err_t ret = ESP_OK;
126+
usb_phy_config_t phy_config = {
127+
.controller = USB_PHY_CTRL_OTG,
128+
.target = USB_PHY_TARGET_INT,
129+
.otg_mode = USB_OTG_MODE_DEVICE,
130+
.otg_speed = USB_PHY_SPEED_FULL,
131+
.ext_io_conf = NULL,
132+
.otg_io_conf = NULL,
133+
};
134+
135+
ret = usb_new_phy(&phy_config, &phy_handle);
136+
if (ret != ESP_OK) {
137+
log_e("Failed to init USB PHY");
138+
}
139+
return ret;
140+
}
141+
142+
esp_err_t deinit_usb_hal() {
143+
esp_err_t ret = ESP_OK;
144+
if (phy_handle) {
145+
ret = usb_del_phy(phy_handle);
146+
if (ret != ESP_OK) {
147+
log_e("Failed to deinit USB PHY");
148+
}
149+
}
150+
return ret;
151+
}
152+
153+
#else
154+
155+
#error No way to initialize USP PHY
156+
157+
void init_usb_hal(bool external_phy) {
158+
return ESP_OK;
159+
}
160+
161+
void deinit_usb_hal() {
162+
return ESP_OK;
163+
}
164+
#endif
165+
166+
esp_err_t tinyusb_driver_install(const tinyusb_config_t *config) {
167+
init_usb_hal(config->external_phy);
108168
if (!tusb_init()) {
109169
log_e("Can't initialize the TinyUSB stack.");
110170
return ESP_FAIL;
@@ -420,6 +480,7 @@ static void hw_cdc_reset_handler(void *arg) {
420480

421481
static void usb_switch_to_cdc_jtag() {
422482
// Disable USB-OTG
483+
deinit_usb_hal();
423484
periph_ll_reset(PERIPH_USB_MODULE);
424485
//periph_ll_enable_clk_clear_rst(PERIPH_USB_MODULE);
425486
periph_ll_disable_clk_set_rst(PERIPH_USB_MODULE);

‎libraries/TFLiteMicro/examples/micro_speech/README.md‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎libraries/TFLiteMicro/examples/micro_speech/audio_provider.cpp‎

Lines changed: 0 additions & 184 deletions
This file was deleted.

‎libraries/TFLiteMicro/examples/micro_speech/audio_provider.h‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎libraries/TFLiteMicro/examples/micro_speech/command_responder.cpp‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /