Skip to content

Commit

Permalink
IDF release/v5.1 (espressif#9613)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
me-no-dev and SuGlider authored May 13, 2024
1 parent e10de73 commit 0c4b35e
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 2,335 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
set(priv_includes cores/esp32/libb64)
set(requires spi_flash esp_partition mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES})
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES})

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

Expand Down
67 changes: 64 additions & 3 deletions cores/esp32/esp32-hal-tinyusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "rom/gpio.h"

#include "hal/usb_hal.h"
#include "hal/gpio_ll.h"
#include "hal/clk_gate_ll.h"

Expand Down Expand Up @@ -63,6 +62,10 @@ typedef struct {
bool external_phy;
} tinyusb_config_t;

#if __has_include("hal/usb_hal.h")

#include "hal/usb_hal.h"

static bool usb_otg_deinit(void *busptr) {
// Once USB OTG is initialized, its GPIOs are assigned and it shall never be deinited
// except when S3 swithicng usb from cdc to jtag while resetting to bootrom
Expand Down Expand Up @@ -101,10 +104,67 @@ static void configure_pins(usb_hal_context_t *usb) {
}
}

esp_err_t tinyusb_driver_install(const tinyusb_config_t *config) {
usb_hal_context_t hal = {.use_external_phy = config->external_phy};
esp_err_t init_usb_hal(bool external_phy) {
usb_hal_context_t hal = {.use_external_phy = external_phy};
usb_hal_init(&hal);
configure_pins(&hal);
return ESP_OK;
}

esp_err_t deinit_usb_hal() {
return ESP_OK;
}

#elif __has_include("esp_private/usb_phy.h")

#include "esp_private/usb_phy.h"

static usb_phy_handle_t phy_handle = NULL;

esp_err_t init_usb_hal(bool external_phy) {
esp_err_t ret = ESP_OK;
usb_phy_config_t phy_config = {
.controller = USB_PHY_CTRL_OTG,
.target = USB_PHY_TARGET_INT,
.otg_mode = USB_OTG_MODE_DEVICE,
.otg_speed = USB_PHY_SPEED_FULL,
.ext_io_conf = NULL,
.otg_io_conf = NULL,
};

ret = usb_new_phy(&phy_config, &phy_handle);
if (ret != ESP_OK) {
log_e("Failed to init USB PHY");
}
return ret;
}

esp_err_t deinit_usb_hal() {
esp_err_t ret = ESP_OK;
if (phy_handle) {
ret = usb_del_phy(phy_handle);
if (ret != ESP_OK) {
log_e("Failed to deinit USB PHY");
}
}
return ret;
}

#else

#error No way to initialize USP PHY

void init_usb_hal(bool external_phy) {
return ESP_OK;
}

void deinit_usb_hal() {
return ESP_OK;
}
#endif

esp_err_t tinyusb_driver_install(const tinyusb_config_t *config) {
init_usb_hal(config->external_phy);
if (!tusb_init()) {
log_e("Can't initialize the TinyUSB stack.");
return ESP_FAIL;
Expand Down Expand Up @@ -420,6 +480,7 @@ static void hw_cdc_reset_handler(void *arg) {

static void usb_switch_to_cdc_jtag() {
// Disable USB-OTG
deinit_usb_hal();
periph_ll_reset(PERIPH_USB_MODULE);
//periph_ll_enable_clk_clear_rst(PERIPH_USB_MODULE);
periph_ll_disable_clk_set_rst(PERIPH_USB_MODULE);
Expand Down
22 changes: 0 additions & 22 deletions libraries/TFLiteMicro/examples/micro_speech/README.md

This file was deleted.

184 changes: 0 additions & 184 deletions libraries/TFLiteMicro/examples/micro_speech/audio_provider.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions libraries/TFLiteMicro/examples/micro_speech/audio_provider.h

This file was deleted.

26 changes: 0 additions & 26 deletions libraries/TFLiteMicro/examples/micro_speech/command_responder.cpp

This file was deleted.

Loading

0 comments on commit 0c4b35e

Please sign in to comment.